~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_chk_map_py.py

  • Committer: Vincent Ladeuil
  • Date: 2016-02-01 19:26:41 UTC
  • mto: This revision was merged to the branch mainline in revision 6616.
  • Revision ID: v.ladeuil+lp@free.fr-20160201192641-mzn90m51rydhw00n
Open trunk again as 2.8b1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009 Canonical Ltd
 
1
# Copyright (C) 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
16
16
 
17
17
"""Python implementation of _search_key functions, etc."""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
import zlib
20
22
import struct
21
23
 
 
24
from bzrlib.static_tuple import StaticTuple
 
25
 
22
26
_LeafNode = None
23
27
_InternalNode = None
24
28
_unknown = None
93
97
        value_lines = lines[pos:pos+num_value_lines]
94
98
        pos += num_value_lines
95
99
        value = '\n'.join(value_lines)
96
 
        items[tuple(elements[:-1])] = value
 
100
        items[StaticTuple.from_sequence(elements[:-1])] = value
97
101
    if len(items) != length:
98
102
        raise AssertionError("item count (%d) mismatch for key %s,"
99
103
            " bytes %r" % (length, key, bytes))
141
145
    for line in lines[5:]:
142
146
        line = common_prefix + line
143
147
        prefix, flat_key = line.rsplit('\x00', 1)
144
 
        items[prefix] = (flat_key,)
 
148
        items[prefix] = StaticTuple(flat_key,)
145
149
    if len(items) == 0:
146
150
        raise AssertionError("We didn't find any item for %s" % key)
147
151
    result._items = items
156
160
    result._search_prefix = common_prefix
157
161
    return result
158
162
 
 
163
 
 
164
def _bytes_to_text_key(bytes):
 
165
    """Take a CHKInventory value string and return a (file_id, rev_id) tuple"""
 
166
    sections = bytes.split('\n')
 
167
    kind, file_id = sections[0].split(': ')
 
168
    return (intern(file_id), intern(sections[3]))
 
169