Rev 2325: dirstate correctness: allow adding paths present in the basis. in file:///home/robertc/source/baz/dirstate.0.15/
Robert Collins
robertc at robertcollins.net
Thu Mar 8 23:55:15 GMT 2007
At file:///home/robertc/source/baz/dirstate.0.15/
------------------------------------------------------------
revno: 2325
revision-id: robertc at robertcollins.net-20070308235512-ubrfi3dy7qb52zz0
parent: pqm at pqm.ubuntu.com-20070307115404-732b59c3532cf919
committer: Robert Collins <robertc at robertcollins.net>
branch nick: dirstate.0.15
timestamp: Fri 2007-03-09 10:55:12 +1100
message:
dirstate correctness: allow adding paths present in the basis.
modified:
bzrlib/dirstate.py dirstate.py-20060728012006-d6mvoihjb3je9peu-1
bzrlib/tests/workingtree_implementations/test_add.py test_add.py-20070226165239-4vo178spkrnhavc7-1
=== modified file 'bzrlib/dirstate.py'
--- a/bzrlib/dirstate.py 2007-03-07 08:00:48 +0000
+++ b/bzrlib/dirstate.py 2007-03-08 23:55:12 +0000
@@ -420,8 +420,11 @@
else:
raise errors.BzrError('unknown kind %r' % kind)
entry_index, present = self._find_entry_index(entry_key, block)
- assert not present, "basename %r already added" % basename
- block.insert(entry_index, entry_data)
+ if not present:
+ block.insert(entry_index, entry_data)
+ else:
+ assert block[entry_index][1][0][0] == 'a', " %r(%r) already added" % (basename, file_id)
+ block[entry_index][1][0] = entry_data[1][0]
if kind == 'directory':
# insert a new dirblock
=== modified file 'bzrlib/tests/workingtree_implementations/test_add.py'
--- a/bzrlib/tests/workingtree_implementations/test_add.py 2007-03-05 04:15:38 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_add.py 2007-03-08 23:55:12 +0000
@@ -158,3 +158,22 @@
# the root should have been changed to be a new unique root.
self.assertNotEqual(inventory.ROOT_ID, tree.path2id(''))
tree.unlock()
+
+ def test_add_previously_added(self):
+ # adding a path that was previously added should work
+ tree = self.make_branch_and_tree('.')
+ self.build_tree(['foo'])
+ tree.add(['foo'], ['foo-id'])
+ tree.unversion(['foo-id'])
+ tree.add(['foo'], ['foo-id'])
+ self.assertEqual('foo-id', tree.path2id('foo'))
+
+ def test_add_present_in_basis(self):
+ # adding a path that was present in the basis should work.
+ tree = self.make_branch_and_tree('.')
+ self.build_tree(['foo'])
+ tree.add(['foo'], ['foo-id'])
+ tree.commit('add foo')
+ tree.unversion(['foo-id'])
+ tree.add(['foo'], ['foo-id'])
+ self.assertEqual('foo-id', tree.path2id('foo'))
More information about the bazaar-commits
mailing list