Rev 2610: Add space to mark absent nodes. in http://people.ubuntu.com/~robertc/baz2.0/repository
Robert Collins
robertc at robertcollins.net
Fri Jul 13 08:13:53 BST 2007
At http://people.ubuntu.com/~robertc/baz2.0/repository
------------------------------------------------------------
revno: 2610
revision-id: robertc at robertcollins.net-20070713071350-ueenwzyztgagccgh
parent: robertc at robertcollins.net-20070713070024-ji0p81rkb5aviq9p
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Fri 2007-07-13 17:13:50 +1000
message:
Add space to mark absent nodes.
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:00:24 +0000
+++ b/bzrlib/index.py 2007-07-13 07:13:50 +0000
@@ -30,7 +30,21 @@
class GraphIndexBuilder(object):
- """A builder that can build a GraphIndex."""
+ """A builder that can build a GraphIndex.
+
+ The resulting graph has the structure:
+
+ _SIGNATURE OPTIONS NODES NEWLINE
+ _SIGNATURE := 'Bazaar Graph Index 1' NEWLINE
+ OPTIONS := 'node_ref_lists=' DIGITS NEWLINE
+ NODES := NODE*
+ 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)*)?
+ VALUE := no-newline-no-null-bytes
+ """
def __init__(self, reference_lists=0):
"""Create a GraphIndex builder.
@@ -69,7 +83,7 @@
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%s\0%s\n" % (key, flattened_references, value))
+ lines.append("%s\0\0%s\0%s\n" % (key, 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:00:24 +0000
+++ b/bzrlib/tests/test_index.py 2007-07-13 07:13:50 +0000
@@ -47,7 +47,7 @@
stream = builder.finish()
contents = stream.read()
self.assertEqual("Bazaar Graph Index 1\nnode_ref_lists=0\n"
- "akey\0\0data\n\n", contents)
+ "akey\0\0\0data\n\n", contents)
def test_build_index_two_nodes_sorted_reverse(self):
# the highest sorted node comes first.
@@ -61,9 +61,9 @@
stream = builder.finish()
contents = stream.read()
self.assertEqual("Bazaar Graph Index 1\nnode_ref_lists=0\n"
- "2002\0\0data\n"
- "2001\0\0data\n"
- "2000\0\0data\n"
+ "2002\0\0\0data\n"
+ "2001\0\0\0data\n"
+ "2000\0\0\0data\n"
"\n", contents)
def test_add_node_bad_key(self):
More information about the bazaar-commits
mailing list