Rev 2438: (John Arbash Meinel) Fix bug #104257 to handle unknown files in previously empty versioned directories in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Apr 20 16:40:37 BST 2007


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

------------------------------------------------------------
revno: 2438
revision-id: pqm at pqm.ubuntu.com-20070420154033-kkrk7tn575z1o491
parent: pqm at pqm.ubuntu.com-20070420121956-hbxbonnuyt92yy4u
parent: john at arbash-meinel.com-20070420150522-lpbhxv739kynwyep
committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2007-04-20 16:40:33 +0100
message:
  (John Arbash Meinel) Fix bug #104257 to handle unknown files in previously empty versioned directories
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/tests/intertree_implementations/test_compare.py test_compare.py-20060724101752-09ysswo1a92uqyoz-2
  bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
    ------------------------------------------------------------
    revno: 2402.2.5
    merged: john at arbash-meinel.com-20070420150522-lpbhxv739kynwyep
    parent: john at arbash-meinel.com-20070413144709-6f529ghpukn2fhlq
    parent: pqm at pqm.ubuntu.com-20070419095256-nq0n6puj11zm7n7r
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: iter_changes_unknowns_104257
    timestamp: Fri 2007-04-20 10:05:22 -0500
    message:
      [merge] bzr.dev 2428
    ------------------------------------------------------------
    revno: 2402.2.4
    merged: john at arbash-meinel.com-20070413144709-6f529ghpukn2fhlq
    parent: john at arbash-meinel.com-20070411175522-5t9shbp3dbkjawsy
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: iter_changes_unknowns_104257
    timestamp: Fri 2007-04-13 09:47:09 -0500
    message:
      Clean up the setup for clarity (suggested by Robert)
    ------------------------------------------------------------
    revno: 2402.2.3
    merged: john at arbash-meinel.com-20070411175522-5t9shbp3dbkjawsy
    parent: john at arbash-meinel.com-20070411175022-gdznyinz160vx05e
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: iter_changes_unknowns_104257
    timestamp: Wed 2007-04-11 12:55:22 -0500
    message:
      NEWS for fixing bug #104257
    ------------------------------------------------------------
    revno: 2402.2.2
    merged: john at arbash-meinel.com-20070411175022-gdznyinz160vx05e
    parent: john at arbash-meinel.com-20070411170244-qael9owa2l2rcneh
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: iter_changes_unknowns_104257
    timestamp: Wed 2007-04-11 12:50:22 -0500
    message:
      Fix _iter_changes to properly handle versioned (but empty) directories
      so that it yields files from there as unknown.
      Also check to make sure we don't recurse into subdirectories of these dirs.
    ------------------------------------------------------------
    revno: 2402.2.1
    merged: john at arbash-meinel.com-20070411170244-qael9owa2l2rcneh
    parent: pqm at pqm.ubuntu.com-20070410074302-cf6b95587a1058cd
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: iter_changes_unknowns_104257
    timestamp: Wed 2007-04-11 12:02:44 -0500
    message:
      Add a test which exposes the bug in WT4._iter_changes()
=== modified file 'NEWS'
--- a/NEWS	2007-04-20 11:48:24 +0000
+++ b/NEWS	2007-04-20 15:40:33 +0000
@@ -99,6 +99,10 @@
     * Don't produce encoding error when adding duplicate files.
       (Aaron Bentley)
 
