Rev 6574: (bug #830497) Teach Dirstate._validate to check that id_index maps back to actual entries. in http://bazaar.launchpad.net/~jameinel/tree-root-dirstate-830947
John Arbash Meinel
john at arbash-meinel.com
Sun May 19 11:43:00 UTC 2013
At http://bazaar.launchpad.net/~jameinel/tree-root-dirstate-830947
------------------------------------------------------------
revno: 6574
revision-id: john at arbash-meinel.com-20130519114254-n0suab1h0lh1b2bh
parent: pqm at pqm.ubuntu.com-20130207092516-eax0tqbckd3oiaw8
fixes bug: https://launchpad.net/bugs/830497
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: tree-root-dirstate-830947
timestamp: Sun 2013-05-19 12:42:54 +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 2012-01-24 01:35:56 +0000
+++ b/bzrlib/dirstate.py 2013-05-19 11:42:54 +0000
@@ -2566,13 +2566,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.
@@ -3285,10 +3278,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