Rev 5871: Start handling an InconsistentDelta case exposed by test_inv cases. 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:00:17 UTC 2011
At http://bazaar.launchpad.net/~jameinel/bzr/2.4-set-parent-trees-delta-282941
------------------------------------------------------------
revno: 5871
revision-id: john at arbash-meinel.com-20110519110008-98fwqaapn0zyh10h
parent: john at arbash-meinel.com-20110519104149-dcpo5kyzw4o38tbr
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.4-set-parent-trees-delta-282941
timestamp: Thu 2011-05-19 13:00:08 +0200
message:
Start handling an InconsistentDelta case exposed by test_inv cases.
-------------- next part --------------
=== modified file 'bzrlib/dirstate.py'
--- a/bzrlib/dirstate.py 2011-05-19 10:24:09 +0000
+++ b/bzrlib/dirstate.py 2011-05-19 11:00:08 +0000
@@ -1689,9 +1689,29 @@
"An entry was marked as a new add"
" but the basis target already existed")
else:
+ # The exact key was not found in the block. However, we need to
+ # check if there is a key next to us that would have matched.
+ # We only need to check 2 locations, because there are only 2
+ # trees present.
+ for maybe_index in range(entry_index-1, entry_index+1):
+ 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],))
+
entry = (entry_key, [DirState.NULL_PARENT_DETAILS,
new_details])
block.insert(entry_index, entry)
+
active_kind = entry[1][0][0]
if active_kind == 'a':
# The active record shows up as absent, this could be genuine,
=== modified file 'bzrlib/tests/test_dirstate.py'
--- a/bzrlib/tests/test_dirstate.py 2011-05-19 10:41:49 +0000
+++ b/bzrlib/tests/test_dirstate.py 2011-05-19 11:00:08 +0000
@@ -2541,8 +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')
+ # 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):
@@ -2669,4 +2675,10 @@
basis= [('file', 'file-id')],
delta=[('other-file', 'file', 'file-id')])
+ def test_invalid_new_id_same_path(self):
+ state = self.assertBadDelta(
+ active=[('file', 'file-id')],
+ basis= [('file', 'file-id')],
+ delta=[(None, 'file', 'file-id-2')])
+
# TODO: Test stuff like renaming a directory, and renaming contents therein
More information about the bazaar-commits
mailing list