~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/chk_serializer.py

  • Committer: Robert J. Tanner
  • Date: 2009-06-10 03:56:49 UTC
  • mfrom: (4423 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4425.
  • Revision ID: tanner@real-time.com-20090610035649-7rfx4cls4550zc3c
Merge 1.15.1 back to trunk

Show diffs side-by-side

added added

removed removed

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