Rev 3823: Fix the wrong fix. in file:///net/bigmamac/Volumes/home/vila/src/bzr/experimental/brisbane-core/

Vincent Ladeuil v.ladeuil+lp at free.fr
Wed Feb 18 18:25:33 GMT 2009


At file:///net/bigmamac/Volumes/home/vila/src/bzr/experimental/brisbane-core/

------------------------------------------------------------
revno: 3823
revision-id: v.ladeuil+lp at free.fr-20090218182531-7zvja7tufed8a1pi
parent: v.ladeuil+lp at free.fr-20090218165051-75ql383s2rhyv24j
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: brisbane-core
timestamp: Wed 2009-02-18 19:25:31 +0100
message:
  Fix the wrong fix.
  
  * tests/test_chk_map.py:
  (TestNode.assertCommonPrefix): Also check the expected result.
  
  * chk_map.py:
  (Node.common_prefix): Oops, off-by-one error in the previous fix.
-------------- next part --------------
=== modified file 'bzrlib/chk_map.py'
--- a/bzrlib/chk_map.py	2009-02-18 16:50:51 +0000
+++ b/bzrlib/chk_map.py	2009-02-18 18:25:31 +0000
@@ -509,8 +509,9 @@
         # Is there a better way to do this?
         for pos, (left, right) in enumerate(zip(prefix, key)):
             if left != right:
+                pos -= 1
                 break
-        common = prefix[:pos]
+        common = prefix[:pos+1]
         return common
 
     @classmethod

=== modified file 'bzrlib/tests/test_chk_map.py'
--- a/bzrlib/tests/test_chk_map.py	2009-02-18 16:50:51 +0000
+++ b/bzrlib/tests/test_chk_map.py	2009-02-18 18:25:31 +0000
@@ -33,26 +33,26 @@
 
 class TestNode(tests.TestCase):
 
-    def assertCommonPrefix(self, prefix, key):
+    def assertCommonPrefix(self, expected_common, prefix, key):
         common = Node.common_prefix(prefix, key)
         self.assertTrue(len(common) <= len(prefix))
         self.assertTrue(len(common) <= len(key))
         self.assertStartsWith(prefix, common)
         self.assertStartsWith(key, common)
+        self.assertEquals(expected_common, common)
 
     def test_common_prefix(self):
-        self.assertCommonPrefix('beg', 'begin')
+        self.assertCommonPrefix('beg', 'beg', 'begin')
 
     def test_no_common_prefix(self):
-        self.assertCommonPrefix('begin', 'end')
+        import pdb; pdb.set_trace()
+        self.assertCommonPrefix('', 'begin', 'end')
 
     def test_equal(self):
-        self.assertCommonPrefix('begin', 'begin')
+        self.assertCommonPrefix('begin', 'begin', 'begin')
 
     def test_not_a_prefix(self):
-        self.assertCommonPrefix('begin', 'b')
-
-
+        self.assertCommonPrefix('b', 'begin', 'b')
 class TestCaseWithStore(tests.TestCaseWithTransport):
 
     def get_chk_bytes(self):



More information about the bazaar-commits mailing list