Rev 2473: [merge] fix for bug #111127 in http://bzr.arbash-meinel.com/branches/bzr/0.16-dev/dirstate_fixes

John Arbash Meinel john at arbash-meinel.com
Mon Apr 30 18:41:19 BST 2007


At http://bzr.arbash-meinel.com/branches/bzr/0.16-dev/dirstate_fixes

------------------------------------------------------------
revno: 2473
revision-id: john at arbash-meinel.com-20070430174107-jec5pf7b63kc2uj9
parent: pqm at pqm.ubuntu.com-20070430083158-pitv7lbgdu0q8g6h
parent: john at arbash-meinel.com-20070430170541-pdh0k81zpedgjl70
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate_fixes
timestamp: Mon 2007-04-30 12:41:07 -0500
message:
  [merge] fix for bug #111127
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: 2466.5.4
    merged: john at arbash-meinel.com-20070430170541-pdh0k81zpedgjl70
    parent: john at arbash-meinel.com-20070430162558-f040stduyrfflef9
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: mixed_names_111127
    timestamp: Mon 2007-04-30 12:05:41 -0500
    message:
      Fix bug #11127 by splitting paths on '/'.
      This adds a bit of overhead when paths don't match.
      So conceptually we might want to cache the split value,
      or return it from the underlying iterator.
      However, we only need it when the current iterators don't match
      so most of the time a simple 'x == y' is sufficient, since
      equality is correct with or without the split().
      So the computational overhead should be fine.
    ------------------------------------------------------------
    revno: 2466.5.3
    merged: john at arbash-meinel.com-20070430162558-f040stduyrfflef9
    parent: john at arbash-meinel.com-20070430162242-3gds64wynnny2t57
    parent: pqm at pqm.ubuntu.com-20070430083158-pitv7lbgdu0q8g6h
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: mixed_names_111127
    timestamp: Mon 2007-04-30 11:25:58 -0500
    message:
      [merge] bzr.dev 2472
    ------------------------------------------------------------
    revno: 2466.5.2
    merged: john at arbash-meinel.com-20070430162242-3gds64wynnny2t57
    parent: john at arbash-meinel.com-20070430160855-z8zh7eb7r629ch6g
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: mixed_names_111127
    timestamp: Mon 2007-04-30 11:22:42 -0500
    message:
      Extend the test a bit to make sure the include_unchanged value is correct.
      still (broken)
    ------------------------------------------------------------
    revno: 2466.5.1
    merged: john at arbash-meinel.com-20070430160855-z8zh7eb7r629ch6g
    parent: pqm at pqm.ubuntu.com-20070426211103-h84prqh7a4ad3ez2
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: mixed_names_111127
    timestamp: Mon 2007-04-30 11:08:55 -0500
    message:
      Add a (failing) test for bug 111127
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2007-04-30 07:48:55 +0000
+++ b/NEWS	2007-04-30 17:05:41 +0000
@@ -1,5 +1,13 @@
 IN DEVELOPMENT
 
+  BUGFIXES:
+
+    * Handle when you have 2 directories with similar names, but one has a
+      hyphen. (``'abc'`` versus ``'abc-2'``). The WT4._iter_changes
+      iterator was using direct comparison and ``'abc/a'`` sorts after
+      ``'abc-2'``, but ``('abc', 'a')`` sorts before ``('abc-2',)``.
+      (John Arbash Meinel, #111227)
+
 bzr 0.16rc2  2007-04-30
 
   BUGFIXES:

=== modified file 'bzrlib/tests/intertree_implementations/test_compare.py'
--- a/bzrlib/tests/intertree_implementations/test_compare.py	2007-04-26 20:45:53 +0000
+++ b/bzrlib/tests/intertree_implementations/test_compare.py	2007-04-30 17:05:41 +0000
@@ -867,6 +867,51 @@
             specific_files=specific_files, require_versioned=False,
             want_unversioned=True))
 
+    def test_similar_filenames(self):
+        """Test when we have a few files with similar names."""
+        tree1 = self.make_branch_and_tree('tree1')
+        tree2 = self.make_branch_and_tree('tree2')
+        tree2.set_root_id(tree1.get_root_id())
+
+        # The trees are actually identical, but they happen to contain
+        # similarly named files.
+        self.build_tree(['tree1/a/',
+                         'tree1/a/b/',
+                         'tree1/a/b/c/',
+                         'tree1/a/b/c/d/',
+                         'tree1/a-c/',
+                         'tree1/a-c/e/',
+                         'tree2/a/',
+                         'tree2/a/b/',
+                         'tree2/a/b/c/',
+                         'tree2/a/b/c/d/',
+                         'tree2/a-c/',
+                         'tree2/a-c/e/',
+                        ])
+        tree1.add(['a', 'a/b', 'a/b/c', 'a/b/c/d', 'a-c', 'a-c/e'],
+                  ['a-id', 'b-id', 'c-id', 'd-id', 'a-c-id', 'e-id'])
+        tree2.add(['a', 'a/b', 'a/b/c', 'a/b/c/d', 'a-c', 'a-c/e'],
+                  ['a-id', 'b-id', 'c-id', 'd-id', 'a-c-id', 'e-id'])
+
+        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
+
+        self.assertEqual([], self.do_iter_changes(tree1, tree2,
+                                                  want_unversioned=True))
+        expected = sorted([
+            self.unchanged(tree2, tree2.get_root_id()),
+            self.unchanged(tree2, 'a-id'),
+            self.unchanged(tree2, 'b-id'),
+            self.unchanged(tree2, 'c-id'),
+            self.unchanged(tree2, 'd-id'),
+            self.unchanged(tree2, 'a-c-id'),
+            self.unchanged(tree2, 'e-id'),
+            ])
+        self.assertEqual(expected,
+                         self.do_iter_changes(tree1, tree2,
+                                              want_unversioned=True,
+                                              include_unchanged=True))
+
+
     def test_unversioned_subtree_only_emits_root(self):
         tree1 = self.make_branch_and_tree('tree1')
         tree2 = self.make_to_branch_and_tree('tree2')

=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py	2007-04-30 05:13:58 +0000
+++ b/bzrlib/workingtree_4.py	2007-04-30 17:05:41 +0000
@@ -2122,7 +2122,7 @@
                    current_block is not None):
                 if (current_dir_info and current_block
                     and current_dir_info[0][0] != current_block[0]):
-                    if current_dir_info[0][0] < current_block[0] :
+                    if current_dir_info[0][0].split('/') < current_block[0].split('/'):
                         # filesystem 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
@@ -2257,7 +2257,7 @@
                                        result[7],
                                       )
                     elif current_entry[0][1] != current_path_info[1]:
-                        if current_path_info[1] < current_entry[0][1]:
+                        if current_path_info[1].split('/') < current_entry[0][1].split('/'):
                             # extra file on disk: pass for now, but only
                             # increment the path, not the entry
                             advance_entry = False



More information about the bazaar-commits mailing list