Rev 4360: (Jelmer) Handle empty keys when finding common prefixes in CHKMap. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu May 14 00:24:20 BST 2009


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

------------------------------------------------------------
revno: 4360
revision-id: pqm at pqm.ubuntu.com-20090513232416-vt21661225sx5v8m
parent: pqm at pqm.ubuntu.com-20090513214008-38hihmlcby54hc99
parent: jelmer at samba.org-20090513215957-9se99cq16q0h460t
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2009-05-14 00:24:16 +0100
message:
  (Jelmer) Handle empty keys when finding common prefixes in CHKMap.
modified:
  bzrlib/chk_map.py              chk_map.py-20081001014447-ue6kkuhofvdecvxa-1
  bzrlib/tests/test_chk_map.py   test_chk_map.py-20081001014447-ue6kkuhofvdecvxa-2
    ------------------------------------------------------------
    revno: 4358.1.1
    revision-id: jelmer at samba.org-20090513215957-9se99cq16q0h460t
    parent: pqm at pqm.ubuntu.com-20090513171628-zmtijps3xl06nr9j
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: bzr.dev
    timestamp: Wed 2009-05-13 23:59:57 +0200
    message:
      Support empty keys when looking for common prefixes in CHKMap.
    modified:
      bzrlib/chk_map.py              chk_map.py-20081001014447-ue6kkuhofvdecvxa-1
      bzrlib/tests/test_chk_map.py   test_chk_map.py-20081001014447-ue6kkuhofvdecvxa-2
=== modified file 'bzrlib/chk_map.py'
--- a/bzrlib/chk_map.py	2009-04-09 20:23:07 +0000
+++ b/bzrlib/chk_map.py	2009-05-13 21:59:57 +0000
@@ -559,6 +559,7 @@
         """
         if key.startswith(prefix):
             return prefix
+        pos = -1
         # Is there a better way to do this?
         for pos, (left, right) in enumerate(zip(prefix, key)):
             if left != right:

=== modified file 'bzrlib/tests/test_chk_map.py'
--- a/bzrlib/tests/test_chk_map.py	2009-04-09 20:23:07 +0000
+++ b/bzrlib/tests/test_chk_map.py	2009-05-13 21:59:57 +0000
@@ -53,6 +53,11 @@
     def test_not_a_prefix(self):
         self.assertCommonPrefix('b', 'begin', 'b')
 
+    def test_empty(self):
+        self.assertCommonPrefix('', '', 'end')
+        self.assertCommonPrefix('', 'begin', '')
+        self.assertCommonPrefix('', '', '')
+
 
 class TestCaseWithStore(tests.TestCaseWithTransport):
 




More information about the bazaar-commits mailing list