Rev 5093: (andrew) Fix 'bzr dump-btree' to work with *.cix and *.six files. (#488607) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Mar 17 23:57:19 GMT 2010


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

------------------------------------------------------------
revno: 5093 [merge]
revision-id: pqm at pqm.ubuntu.com-20100317235716-vws90s2mun3mn8lc
parent: pqm at pqm.ubuntu.com-20100317100840-xld2z96vzr6bpc5s
parent: andrew.bennetts at canonical.com-20100317034335-tof43tzw3z601b8q
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2010-03-17 23:57:16 +0000
message:
  (andrew) Fix 'bzr dump-btree' to work with *.cix and *.six files. (#488607)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/tests/blackbox/test_dump_btree.py test_dump_btree.py-20081008203335-zkpcq230b6vubszz-1
=== modified file 'NEWS'
--- a/NEWS	2010-03-17 05:36:11 +0000
+++ b/NEWS	2010-03-17 23:57:16 +0000
@@ -82,6 +82,10 @@
 * ``bzr add`` will not add conflict related files unless explicitly required.
   (Vincent Ladeuil, #322767, #414589)
 
+* ``bzr dump-btree`` now works on ``*.cix`` and ``*.six`` files.  Those
+  indices do not have reference lists, so ``dump-btree`` will simply show
+  ``None`` instead.  (Andrew Bennetts, #488607)
+
 * ``bzr help`` will no longer trigger the get_missing_command hook when
   doing a topic lookup. This avoids prompting (like 'no command plugins/loom,
   did you mean log?') when getting help. In future we may trigger the hook 

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2010-03-13 02:49:14 +0000
+++ b/bzrlib/builtins.py	2010-03-17 03:39:58 +0000
@@ -456,7 +456,12 @@
         for node in bt.iter_all_entries():
             # Node is made up of:
             # (index, key, value, [references])
-            refs_as_tuples = static_tuple.as_tuples(node[3])
+            try:
+                refs = node[3]
+            except IndexError:
+                refs_as_tuples = None
+            else:
+                refs_as_tuples = static_tuple.as_tuples(refs)
             as_tuple = (tuple(node[1]), node[2], refs_as_tuples)
             self.outf.write('%s\n' % (as_tuple,))
 

=== modified file 'bzrlib/tests/blackbox/test_dump_btree.py'
--- a/bzrlib/tests/blackbox/test_dump_btree.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/blackbox/test_dump_btree.py	2010-03-17 03:43:35 +0000
@@ -78,3 +78,16 @@
             'test2\0key3\0ref\0entry3\0value3\n'
             '\n',
             out)
+
+    def test_dump_btree_no_refs_smoke(self):
+        # A BTree index with no ref lists (such as *.cix) can be dumped without
+        # errors.
+        builder = btree_index.BTreeBuilder(
+            reference_lists=0, key_elements=2)
+        builder.add_node(('test', 'key1'), 'value')
+        out_f = builder.finish()
+        try:
+            self.build_tree_contents([('test.btree', out_f.read())])
+        finally:
+            out_f.close()
+        out, err = self.run_bzr('dump-btree test.btree')




More information about the bazaar-commits mailing list