Rev 5880: Clean up the _update_basis_apply_changes code 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 13:37:27 UTC 2011
At http://bazaar.launchpad.net/~jameinel/bzr/2.4-set-parent-trees-delta-282941
------------------------------------------------------------
revno: 5880
revision-id: john at arbash-meinel.com-20110519133713-i8k4tsaauepjaxmf
parent: john at arbash-meinel.com-20110519132206-iy5aqsz54j7dhp2i
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.4-set-parent-trees-delta-282941
timestamp: Thu 2011-05-19 15:37:13 +0200
message:
Clean up the _update_basis_apply_changes code
ensure that the code path is getting hit.
-------------- next part --------------
=== modified file 'bzrlib/dirstate.py'
--- a/bzrlib/dirstate.py 2011-05-19 13:05:10 +0000
+++ b/bzrlib/dirstate.py 2011-05-19 13:37:13 +0000
@@ -1545,15 +1545,11 @@
new_ids.add(file_id)
elif new_path is None:
deletes.append((old_path_utf8, None, file_id, None, True))
- elif (old_path, new_path) == root_only:
- # changes to just the root should not require remove/insertion
- # of everything.
+ elif old_path == new_path:
+ # change things in-place
changes.append((old_path_utf8, new_path_utf8, file_id,
inv_to_entry(inv_entry)))
else:
- # TODO: if old_path == new_path, I think we can get away with
- # treating this entry as a simple 'changes' entry, rather
- # than a delete + add. JAM 2011-05-18
# Renames:
# Because renames must preserve their children we must have
# processed all relocations and removes before hand. The sort
@@ -1773,14 +1769,10 @@
absent = 'ar'
for old_path, new_path, file_id, new_details in changes:
# the entry for this file_id must be in tree 0.
- entry = self._get_entry(0, file_id, new_path)
- if entry[0] is None or entry[0][2] != file_id:
- self._raise_invalid(new_path, file_id,
- 'working tree does not contain new entry')
- if (entry[1][0][0] in absent or
- entry[1][1][0] in absent):
- self._raise_invalid(new_path, file_id,
- 'changed considered absent')
+ entry = self._get_entry(1, file_id, new_path)
+ if entry[0] is None or entry[1][1][0] in 'ar':
+ self._raise_invalid(new_path, file_id,
+ 'changed entry considered not present')
entry[1][1] = new_details
def _update_basis_apply_deletes(self, deletes, rename_targets):
=== modified file 'bzrlib/tests/test_dirstate.py'
--- a/bzrlib/tests/test_dirstate.py 2011-05-19 13:22:06 +0000
+++ b/bzrlib/tests/test_dirstate.py 2011-05-19 13:37:13 +0000
@@ -2750,12 +2750,12 @@
# path_to_ie handles entries with missing parents
state = self.assertBadDelta(
active=[('path/', 'path-id')],
- basis =[],
+ basis= [],
delta=[(None, 'path/path2', 'file-id')])
state = self.assertBadDelta(
active=[('path/', 'path-id'),
('path/path2', 'file-id')],
- basis =[],
+ basis= [],
delta=[(None, 'path/path2', 'file-id')])
def test_change_root_id(self):
@@ -2780,3 +2780,19 @@
('file', 'file-id')],
target=[('', 'target-root-id'),
('file', 'root-id')])
+
+ def test_change_file_absent_in_active(self):
+ state = self.assertUpdate(
+ active=[],
+ basis= [('file', 'file-id')],
+ target=[('file', 'file-id')])
+
+ def test_invalid_changed_file(self):
+ state = self.assertBadDelta( # Not present in basis
+ active=[('file', 'file-id')],
+ basis= [],
+ delta=[('file', 'file', 'file-id')])
+ state = self.assertBadDelta( # present at another location in basis
+ active=[('file', 'file-id')],
+ basis= [('other-file', 'file-id')],
+ delta=[('file', 'file', 'file-id')])
More information about the bazaar-commits
mailing list