~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/chk_serializer.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-06-18 20:25:52 UTC
  • mfrom: (4413.5.15 1.16-chk-direct)
  • Revision ID: pqm@pqm.ubuntu.com-20090618202552-xyl6tcvbxtm8bupf
(jam) Improve initial commit performance by creating a CHKMap in bulk,
        rather than via O(tree) map() calls.

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
 
131
136
        return self.read_revision_from_string(f.read())
132
137
 
133
138
 
134
 
class CHKSerializerSubtree(BEncodeRevisionSerializer1, xml7.Serializer_v7):
 
139
class CHKSerializerSubtree(BEncodeRevisionSerializer1, xml6.Serializer_v6):
135
140
    """A CHKInventory based serializer that supports tree references"""
136
141
 
137
142
    supported_kinds = set(['file', 'directory', 'symlink', 'tree-reference'])
139
144
    revision_format_num = None
140
145
    support_altered_by_hack = False
141
146
 
142
 
    def _unpack_entry(self, elt, entry_cache=None, return_from_cache=False):
 
147
    def _unpack_entry(self, elt):
143
148
        kind = elt.tag
144
149
        if not kind in self.supported_kinds:
145
150
            raise AssertionError('unsupported entry kind %s' % kind)
152
157
            return inventory.TreeReference(file_id, name, parent_id, revision,
153
158
                                           reference_revision)
154
159
        else:
155
 
            return xml7.Serializer_v7._unpack_entry(self, elt,
156
 
                entry_cache=entry_cache, return_from_cache=return_from_cache)
 
160
            return xml6.Serializer_v6._unpack_entry(self, elt)
157
161
 
158
162
    def __init__(self, node_size, search_key_name):
159
163
        self.maximum_size = node_size
160
164
        self.search_key_name = search_key_name
161
165
 
162
166
 
163
 
class CHKSerializer(xml6.Serializer_v6):
 
167
class CHKSerializer(xml5.Serializer_v5):
164
168
    """A CHKInventory based serializer with 'plain' behaviour."""
165
169
 
166
170
    format_num = '9'