Rev 6074: (bug #830497) Teach Dirstate._validate to check that id_index maps back to actual entries. in http://bazaar.launchpad.net/~jameinel/bzr/2.4-tree-root-dirstate-830947
John Arbash Meinel
john at arbash-meinel.com
Sun May 19 11:45:47 UTC 2013
At http://bazaar.launchpad.net/~jameinel/bzr/2.4-tree-root-dirstate-830947
------------------------------------------------------------
revno: 6074
revision-id: john at arbash-meinel.com-20130519114542-fllc0nqo0r33ia2p
parent: pqm at pqm.ubuntu.com-20121106185552-58jmp21g8cxqsy16
fixes bug: https://launchpad.net/bugs/830497
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.4-tree-root-dirstate-830947
timestamp: Sun 2013-05-19 12:45:42 +0100
message:
(bug #830497) Teach Dirstate._validate to check that id_index maps back to actual entries.
This makes it clear that set_root_id should not be updating the index, as update_minimal
is likely doing it correctly. (you don't want id_index to map to the unset root location,
only to the currently set locations.)
This makes the plain set_root_id test fail, which means we don't have to write
any new tests.
-------------- next part --------------
=== modified file 'bzrlib/dirstate.py'
--- a/bzrlib/dirstate.py 2011-09-28 15:41:38 +0000
+++ b/bzrlib/dirstate.py 2013-05-19 11:45:42 +0000
@@ -2609,13 +2609,6 @@
self.update_minimal(('', '', new_id), 'd',
path_utf8='', packed_stat=entry[1][0][4])
self._mark_modified()
- # XXX: This was added by Ian, we need to make sure there
- # are tests for it, because it isn't in bzr.dev TRUNK
- # It looks like the only place it is called is in setting the root
- # id of the tree. So probably we never had an _id_index when we
- # don't even have a root yet.
- if self._id_index is not None:
- self._add_to_id_index(self._id_index, entry[0])
def set_parent_trees(self, trees, ghosts):
"""Set the parent trees for the dirstate.
@@ -3328,10 +3321,20 @@
if self._id_index is not None:
for file_id, entry_keys in self._id_index.iteritems():
for entry_key in entry_keys:
+ # Check that the entry in the map is pointing to the same
+ # file_id
if entry_key[2] != file_id:
raise AssertionError(
'file_id %r did not match entry key %s'
% (file_id, entry_key))
+ # And that from this entry key, we can look up the original
+ # record
+ block_index, present = self._find_block_index_from_key(entry_key)
+ if not present:
+ raise AssertionError('missing block for entry key: %r', entry_key)
+ entry_index, present = self._find_entry_index(entry_key, self._dirblocks[block_index][1])
+ if not present:
+ raise AssertionError('missing entry for key: %r', entry_key)
if len(entry_keys) != len(set(entry_keys)):
raise AssertionError(
'id_index contained non-unique data for %s'
More information about the bazaar-commits
mailing list