Rev 2638: Merge absent record offset generation bugfix. in http://people.ubuntu.com/~robertc/baz2.0/repository

Robert Collins robertc at robertcollins.net
Fri Jul 13 21:02:26 BST 2007


At http://people.ubuntu.com/~robertc/baz2.0/repository

------------------------------------------------------------
revno: 2638
revision-id: robertc at robertcollins.net-20070713200224-0rowyzto11en8zfd
parent: robertc at robertcollins.net-20070713190002-izvtokos305lqjzn
parent: robertc at robertcollins.net-20070713200006-ollxheg4pu5m9wf1
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Sat 2007-07-14 06:02:24 +1000
message:
  Merge absent record offset generation bugfix.
modified:
  bzrlib/index.py                index.py-20070712131115-lolkarso50vjr64s-1
  bzrlib/tests/test_index.py     test_index.py-20070712131115-lolkarso50vjr64s-2
    ------------------------------------------------------------
    revno: 2626.1.2
    revision-id: robertc at robertcollins.net-20070713200006-ollxheg4pu5m9wf1
    parent: robertc at robertcollins.net-20070713163554-ok2qtnzv6rcbpt3z
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: index
    timestamp: Sat 2007-07-14 06:00:06 +1000
    message:
      Bugfix incorrect offset generation when an absent record is before a referenced record.
    modified:
      bzrlib/index.py                index.py-20070712131115-lolkarso50vjr64s-1
      bzrlib/tests/test_index.py     test_index.py-20070712131115-lolkarso50vjr64s-2
=== modified file 'bzrlib/index.py'
--- a/bzrlib/index.py	2007-07-13 16:35:54 +0000
+++ b/bzrlib/index.py	2007-07-13 20:00:06 +0000
@@ -113,7 +113,7 @@
                 # one byte for absent if set.
                 if absent:
                     non_ref_bytes += 1
-                if self.reference_lists:
+                elif self.reference_lists:
                     # (ref_lists -1) tabs
                     non_ref_bytes += self.reference_lists - 1
                     # (ref-1 cr's per ref_list)
@@ -138,8 +138,8 @@
                 current_offset += len(key) + len(value) + 3 + 1
                 # one byte for absent if set.
                 if absent:
-                    current_offset+= 1
-                if self.reference_lists:
+                    current_offset += 1
+                elif self.reference_lists:
                     # (ref_lists -1) tabs
                     current_offset += self.reference_lists - 1
                     # (ref-1 cr's per ref_list)

=== modified file 'bzrlib/tests/test_index.py'
--- a/bzrlib/tests/test_index.py	2007-07-13 16:35:54 +0000
+++ b/bzrlib/tests/test_index.py	2007-07-13 20:00:06 +0000
@@ -215,6 +215,19 @@
         builder.add_node('key', (['reference'], ), 'data')
         builder.add_node('reference', ([],), 'data')
 
+    def test_absent_has_no_reference_overhead(self):
+        # the offsets after an absent record should be correct when there are
+        # >1 reference lists.
+        builder = GraphIndexBuilder(reference_lists=2)
+        builder.add_node('parent', (['tail', 'other'], []), '')
+        stream = builder.finish()
+        contents = stream.read()
+        self.assertEqual("Bazaar Graph Index 1\nnode_ref_lists=2\n"
+            "tail\x00a\x00\x00\n"
+            "parent\x00\x0038\r63\t\x00\n"
+            "other\x00a\x00\x00\n"
+            "\n", contents)
+
 
 class TestGraphIndex(TestCaseWithMemoryTransport):
 




More information about the bazaar-commits mailing list