Rev 5874: Handle missing parent, though bugs may still remain 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:19:51 UTC 2011
At http://bazaar.launchpad.net/~jameinel/bzr/2.4-set-parent-trees-delta-282941
------------------------------------------------------------
revno: 5874
revision-id: john at arbash-meinel.com-20110519111942-cz9mhf58vow11f28
parent: john at arbash-meinel.com-20110519111330-j2cfilod2l3qympr
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.4-set-parent-trees-delta-282941
timestamp: Thu 2011-05-19 13:19:42 +0200
message:
Handle missing parent, though bugs may still remain
-------------- next part --------------
=== modified file 'bzrlib/dirstate.py'
--- a/bzrlib/dirstate.py 2011-05-19 11:13:30 +0000
+++ b/bzrlib/dirstate.py 2011-05-19 11:19:42 +0000
@@ -1666,8 +1666,13 @@
for old_path, new_path, file_id, new_details, real_add in adds:
dirname, basename = osutils.split(new_path)
entry_key = st(dirname, basename, file_id)
- # TODO: consider if we need add_if_missing=True
- _, block = self._find_block(entry_key)
+ try:
+ # TODO: consider if we need add_if_missing=True
+ _, block = self._find_block(entry_key)
+ except errors.NotVersionedError, e:
+ self._raise_invalid(new_path, file_id,
+ "Got a not-versioned error trying to add path."
+ " Is the parent missing? %s" % (e,))
entry_index, present = self._find_entry_index(entry_key, block)
if real_add:
if old_path is not None:
=== modified file 'bzrlib/tests/test_dirstate.py'
--- a/bzrlib/tests/test_dirstate.py 2011-05-19 11:13:30 +0000
+++ b/bzrlib/tests/test_dirstate.py 2011-05-19 11:19:42 +0000
@@ -2451,7 +2451,10 @@
else:
is_dir = False
dirname, basename = osutils.split(path)
- dir_id = dir_ids[dirname]
+ try:
+ dir_id = dir_ids[dirname]
+ except KeyError:
+ dir_id = 'missing_parent_id'
if is_dir:
ie = inventory.InventoryDirectory(file_id, basename, dir_id)
dir_ids[path] = dir_id
@@ -2684,13 +2687,18 @@
# The bad entry comes first
state = self.assertBadDelta(
active=[('file', 'file-id-2')],
- basis= [('file', 'file-id-2')],
+ basis=[('file', 'file-id-2')],
delta=[(None, 'file', 'file-id')])
- def test_invalid_repeated_id(self):
+ def test_invalid_existing_id(self):
state = self.assertBadDelta(
active=[('file', 'file-id')],
basis= [('file', 'file-id')],
delta=[(None, 'file', 'file-id')])
+ def test_invalid_parent_missing(self):
+ state = self.assertBadDelta(
+ active=[],
+ basis= [],
+ delta=[(None, 'path/path2', 'file-id')])
# TODO: Test stuff like renaming a directory, and renaming contents therein
=== modified file 'bzrlib/tests/test_inv.py'
--- a/bzrlib/tests/test_inv.py 2011-05-19 10:24:09 +0000
+++ b/bzrlib/tests/test_inv.py 2011-05-19 11:19:42 +0000
@@ -622,7 +622,6 @@
parent2.revision = 'result'
inv.add(parent1)
delta = [(None, u'dir1', 'p-2', parent2)]
- self.apply_delta(self, inv, delta)
self.assertRaises(errors.InconsistentDelta, self.apply_delta, self,
inv, delta)
More information about the bazaar-commits
mailing list