Rev 2611: Node references are tab separated. in http://people.ubuntu.com/~robertc/baz2.0/repository
Robert Collins
robertc at robertcollins.net
Fri Jul 13 08:22:45 BST 2007
At http://people.ubuntu.com/~robertc/baz2.0/repository
------------------------------------------------------------
revno: 2611
revision-id: robertc at robertcollins.net-20070713072242-vgf4mkayfyjk6zy0
parent: robertc at robertcollins.net-20070713071350-ueenwzyztgagccgh
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Fri 2007-07-13 17:22:42 +1000
message:
Node references are tab separated.
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 07:13:50 +0000
+++ b/bzrlib/index.py 2007-07-13 07:22:42 +0000
@@ -41,8 +41,10 @@
NODE := KEY NULL ABSENT? NULL REFERENCES NULL VALUE NEWLINE
KEY := Not-whitespace-utf8
ABSENT := 'a'
- REFERENCES := (REFERENCE_LIST TAB) {node_ref_lists}
- REFERENCE_LIST := (KEY (CR KEY)*)?
+ REFERENCES := REFERENCE_LIST (TAB REFERENCE_LIST){node_ref_lists - 1}
+ REFERENCE_LIST := (REFERENCE (CR REFERENCE)*)?
+ REFERENCE := DIGITS ; digits is the byte offset in the index of the
+ ; referenced key.
VALUE := no-newline-no-null-bytes
"""
@@ -82,8 +84,11 @@
lines = [_SIGNATURE]
lines.append(_OPTION_NODE_REFS + str(self.reference_lists) + '\n')
for key, (references, value) in sorted(self._nodes.items(),reverse=True):
- flattened_references = ''
- lines.append("%s\0\0%s\0%s\n" % (key, flattened_references, value))
+ flattened_references = []
+ for ref_list in references:
+ flattened_references.append('')
+ lines.append("%s\0\0%s\0%s\n" % (key,
+ '\t'.join(flattened_references), value))
lines.append('\n')
return StringIO(''.join(lines))
=== modified file 'bzrlib/tests/test_index.py'
--- a/bzrlib/tests/test_index.py 2007-07-13 07:13:50 +0000
+++ b/bzrlib/tests/test_index.py 2007-07-13 07:22:42 +0000
@@ -66,6 +66,24 @@
"2000\0\0\0data\n"
"\n", contents)
+ def test_build_index_reference_lists_are_included_one(self):
+ builder = GraphIndexBuilder(reference_lists=1)
+ builder.add_node('key', ([], ), 'data')
+ stream = builder.finish()
+ contents = stream.read()
+ self.assertEqual("Bazaar Graph Index 1\nnode_ref_lists=1\n"
+ "key\0\0\0data\n"
+ "\n", contents)
+
+ def test_build_index_reference_lists_are_included_two(self):
+ builder = GraphIndexBuilder(reference_lists=2)
+ builder.add_node('key', ([], []), 'data')
+ stream = builder.finish()
+ contents = stream.read()
+ self.assertEqual("Bazaar Graph Index 1\nnode_ref_lists=2\n"
+ "key\0\0\t\0data\n"
+ "\n", contents)
+
def test_add_node_bad_key(self):
builder = GraphIndexBuilder()
for bad_char in '\t\n\x0b\x0c\r\x00 ':
More information about the bazaar-commits
mailing list