Rev 2470: Fix bug #11127 by splitting paths on '/'. in http://bzr.arbash-meinel.com/branches/bzr/0.16-dev/mixed_names_111127

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


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

------------------------------------------------------------
revno: 2470
revision-id: 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.
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
-------------- 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-30 16:25:58 +0000
+++ b/bzrlib/tests/intertree_implementations/test_compare.py	2007-04-30 17:05:41 +0000
@@ -877,17 +877,21 @@
         # 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/d/',
+                         'tree1/a-c/e/',
                          'tree2/a/',
                          'tree2/a/b/',
+                         'tree2/a/b/c/',
+                         'tree2/a/b/c/d/',
                          'tree2/a-c/',
-                         'tree2/a-c/d/',
+                         'tree2/a-c/e/',
                         ])
-        tree1.add(['a', 'a/b', 'a-c', 'a-c/d'],
-                  ['a-id', 'b-id', 'a-c-id', 'd-id'])
-        tree2.add(['a', 'a/b', 'a-c', 'a-c/d'],
-                  ['a-id', 'b-id', 'a-c-id', 'd-id'])
+        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)
 
@@ -897,8 +901,10 @@
             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, 'd-id'),
+            self.unchanged(tree2, 'e-id'),
             ])
         self.assertEqual(expected,
                          self.do_iter_changes(tree1, 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