Rev 2407: _iter_changes should return Unicode paths. in http://bazaar.launchpad.net/%7Ebzr/bzr/dirstate
John Arbash Meinel
john at arbash-meinel.com
Mon Feb 26 02:12:34 GMT 2007
At http://bazaar.launchpad.net/%7Ebzr/bzr/dirstate
------------------------------------------------------------
revno: 2407
revision-id: john at arbash-meinel.com-20070226021126-m31pb4ci3lxrjha8
parent: robertc at robertcollins.net-20070226013238-w7sjnnn1d7uvcpg5
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate
timestamp: Sun 2007-02-25 20:11:26 -0600
message:
_iter_changes should return Unicode paths.
Also, support NULL_REVISION by special casing the source_index
and just stating that all entries are absent.
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
-------------- next part --------------
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2007-02-17 03:34:50 +0000
+++ b/bzrlib/builtins.py 2007-02-26 02:11:26 +0000
@@ -2440,8 +2440,20 @@
merge_type = _mod_merge.Merge3Merger
if directory is None: directory = u'.'
+ # XXX: jam 20070225 WorkingTree should be locked before you extract its
+ # inventory. Because merge is a mutating operation, it really
+ # should be a lock_write() for the whole cmd_merge operation.
+ # However, cmd_merge open's its own tree in _merge_helper, which
+ # means if we lock here, the later lock_write() will always block.
+ # Either the merge helper code should be updated to take a tree,
+ # or the ChangeReporter should be updated to not require an
+ # inventory. (What about tree.merge_from_branch?)
tree = WorkingTree.open_containing(directory)[0]
- change_reporter = delta.ChangeReporter(tree.inventory)
+ tree.lock_read()
+ try:
+ change_reporter = delta.ChangeReporter(tree.inventory)
+ finally:
+ tree.unlock()
if branch is not None:
try:
=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py 2007-02-26 01:32:38 +0000
+++ b/bzrlib/workingtree_4.py 2007-02-26 02:11:26 +0000
@@ -1404,10 +1404,17 @@
require_versioned):
yield f
return
- assert (self.source._revision_id in self.target.get_parent_ids())
- parents = self.target.get_parent_ids()
+ parent_ids = self.target.get_parent_ids()
target_index = 0
- source_index = 1 + parents.index(self.source._revision_id)
+ if self.source._revision_id == NULL_REVISION:
+ source_index = None
+ indices = (target_index,)
+ else:
+ assert (self.source._revision_id in parent_ids), \
+ "Failure: source._revision_id: %s not in target.parent_ids(%s)" % (
+ self.source._revision_id, parent_ids)
+ source_index = 1 + parent_ids.index(self.source._revision_id)
+ indices = (source_index,target_index)
# -- make all specific_files utf8 --
if specific_files:
specific_files_utf8 = set()
@@ -1442,7 +1449,6 @@
# -- check all supplied paths are versioned in a search tree. --
all_versioned = True
for path in specific_files:
- path = path.encode('utf8')
path_entries = _entries_for_path(path)
if not path_entries:
# this specified path is not present at all: error
@@ -1452,7 +1458,7 @@
# for each id at this path
for entry in path_entries:
# for each tree.
- for index in source_index, target_index:
+ for index in indices:
if entry[1][index][0] != 'a': # absent
found_versioned = True
# all good: found a versioned cell
@@ -1511,6 +1517,7 @@
# relocated path as one to search if its not searched already. If the
# detail is not relocated, add the id.
searched_specific_files = set()
+ NULL_PARENT_DETAILS = dirstate.DirState.NULL_PARENT_DETAILS
def _process_entry(entry, path_info):
"""Compare an entry and real disk to generate delta information.
@@ -1519,7 +1526,10 @@
(Perhaps we should pass in a concrete entry for this ?)
"""
# TODO: when a parent has been renamed, dont emit path renames for children,
- source_details = entry[1][source_index]
+ if source_index is None:
+ source_details = NULL_PARENT_DETAILS
+ else:
+ source_details = entry[1][source_index]
target_details = entry[1][target_index]
if source_details[0] in 'rfdl' and target_details[0] in 'fdl':
# claimed content in both: diff
@@ -1588,7 +1598,13 @@
target_exec = bool(
stat.S_ISREG(path_info[3].st_mode)
and stat.S_IEXEC & path_info[3].st_mode)
- return ((entry[0][2], path, content_change, (True, True), (source_parent_id, target_parent_id), (old_basename, entry[0][1]), (dirstate.DirState._minikind_to_kind[source_details[0]], path_info[2]), (source_exec, target_exec)),)
+ path_unicode = path.decode('utf8')
+ return ((entry[0][2], path_unicode, content_change,
+ (True, True),
+ (source_parent_id, target_parent_id),
+ (old_basename, entry[0][1]),
+ (dirstate.DirState._minikind_to_kind[source_details[0]], path_info[2]),
+ (source_exec, target_exec)),)
elif source_details[0] in 'a' and target_details[0] in 'fdl':
# looks like a new file
if path_info is not None:
@@ -1602,7 +1618,13 @@
new_executable = bool(
stat.S_ISREG(path_info[3].st_mode)
and stat.S_IEXEC & path_info[3].st_mode)
- return ((entry[0][2], path, True, (False, True), (None, parent_id), (None, entry[0][1]), (None, path_info[2]), (None, new_executable)),)
+ path_unicode = path.decode('utf8')
+ return ((entry[0][2], path_unicode, True,
+ (False, True),
+ (None, parent_id),
+ (None, entry[0][1]),
+ (None, path_info[2]),
+ (None, new_executable)),)
else:
# but its not on disk: we deliberately treat this as just
# never-present. (Why ?! - RBC 20070224)
@@ -1617,7 +1639,13 @@
parent_id = state._get_entry(source_index, path_utf8=entry[0][0])[0][2]
if parent_id == entry[0][2]:
parent_id = None
- return ((entry[0][2], old_path, True, (True, False), (parent_id, None), (entry[0][1], None), (dirstate.DirState._minikind_to_kind[source_details[0]], None), (source_details[3], None)),)
+ old_path_unicode = old_path.decode('utf8')
+ return ((entry[0][2], old_path_unicode, True,
+ (True, False),
+ (parent_id, None),
+ (entry[0][1], None),
+ (dirstate.DirState._minikind_to_kind[source_details[0]], None),
+ (source_details[3], None)),)
elif source_details[0] in 'fdl' and target_details[0] in 'r':
# a rename; could be a true rename, or a rename inherited from
# a renamed parent. TODO: handle this efficiently. Its not
More information about the bazaar-commits
mailing list