+    * Fix ``InterDirstateTre._iter_changes`` to handle when we come across
+      an empty versioned directory, which now has files in it.
+      (John Arbash Meinel, #104257)
+
     * Teach ``common_ancestor`` to shortcut when the tip of one branch is
       inside the ancestry of the other. Saves a lot of graph processing
       (with an ancestry of 16k revisions, ``bzr merge ../already-merged``

=== modified file 'bzrlib/tests/intertree_implementations/test_compare.py'
--- a/bzrlib/tests/intertree_implementations/test_compare.py	2007-04-13 07:03:32 +0000
+++ b/bzrlib/tests/intertree_implementations/test_compare.py	2007-04-20 15:05:22 +0000
@@ -1216,3 +1216,33 @@
         self.assertEqual([], # Without want_unversioned we should get nothing
                          self.do_iter_changes(tree1, tree2,
                                               specific_files=[u'\u03b1']))
+
+    def test_unknown_empty_dir(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)
+
+        # Start with 2 identical trees
+        self.build_tree(['tree1/a/', 'tree1/b/',
+                         'tree2/a/', 'tree2/b/'])
+        self.build_tree_contents([('tree1/b/file', 'contents\n'),
+                                  ('tree2/b/file', 'contents\n')])
+        tree1.add(['a', 'b', 'b/file'], ['a-id', 'b-id', 'b-file-id'])
+        tree2.add(['a', 'b', 'b/file'], ['a-id', 'b-id', 'b-file-id'])
+
+        # Now create some unknowns in tree2
+        # We should find both a/file and a/dir as unknown, but we shouldn't
+        # recurse into a/dir to find that a/dir/subfile is also unknown.
+        self.build_tree(['tree2/a/file', 'tree2/a/dir/', 'tree2/a/dir/subfile'])
+
+        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
+
+        expected = sorted([
+            self.unversioned(tree2, u'a/file'),
+            self.unversioned(tree2, u'a/dir'),
+            ])
+        self.assertEqual(expected,
+                         self.do_iter_changes(tree1, tree2,
+                                              require_versioned=False,
+                                              want_unversioned=True))

=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py	2007-04-20 04:19:55 +0000
+++ b/bzrlib/workingtree_4.py	2007-04-20 15:40:33 +0000
@@ -2121,11 +2121,40 @@
                         # this has two possibilities:
                         # A) it is versioned but empty, so there is no block for it
                         # B) it is not versioned.
-                        # in either case it was processed by the containing directories walk:
-                        # if it is root/foo, when we walked root we emitted it,
-                        # or if we ere given root/foo to walk specifically, we
-                        # emitted it when checking the walk-root entries
-                        # advance the iterator and loop - we dont need to emit it.
+
+                        # if (A) then we need to recurse into it to check for
+                        # new unknown files or directories.
+                        # if (B) then we should ignore it, because we don't
+                        # recurse into unknown directories.
+                        if want_unversioned:
+                            path_index = 0
+                            while path_index < len(current_dir_info[1]):
+                                    current_path_info = current_dir_info[1][path_index]
+                                    if current_path_info[2] == 'directory':
+                                        if self.target._directory_is_tree_reference(
+                                            current_path_info[0].decode('utf8')):
+                                            current_path_info = current_path_info[:2] + \
+                                                ('tree-reference',) + current_path_info[3:]
+                                    new_executable = bool(
+                                        stat.S_ISREG(current_path_info[3].st_mode)
+                                        and stat.S_IEXEC & current_path_info[3].st_mode)
+                                    yield (None,
+                                        (None, utf8_decode_or_none(current_path_info[0])),
+                                        True,
+                                        (False, False),
+                                        (None, None),
+                                        (None, utf8_decode_or_none(current_path_info[1])),
+                                        (None, current_path_info[2]),
+                                        (None, new_executable))
+                                    # dont descend into this unversioned path if it is
+                                    # a dir
+                                    if current_path_info[2] in ('directory',
+                                                                'tree-reference'):
+                                        del current_dir_info[1][path_index]
+                                        path_index -= 1
+                                    path_index += 1
+
+                        # This dir info has been handled, go to the next
                         try:
                             current_dir_info = dir_iterator.next()
                         except StopIteration:
@@ -2294,15 +2323,14 @@
                                 new_executable = bool(
                                     stat.S_ISREG(current_path_info[3].st_mode)
                                     and stat.S_IEXEC & current_path_info[3].st_mode)
-                                if want_unversioned:
-                                    yield (None,
-                                        (None, utf8_decode_or_none(current_path_info[0])),
-                                        True,
-                                        (False, False),
-                                        (None, None),
-                                        (None, utf8_decode_or_none(current_path_info[1])),
-                                        (None, current_path_info[2]),
-                                        (None, new_executable))
+                                yield (None,
+                                    (None, utf8_decode_or_none(current_path_info[0])),
+                                    True,
+                                    (False, False),
+                                    (None, None),
+                                    (None, utf8_decode_or_none(current_path_info[1])),
+                                    (None, current_path_info[2]),
+                                    (None, new_executable))
                             # dont descend into this unversioned path if it is
                             # a dir
                             if current_path_info[2] in ('directory'):




More information about the bazaar-commits mailing list