Rev 5872: Trap an InconsistentDelta case. add can try to add another in http://bazaar.launchpad.net/~jameinel/bzr/2.4-set-parent-trees-delta-282941
John Arbash Meinel
john at arbash-meinel.com
Thu May 19 11:08:34 UTC 2011
At http://bazaar.launchpad.net/~jameinel/bzr/2.4-set-parent-trees-delta-282941
------------------------------------------------------------
revno: 5872
revision-id: john at arbash-meinel.com-20110519110825-bfdizt740uglh684
parent: john at arbash-meinel.com-20110519110008-98fwqaapn0zyh10h
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.4-set-parent-trees-delta-282941
timestamp: Thu 2011-05-19 13:08:25 +0200
message:
Trap an InconsistentDelta case. add can try to add another
entry to the same location. Not too bad to detect, since we just need
to look at nearby locations.
-------------- next part --------------
=== modified file 'bzrlib/dirstate.py'
--- a/bzrlib/dirstate.py 2011-05-19 11:00:08 +0000
+++ b/bzrlib/dirstate.py 2011-05-19 11:08:25 +0000
@@ -1697,16 +1697,20 @@
if maybe_index < 0 or maybe_index >= len(block):
continue
maybe_entry = block[maybe_index]
- if maybe_entry[0][:2] == (dirname, basename):
- # There is another record with the same path
- if maybe_entry[0][2] == file_id:
- raise AssertionError('shouldnt happen')
- basis_kind = maybe_entry[1][1][0]
- if basis_kind not in 'ar':
- self._raise_invalid(new_path, file_id,
- "we have an add record for path, but the path"
- " is already present with another file_id %s"
- % (maybe_entry[0][2],))
+ if maybe_entry[0][:2] != (dirname, basename):
+ # Just a random neighbor
+ continue
+ if maybe_entry[0][2] == file_id:
+ raise AssertionError(
+ '_find_entry_index didnt find a key match'
+ ' but walking the data did, for %s'
+ % (entry_key,))
+ basis_kind = maybe_entry[1][1][0]
+ if basis_kind not in 'ar':
+ self._raise_invalid(new_path, file_id,
+ "we have an add record for path, but the path"
+ " is already present with another file_id %s"
+ % (maybe_entry[0][2],))
entry = (entry_key, [DirState.NULL_PARENT_DETAILS,
new_details])
=== modified file 'bzrlib/tests/test_dirstate.py'
--- a/bzrlib/tests/test_dirstate.py 2011-05-19 11:00:08 +0000
+++ b/bzrlib/tests/test_dirstate.py 2011-05-19 11:08:25 +0000
@@ -2541,14 +2541,14 @@
state = self.create_empty_dirstate()
state.set_state_from_scratch(active_tree.inventory,
[('basis', basis_tree)], [])
- # self.assertRaises(errors.InconsistentDelta,
- # state.update_basis_by_delta, inv_delta, 'target')
- try:
- state.update_basis_by_delta(inv_delta, 'target')
- except errors.InconsistentDelta, e:
- pass
- else:
- import pdb; pdb.set_trace()
+ self.assertRaises(errors.InconsistentDelta,
+ state.update_basis_by_delta, inv_delta, 'target')
+ # try:
+ # state.update_basis_by_delta(inv_delta, 'target')
+ # except errors.InconsistentDelta, e:
+ # pass
+ # else:
+ # import pdb; pdb.set_trace()
self.assertTrue(state._changes_aborted)
def test_remove_file_matching_active_state(self):
@@ -2676,9 +2676,15 @@
delta=[('other-file', 'file', 'file-id')])
def test_invalid_new_id_same_path(self):
+ # The bad entry comes after
state = self.assertBadDelta(
active=[('file', 'file-id')],
basis= [('file', 'file-id')],
delta=[(None, 'file', 'file-id-2')])
+ # The bad entry comes first
+ state = self.assertBadDelta(
+ active=[('file', 'file-id-2')],
+ basis= [('file', 'file-id-2')],
+ delta=[(None, 'file', 'file-id')])
# TODO: Test stuff like renaming a directory, and renaming contents therein
More information about the bazaar-commits
mailing list