Rev 3806: Hack up the serialized form so that we can support multi-line values. in http://bzr.arbash-meinel.com/branches/bzr/brisbane/knit_parent_hack
John Arbash Meinel
john at arbash-meinel.com
Wed Dec 3 02:29:52 GMT 2008
At http://bzr.arbash-meinel.com/branches/bzr/brisbane/knit_parent_hack
------------------------------------------------------------
revno: 3806
revision-id: john at arbash-meinel.com-20081203022937-82s2xlcafakdqy0v
parent: john at arbash-meinel.com-20081203013227-rou9cbbpgd6bh9fh
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: knit_parent_hack
timestamp: Tue 2008-12-02 20:29:37 -0600
message:
Hack up the serialized form so that we can support multi-line values.
-------------- next part --------------
=== modified file 'bzrlib/chk_map.py'
--- a/bzrlib/chk_map.py 2008-12-03 01:32:27 +0000
+++ b/bzrlib/chk_map.py 2008-12-03 02:29:37 +0000
@@ -445,16 +445,25 @@
:param key: The key that the serialised node has.
"""
result = LeafNode()
- lines = bytes.splitlines()
+ lines = bytes.splitlines(True)
items = {}
- if lines[0] != 'chkleaf:':
+ if lines[0] != 'chkleaf:\n':
raise ValueError("not a serialised leaf node: %r" % bytes)
maximum_size = int(lines[1])
width = int(lines[2])
length = int(lines[3])
- for line in lines[4:]:
- elements = line.split('\x00', width)
- items[tuple(elements[:-1])] = elements[-1]
+ pos = 4
+ while pos < len(lines):
+ elements = lines[pos].split('\x00')
+ assert len(elements) == width + 1
+ num_value_lines = int(elements[-1])
+ pos += 1
+ value_lines = lines[pos:pos+num_value_lines]
+ pos += num_value_lines
+ value = ''.join(value_lines)
+ assert value.endswith('\n')
+ value = value[:-1]
+ items[tuple(elements[:-1])] = value
if len(items) != length:
raise AssertionError("item count mismatch")
result._items = items
@@ -559,7 +568,9 @@
lines.append("%d\n" % self._key_width)
lines.append("%d\n" % self._len)
for key, value in sorted(self._items.items()):
- lines.append("%s\x00%s\n" % ('\x00'.join(key), value))
+ value_lines = (value + '\n').splitlines(True)
+ lines.append("%s\x00%d\n" % ('\x00'.join(key), len(value_lines)))
+ lines.extend(value_lines)
if self._orig_key is None:
parents = ()
else:
@@ -571,6 +582,8 @@
' different details: %s',
e)
self._key = e.key
+ if len(e.key) != 1 or not e.key[0].startswith('sha1:'):
+ import pdb; pdb.set_trace()
else:
self._key = ("sha1:" + sha1,)
self._orig_key = self._key
@@ -841,6 +854,8 @@
' different details: %s',
e)
self._key = e.key
+ if len(e.key) != 1 or not e.key[0].startswith('sha1:'):
+ import pdb; pdb.set_trace()
else:
self._key = ("sha1:" + sha1,)
self._orig_key = self._key
More information about the bazaar-commits
mailing list