Merge lp:~lifeless/bzr/bug-367632 into lp:~bzr/bzr/trunk-old

Proposed by Robert Collins
Status: Merged
Merged at revision: not available
Proposed branch: lp:~lifeless/bzr/bug-367632
Merge into: lp:~bzr/bzr/trunk-old
Diff against target: 127 lines (has conflicts)
Text conflict in NEWS
To merge this branch: bzr merge lp:~lifeless/bzr/bug-367632
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+8928@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

Add interface enforcement for the behaviour of iter_changes with missing
subtrees with explicit paths - the whole subtree is returned.

This fixes the behaviour of 'revert .' when a directory and its contents
have been removed.

-Rob

--

Revision history for this message
Martin Pool (mbp) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2009-07-20 21:21:10 +0000
+++ NEWS 2009-07-21 03:35:33 +0000
@@ -38,10 +38,16 @@
38* ``bzr mv`` no longer takes out branch locks, which allows it to work38* ``bzr mv`` no longer takes out branch locks, which allows it to work
39 when the branch is readonly. (Robert Collins, #216541)39 when the branch is readonly. (Robert Collins, #216541)
4040
41<<<<<<< TREE
41* Fixed a NameError that occurs when merging or pulling from a URL that42* Fixed a NameError that occurs when merging or pulling from a URL that
42 causes a redirection loop when bzr tries to read a URL as a bundle.43 causes a redirection loop when bzr tries to read a URL as a bundle.
43 (Andrew Bennetts, #400847)44 (Andrew Bennetts, #400847)
44 45
46=======
47* ``bzr revert .`` no longer generates an InconsistentDelta error when
48 there are missing subtrees. (Robert Collins, #367632)
49
50>>>>>>> MERGE-SOURCE
45* Fixed spurious "Source branch does not support stacking" warning when51* Fixed spurious "Source branch does not support stacking" warning when
46 pushing. (Andrew Bennetts, #388908)52 pushing. (Andrew Bennetts, #388908)
4753
4854
=== modified file 'bzrlib/tests/per_intertree/test_compare.py'
--- bzrlib/tests/per_intertree/test_compare.py 2009-07-14 10:12:30 +0000
+++ bzrlib/tests/per_intertree/test_compare.py 2009-07-21 03:35:33 +0000
@@ -757,6 +757,29 @@
757 (None, root_id), (None, 'file'), (None, None), (None, False))]757 (None, root_id), (None, 'file'), (None, None), (None, False))]
758 self.assertEqual(expected, self.do_iter_changes(tree1, tree2))758 self.assertEqual(expected, self.do_iter_changes(tree1, tree2))
759759
760 def test_only_in_target_missing_subtree_specific_bug_367632(self):
761 tree1 = self.make_branch_and_tree('tree1')
762 tree2 = self.make_to_branch_and_tree('tree2')
763 tree2.set_root_id(tree1.get_root_id())
764 self.build_tree(['tree2/a-dir/', 'tree2/a-dir/a-file'])
765 tree2.add(['a-dir', 'a-dir/a-file'], ['dir-id', 'file-id'])
766 os.unlink('tree2/a-dir/a-file')
767 os.rmdir('tree2/a-dir')
768 tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
769 self.not_applicable_if_missing_in('a-dir', tree2)
770 root_id = tree1.path2id('')
771 expected = [
772 ('dir-id', (None, 'a-dir'), False, (False, True),
773 (None, root_id), (None, 'a-dir'), (None, None), (None, False)),
774 ('file-id', (None, 'a-dir/a-file'), False, (False, True),
775 (None, 'dir-id'), (None, 'a-file'), (None, None), (None, False))
776 ]
777 # bug 367632 showed that specifying the root broke some code paths,
778 # so we check this contract with and without it.
779 self.assertEqual(expected, self.do_iter_changes(tree1, tree2))
780 self.assertEqual(expected,
781 self.do_iter_changes(tree1, tree2, specific_files=['']))
782
760 def test_unchanged_with_renames_and_modifications(self):783 def test_unchanged_with_renames_and_modifications(self):
761 """want_unchanged should generate a list of unchanged entries."""784 """want_unchanged should generate a list of unchanged entries."""
762 tree1 = self.make_branch_and_tree('1')785 tree1 = self.make_branch_and_tree('1')
@@ -765,7 +788,6 @@
765 tree2 = self.get_tree_no_parents_abc_content_5(tree2)788 tree2 = self.get_tree_no_parents_abc_content_5(tree2)
766 tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)789 tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
767 root_id = tree1.path2id('')790 root_id = tree1.path2id('')
768
769 self.assertEqual(sorted([self.unchanged(tree1, root_id),791 self.assertEqual(sorted([self.unchanged(tree1, root_id),
770 self.unchanged(tree1, 'b-id'),792 self.unchanged(tree1, 'b-id'),
771 ('a-id', ('a', 'd'), True, (True, True),793 ('a-id', ('a', 'd'), True, (True, True),
772794
=== modified file 'bzrlib/transform.py'
--- bzrlib/transform.py 2009-07-20 06:06:22 +0000
+++ bzrlib/transform.py 2009-07-21 03:35:33 +0000
@@ -1718,14 +1718,20 @@
1718 def __iter__(self):1718 def __iter__(self):
1719 return iter(self.all_file_ids())1719 return iter(self.all_file_ids())
17201720
1721 def has_id(self, file_id):1721 def _has_id(self, file_id, fallback_check):
1722 if file_id in self._transform._r_new_id:1722 if file_id in self._transform._r_new_id:
1723 return True1723 return True
1724 elif file_id in set([self._transform.tree_file_id(trans_id) for1724 elif file_id in set([self._transform.tree_file_id(trans_id) for
1725 trans_id in self._transform._removed_id]):1725 trans_id in self._transform._removed_id]):
1726 return False1726 return False
1727 else:1727 else:
1728 return self._transform._tree.has_id(file_id)1728 return fallback_check(file_id)
1729
1730 def has_id(self, file_id):
1731 return self._has_id(file_id, self._transform._tree.has_id)
1732
1733 def has_or_had_id(self, file_id):
1734 return self._has_id(file_id, self._transform._tree.has_or_had_id)
17291735
1730 def _path2trans_id(self, path):1736 def _path2trans_id(self, path):
1731 # We must not use None here, because that is a valid value to store.1737 # We must not use None here, because that is a valid value to store.
17321738
=== modified file 'bzrlib/tree.py'
--- bzrlib/tree.py 2009-07-10 08:33:11 +0000
+++ bzrlib/tree.py 2009-07-21 03:35:33 +0000
@@ -133,8 +133,6 @@
133 return self.has_id(file_id)133 return self.has_id(file_id)
134134
135 def has_or_had_id(self, file_id):135 def has_or_had_id(self, file_id):
136 if file_id == self.inventory.root.file_id:
137 return True
138 return self.inventory.has_id(file_id)136 return self.inventory.has_id(file_id)
139137
140 def is_ignored(self, filename):138 def is_ignored(self, filename):
@@ -825,7 +823,7 @@
825 new_pending = set()823 new_pending = set()
826 for file_id in pending:824 for file_id in pending:
827 for tree in trees:825 for tree in trees:
828 if not tree.has_id(file_id):826 if not tree.has_or_had_id(file_id):
829 continue827 continue
830 for child_id in tree.iter_children(file_id):828 for child_id in tree.iter_children(file_id):
831 if child_id not in interesting_ids:829 if child_id not in interesting_ids:
832830
=== modified file 'bzrlib/workingtree_4.py'
--- bzrlib/workingtree_4.py 2009-07-15 04:33:14 +0000
+++ bzrlib/workingtree_4.py 2009-07-21 03:35:33 +0000
@@ -435,6 +435,11 @@
435 return osutils.lexists(pathjoin(435 return osutils.lexists(pathjoin(
436 self.basedir, row[0].decode('utf8'), row[1].decode('utf8')))436 self.basedir, row[0].decode('utf8'), row[1].decode('utf8')))
437437
438 def has_or_had_id(self, file_id):
439 state = self.current_dirstate()
440 row, parents = self._get_entry(file_id=file_id)
441 return row is not None
442
438 @needs_read_lock443 @needs_read_lock
439 def id2path(self, file_id):444 def id2path(self, file_id):
440 "Convert a file-id to a path."445 "Convert a file-id to a path."