Rev 2464: (John Arbash Meinel) Fix bug #109993 by fixing _iter_changes to not sync an on-disk file with an 'absent' dirblock record. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Apr 26 16:39:06 BST 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 2464
revision-id: pqm at pqm.ubuntu.com-20070426153904-l91p9ybsqpxt2vyv
parent: pqm at pqm.ubuntu.com-20070426104148-4l5wq2zemlzv0shg
parent: john at arbash-meinel.com-20070426144401-zdbrjiuao7xqrp0r
committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2007-04-26 16:39:04 +0100
message:
  (John Arbash Meinel) Fix bug #109993 by fixing _iter_changes to not sync an on-disk file with an 'absent' dirblock record.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/tests/intertree_implementations/test_compare.py test_compare.py-20060724101752-09ysswo1a92uqyoz-2
  bzrlib/tests/workingtree_implementations/test_move.py test_move.py-20070225171927-mohn2vqj5fx7edc6-1
  bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
    ------------------------------------------------------------
    revno: 2456.2.6
    merged: john at arbash-meinel.com-20070426144401-zdbrjiuao7xqrp0r
    parent: john at arbash-meinel.com-20070425224555-msapt0k72c4h8wju
    parent: pqm at pqm.ubuntu.com-20070426104148-4l5wq2zemlzv0shg
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: rename_iter_changes_109993
    timestamp: Thu 2007-04-26 09:44:01 -0500
    message:
      [merge] bzr.dev 2463
    ------------------------------------------------------------
    revno: 2456.2.5
    merged: john at arbash-meinel.com-20070425224555-msapt0k72c4h8wju
    parent: john at arbash-meinel.com-20070425221045-z3oqq15r3g5p9goj
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: rename_iter_changes_109993
    timestamp: Wed 2007-04-25 17:45:55 -0500
    message:
      Make sure the output with want_unversioned=False is reasonable.
    ------------------------------------------------------------
    revno: 2456.2.4
    merged: john at arbash-meinel.com-20070425221045-z3oqq15r3g5p9goj
    parent: john at arbash-meinel.com-20070425220709-smtrld4n70yy3u51
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: rename_iter_changes_109993
    timestamp: Wed 2007-04-25 17:10:45 -0500
    message:
      NEWS entry for fixing bug 109993
    ------------------------------------------------------------
    revno: 2456.2.3
    merged: john at arbash-meinel.com-20070425220709-smtrld4n70yy3u51
    parent: john at arbash-meinel.com-20070425215414-3zso9m2xndcd4rwp
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: rename_iter_changes_109993
    timestamp: Wed 2007-04-25 17:07:09 -0500
    message:
      Tests now pass
    ------------------------------------------------------------
    revno: 2456.2.2
    merged: john at arbash-meinel.com-20070425215414-3zso9m2xndcd4rwp
    parent: john at arbash-meinel.com-20070425184156-weys7l94o2nn6d4l
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: rename_iter_changes_109993
    timestamp: Wed 2007-04-25 16:54:14 -0500
    message:
      Add another (failing) test case.
      If we unversion a file, but it is still on disk
      we should get 2 records from _iter_changes
      one to indicate the removal
      the other to indicate the unknown file on disk
    ------------------------------------------------------------
    revno: 2456.2.1
    merged: john at arbash-meinel.com-20070425184156-weys7l94o2nn6d4l
    parent: pqm at pqm.ubuntu.com-20070425143732-c4aa489eylhhfnzg
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: rename_iter_changes_109993
    timestamp: Wed 2007-04-25 13:41:56 -0500
    message:
      (broken) Add a (failing) test that _iter_changes works correctly
      in the case that you delete a file, and rename another file overtop.
      (Dirstate currently has a chance to report the renamed file as deleted
      if the rename goes to a name which sorts first in the list.)
