/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: John Arbash Meinel
  • Date: 2009-06-12 18:05:15 UTC
  • mto: (4371.4.5 vila-better-heads)
  • mto: This revision was merged to the branch mainline in revision 4449.
  • Revision ID: john@arbash-meinel.com-20090612180515-t0cwbjsnve094oik
Add a failing test for handling nodes that are in the same linear chain.

It fails because the ancestry skipping causes us to miss the fact that the two nodes
are actually directly related. We could check at the beginning, as the 
code used to do, but I think that will be incomplete for the more-than-two
heads cases.

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,
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'