~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/chk_serializer.py

  • Committer: Neil Martinsen-Burrell
  • Date: 2009-06-08 05:00:01 UTC
  • mto: (4441.1.1 bzr.ab.integration)
  • mto: This revision was merged to the branch mainline in revision 4443.
  • Revision ID: nmb@wartburg.edu-20090608050001-7znk3433urf3bf0p
Fix 269477 Add documentation about diverged branches and refer to it when pushing fails

Show diffs side-by-side

added added

removed removed

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