/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/chk_serializer.py

  • Committer: Robert Collins
  • Date: 2010-05-06 11:08:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506110810-h3j07fh5gmw54s25
Cleaner matcher matching revised unlocking protocol.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008 Canonical Ltd
 
1
# Copyright (C) 2008, 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
"""Serializer object for CHK based inventory storage."""
18
18
 
19
 
from cStringIO import (
20
 
    StringIO,
21
 
    )
22
 
 
23
19
from bzrlib import (
24
20
    bencode,
25
21
    cache_utf8,
26
22
    inventory,
27
 
    osutils,
28
23
    revision as _mod_revision,
29
 
    xml5,
30
24
    xml6,
 
25
    xml7,
31
26
    )
32
27
 
33
28
 
50
45
    """Simple revision serializer based around bencode.
51
46
    """
52
47
 
 
48
    squashes_xml_invalid_characters = False
 
49
 
53
50
    # Maps {key:(Revision attribute, bencode_type, validator)}
54
51
    # This tells us what kind we expect bdecode to create, what variable on
55
52
    # Revision we should be using, and a function to call to validate/transform
134
131
        return self.read_revision_from_string(f.read())
135
132
 
136
133
 
137
 
class CHKSerializerSubtree(BEncodeRevisionSerializer1, xml6.Serializer_v6):
 
134
class CHKSerializerSubtree(BEncodeRevisionSerializer1, xml7.Serializer_v7):
138
135
    """A CHKInventory based serializer that supports tree references"""
139
136
 
140
137
    supported_kinds = set(['file', 'directory', 'symlink', 'tree-reference'])
142
139
    revision_format_num = None
143
140
    support_altered_by_hack = False
144
141
 
145
 
    def _unpack_entry(self, elt):
 
142
    def _unpack_entry(self, elt, entry_cache=None, return_from_cache=False):
146
143
        kind = elt.tag
147
144
        if not kind in self.supported_kinds:
148
145
            raise AssertionError('unsupported entry kind %s' % kind)
155
152
            return inventory.TreeReference(file_id, name, parent_id, revision,
156
153
                                           reference_revision)
157
154
        else:
158
 
            return xml6.Serializer_v6._unpack_entry(self, elt)
 
155
            return xml7.Serializer_v7._unpack_entry(self, elt,
 
156
                entry_cache=entry_cache, return_from_cache=return_from_cache)
159
157
 
160
158
    def __init__(self, node_size, search_key_name):
161
159
        self.maximum_size = node_size
162
160
        self.search_key_name = search_key_name
163
161
 
164
162
 
165
 
class CHKSerializer(xml5.Serializer_v5):
 
163
class CHKSerializer(xml6.Serializer_v6):
166
164
    """A CHKInventory based serializer with 'plain' behaviour."""
167
165
 
168
166
    format_num = '9'