Rev 2419: find an edge case in our _get_entry logic and fix it. in http://bazaar.launchpad.net/%7Ebzr/bzr/dirstate
John Arbash Meinel
john at arbash-meinel.com
Mon Feb 26 19:20:00 GMT 2007
At http://bazaar.launchpad.net/%7Ebzr/bzr/dirstate
------------------------------------------------------------
revno: 2419
revision-id: john at arbash-meinel.com-20070226191858-04chtw4qy4a1p3tz
parent: john at arbash-meinel.com-20070226170938-ik5w1cd0a1tuzsgq
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate
timestamp: Mon 2007-02-26 13:18:58 -0600
message:
find an edge case in our _get_entry logic and fix it.
Also, id2path doesn't need to grab the index, just use _get_entry.
modified:
bzrlib/dirstate.py dirstate.py-20060728012006-d6mvoihjb3je9peu-1
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
-------------- next part --------------
=== modified file 'bzrlib/dirstate.py'
--- a/bzrlib/dirstate.py 2007-02-26 16:53:16 +0000
+++ b/bzrlib/dirstate.py 2007-02-26 19:18:58 +0000
@@ -1148,7 +1148,7 @@
If either file_id or path is supplied, it is used as the key to lookup.
If both are supplied, the fastest lookup is used, and an error is
raised if they do not both point at the same row.
-
+
:param tree_index: The index of the tree we wish to locate this path
in. If the path is present in that tree, the entry containing its
details is returned, otherwise (None, None) is returned
@@ -1173,6 +1173,7 @@
' tree_index, file_id and path')
return entry
else:
+ assert fileid_utf8 is not None
possible_keys = self._get_id_index().get(fileid_utf8, None)
if not possible_keys:
return None, None
@@ -1182,8 +1183,21 @@
tree_index)
if file_present:
entry = self._dirblocks[block_index][1][entry_index]
+ # _get_block_entry_index only returns entries that are not
+ # absent in the current tree. _get_id_index will return
+ # both locations for a renamed file. It is possible that a
+ # new file was added at the same location that the old file
+ # was renamed away. So _get_block_entry_index will actually
+ # match the new file, skipping the fact that the real entry
+ # we want is the rename. By just continuing here, we should
+ # find the record at the target location, because
+ # _get_id_index should return all locations.
+ if entry[0][2] != fileid_utf8:
+ continue
assert entry[1][tree_index][0] not in ('a', 'r')
- assert key == entry[0]
+ assert key == entry[0], ('We were told that %s would be at'
+ ' %s, %s, but we found %s' % (key, block_index,
+ entry_index, entry))
return entry
return None, None
=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py 2007-02-26 05:54:44 +0000
+++ b/bzrlib/workingtree_4.py 2007-02-26 19:18:58 +0000
@@ -389,7 +389,6 @@
def id2path(self, file_id):
file_id = osutils.safe_file_id(file_id)
state = self.current_dirstate()
- possible_dir_name_ids = state._get_id_index().get(file_id, None)
entry = self._get_entry(file_id=file_id)
if entry == (None, None):
return None
More information about the bazaar-commits
mailing list