Rev 2412: Test for iterating changes past empty directories. in sftp://bazaar.launchpad.net/%7Ebzr/bzr/dirstate/

Robert Collins robertc at robertcollins.net
Mon Feb 26 05:15:10 GMT 2007


At sftp://bazaar.launchpad.net/%7Ebzr/bzr/dirstate/

------------------------------------------------------------
revno: 2412
revision-id: robertc at robertcollins.net-20070226051405-y0p0nx2g03idj2m2
parent: robertc at robertcollins.net-20070226045423-h5irpxqoukh50bjd
committer: Robert Collins <robertc at robertcollins.net>
branch nick: dirstate
timestamp: Mon 2007-02-26 16:14:05 +1100
message:
  Test for iterating changes past empty directories.
modified:
  bzrlib/tests/intertree_implementations/test_compare.py test_compare.py-20060724101752-09ysswo1a92uqyoz-2
  bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
=== modified file 'bzrlib/tests/intertree_implementations/test_compare.py'
--- a/bzrlib/tests/intertree_implementations/test_compare.py	2007-02-26 04:27:55 +0000
+++ b/bzrlib/tests/intertree_implementations/test_compare.py	2007-02-26 05:14:05 +0000
@@ -475,6 +475,20 @@
                           (False, True))],
                          self.do_iter_changes(tree1, tree2))
 
+    def test_empty_dir(self):
+        """an empty dir should not cause glitches to surrounding files."""
+        tree1 = self.make_branch_and_tree('1')
+        tree2 = self.make_to_branch_and_tree('2')
+        tree1 = self.get_tree_no_parents_abc_content(tree1)
+        tree2 = self.get_tree_no_parents_abc_content(tree2)
+        # the pathname is chosen to fall between 'a' and 'b'.
+        self.build_tree(['1/a-empty/', '2/a-empty/'])
+        tree1.add(['a-empty'], ['a-empty'])
+        tree2.add(['a-empty'], ['a-empty'])
+        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
+        expected = []
+        self.assertEqual(expected, self.do_iter_changes(tree1, tree2))
+
     def test_file_rename(self):
         tree1 = self.make_branch_and_tree('1')
         tree2 = self.make_to_branch_and_tree('2')
@@ -529,7 +543,6 @@
             ])
         self.assertEqual(expected, self.do_iter_changes(tree1, tree2))
 
-
     def test_unchanged_with_renames_and_modifications(self):
         """want_unchanged should generate a list of unchanged entries."""
         tree1 = self.make_branch_and_tree('1')

=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py	2007-02-26 04:27:55 +0000
+++ b/bzrlib/workingtree_4.py	2007-02-26 05:14:05 +0000
@@ -1736,9 +1736,24 @@
                         import pdb;pdb.set_trace()
                         print 'unversioned dir'
                     else:
-                        # entry referring to missing dir.
-                        import pdb;pdb.set_trace()
-                        print 'missing dir'
+                        # directory data refers to paths not covered by the dirblock.
+                        # 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.
+                        try:
+                            current_dir_info = dir_iterator.next()
+                            # convert the unicode relpaths in the dir index to uf8 for
+                            # comparison with dirstate data.
+                            # TODO: keep the utf8 version around for giving to the caller.
+                            current_dir_info = ((current_dir_info[0][0].encode('utf8'), current_dir_info[0][1]),
+                                [(line[0].encode('utf8'), line[1].encode('utf8')) + line[2:] for line in current_dir_info[1]])
+                        except StopIteration:
+                            current_dir_info = None
                 entry_index = 0
                 if current_block and entry_index < len(current_block[1]):
                     current_entry = current_block[1][entry_index]



More information about the bazaar-commits mailing list