=== modified file 'NEWS'
--- a/NEWS	2007-04-26 09:07:38 +0000
+++ b/NEWS	2007-04-26 14:44:01 +0000
@@ -252,6 +252,11 @@
     * Handle moving a directory when children have been added, removed,
       and renamed. (John Arbash Meinel, #105479)
 
+    * Handle the case when you delete a file, and then rename another file
+      on top of it. Also handle the case of ``bzr rm --keep foo``. ``bzr
+      status`` should show the removed file and an unknown file in its
+      place. (John Arbash Meinel, #109993)
+
     * Don't preventively use basic authentication for proxy before receiving a
       407 error. Otherwise people willing to use other authentication schemes
       may expose their password in the clear (or nearly). This add one

=== modified file 'bzrlib/tests/intertree_implementations/test_compare.py'
--- a/bzrlib/tests/intertree_implementations/test_compare.py	2007-04-20 15:05:22 +0000
+++ b/bzrlib/tests/intertree_implementations/test_compare.py	2007-04-25 22:45:55 +0000
@@ -1246,3 +1246,75 @@
                          self.do_iter_changes(tree1, tree2,
                                               require_versioned=False,
                                               want_unversioned=True))
+
+    def test_rename_over_deleted(self):
+        tree1 = self.make_branch_and_tree('tree1')
+        tree2 = self.make_to_branch_and_tree('tree2')
+        root_id = tree1.get_root_id()
+        tree2.set_root_id(root_id)
+
+        # The final changes should be:
+        #   touch a b c d
+        #   add a b c d
+        #   commit
+        #   rm a d
+        #   mv b a
+        #   mv c d
+        self.build_tree_contents([
+            ('tree1/a', 'a contents\n'),
+            ('tree1/b', 'b contents\n'),
+            ('tree1/c', 'c contents\n'),
+            ('tree1/d', 'd contents\n'),
+            ('tree2/a', 'b contents\n'),
+            ('tree2/d', 'c contents\n'),
+            ])
+        tree1.add(['a', 'b', 'c', 'd'], ['a-id', 'b-id', 'c-id', 'd-id'])
+        tree2.add(['a', 'd'], ['b-id', 'c-id'])
+
+        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
+
+        expected = sorted([
+            self.deleted(tree1, 'a-id'),
+            self.deleted(tree1, 'd-id'),
+            self.renamed(tree1, tree2, 'b-id', False),
+            self.renamed(tree1, tree2, 'c-id', False),
+            ])
+        self.assertEqual(expected,
+                         self.do_iter_changes(tree1, tree2))
+
+    def test_deleted_and_unknown(self):
+        """Test a file marked removed, but still present on disk."""
+        tree1 = self.make_branch_and_tree('tree1')
+        tree2 = self.make_to_branch_and_tree('tree2')
+        root_id = tree1.get_root_id()
+        tree2.set_root_id(root_id)
+
+        # The final changes should be:
+        # bzr add a b c
+        # bzr rm --keep b
+        self.build_tree_contents([
+            ('tree1/a', 'a contents\n'),
+            ('tree1/b', 'b contents\n'),
+            ('tree1/c', 'c contents\n'),
+            ('tree2/a', 'a contents\n'),
+            ('tree2/b', 'b contents\n'),
+            ('tree2/c', 'c contents\n'),
+            ])
+        tree1.add(['a', 'b', 'c'], ['a-id', 'b-id', 'c-id'])
+        tree2.add(['a', 'c'], ['a-id', 'c-id'])
+
+        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
+
+        expected = sorted([
+            self.deleted(tree1, 'b-id'),
+            self.unversioned(tree2, 'b'),
+            ])
+        self.assertEqual(expected,
+                         self.do_iter_changes(tree1, tree2,
+                                              want_unversioned=True))
+        expected = sorted([
+            self.deleted(tree1, 'b-id'),
+            ])
+        self.assertEqual(expected,
+                         self.do_iter_changes(tree1, tree2,
+                                              want_unversioned=False))

=== modified file 'bzrlib/tests/workingtree_implementations/test_move.py'
--- a/bzrlib/tests/workingtree_implementations/test_move.py	2007-04-20 20:36:30 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_move.py	2007-04-25 18:41:56 +0000
@@ -167,6 +167,21 @@
                                ('d', 'd-id')], tree.basis_tree())
         tree._validate()
 
+    def test_move_over_deleted(self):
+        tree = self.make_branch_and_tree('.')
+        self.build_tree(['a/', 'a/b', 'b'])
+        tree.add(['a', 'a/b', 'b'], ['a-id', 'ab-id', 'b-id'])
+        tree.commit('initial', rev_id='rev-1')
+
+        root_id = tree.get_root_id()
+        tree.remove(['a/b'], keep_files=False)
+        self.assertEqual([('b', 'a/b')], tree.move(['b'], 'a'))
+        self.assertTreeLayout([('', root_id),
+                               ('a', 'a-id'),
+                               ('a/b', 'b-id'),
+                              ], tree)
+        tree._validate()
+
     def test_move_subdir(self):
         tree = self.make_branch_and_tree('.')
         self.build_tree(['a', 'b/', 'b/c'])

=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py	2007-04-20 20:39:53 +0000
+++ b/bzrlib/workingtree_4.py	2007-04-25 22:07:09 +0000
@@ -2294,7 +2294,11 @@
                             # this check should probably be outside the loop: one
                             # 'iterate two trees' api, and then _iter_changes filters
                             # unchanged pairs. - RBC 20070226
-                            path_handled = True
+                            if current_entry[1][target_index][0] == 'a':
+                                advance_path = False
+                                path_handled = False
+                            else:
+                                path_handled = True
                             if (include_unchanged
                                 or result[2]                    # content change
                                 or result[3][0] != result[3][1] # versioned status




More information about the bazaar-commits mailing list