Rev 2609: Multi node sort order is defined. in http://people.ubuntu.com/~robertc/baz2.0/repository
Robert Collins
robertc at robertcollins.net
Fri Jul 13 08:00:27 BST 2007
At http://people.ubuntu.com/~robertc/baz2.0/repository
------------------------------------------------------------
revno: 2609
revision-id: robertc at robertcollins.net-20070713070024-ji0p81rkb5aviq9p
parent: robertc at robertcollins.net-20070713065540-ldqbgi877gtckek4
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Fri 2007-07-13 17:00:24 +1000
message:
Multi node sort order is defined.
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 06:53:51 +0000
+++ b/bzrlib/index.py 2007-07-13 07:00:24 +0000
@@ -67,7 +67,7 @@
def finish(self):
lines = [_SIGNATURE]
lines.append(_OPTION_NODE_REFS + str(self.reference_lists) + '\n')
- for key, (references, value) in self._nodes.items():
+ 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('\n')
=== modified file 'bzrlib/tests/test_index.py'
--- a/bzrlib/tests/test_index.py 2007-07-13 06:55:40 +0000
+++ b/bzrlib/tests/test_index.py 2007-07-13 07:00:24 +0000
@@ -49,6 +49,23 @@
self.assertEqual("Bazaar Graph Index 1\nnode_ref_lists=0\n"
"akey\0\0data\n\n", contents)
+ def test_build_index_two_nodes_sorted_reverse(self):
+ # the highest sorted node comes first.
+ builder = GraphIndexBuilder()
+ # use three to have a good chance of glitching dictionary hash
+ # lookups etc. Insert in randomish order that is not correct
+ # and not the reverse of the correct order.
+ builder.add_node('2001', (), 'data')
+ builder.add_node('2000', (), 'data')
+ builder.add_node('2002', (), 'data')
+ 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"
+ "\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