/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
3735.2.9 by Robert Collins
Get a working chk_map using inventory implementation bootstrapped.
1
# Copyright (C) 2008 Canonical Ltd
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
3735.36.3 by John Arbash Meinel
Add the new address for FSF to the new files.
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3735.2.9 by Robert Collins
Get a working chk_map using inventory implementation bootstrapped.
16
17
"""Serializer object for CHK based inventory storage."""
18
19
from bzrlib import (
20
    inventory,
21
    xml5,
22
    xml6,
23
    )
24
25
26
class CHKSerializerSubtree(xml6.Serializer_v6):
27
    """A CHKInventory based serializer that supports tree references"""
28
29
    supported_kinds = set(['file', 'directory', 'symlink', 'tree-reference'])
30
    format_num = '9'
31
    revision_format_num = None
32
    support_altered_by_hack = False
33
34
    def _unpack_entry(self, elt):
35
        kind = elt.tag
36
        if not kind in self.supported_kinds:
37
            raise AssertionError('unsupported entry kind %s' % kind)
38
        if kind == 'tree-reference':
39
            file_id = elt.attrib['file_id']
40
            name = elt.attrib['name']
41
            parent_id = elt.attrib['parent_id']
42
            revision = elt.get('revision')
43
            reference_revision = elt.get('reference_revision')
44
            return inventory.TreeReference(file_id, name, parent_id, revision,
45
                                           reference_revision)
46
        else:
47
            return xml6.Serializer_v6._unpack_entry(self, elt)
48
3735.2.132 by John Arbash Meinel
Remove references to parent_id_basename_index, now that we know we want it.
49
    def __init__(self, node_size, search_key_name):
3735.2.27 by Robert Collins
Use 4K pages for development3 repositories.
50
        self.maximum_size = node_size
3735.16.7 by John Arbash Meinel
Start parameterizing CHKInventory and CHKSerializer so that we can
51
        self.search_key_name = search_key_name
3735.2.27 by Robert Collins
Use 4K pages for development3 repositories.
52
3735.2.9 by Robert Collins
Get a working chk_map using inventory implementation bootstrapped.
53
54
class CHKSerializer(xml5.Serializer_v5):
55
    """A CHKInventory based serializer with 'plain' behaviour."""
56
57
    format_num = '9'
58
    revision_format_num = None
59
    support_altered_by_hack = False
60
3735.2.132 by John Arbash Meinel
Remove references to parent_id_basename_index, now that we know we want it.
61
    def __init__(self, node_size, search_key_name):
3735.2.27 by Robert Collins
Use 4K pages for development3 repositories.
62
        self.maximum_size = node_size
3735.16.7 by John Arbash Meinel
Start parameterizing CHKInventory and CHKSerializer so that we can
63
        self.search_key_name = search_key_name
64
65
3735.2.132 by John Arbash Meinel
Remove references to parent_id_basename_index, now that we know we want it.
66
chk_serializer_subtree_parent_id = CHKSerializerSubtree(4096, 'plain')
67
chk_serializer_parent_id = CHKSerializer(4096, 'plain')
68
chk_serializer_16_parent_id = CHKSerializer(4096, 'hash-16-way')
69
chk_serializer_255_parent_id = CHKSerializer(4096, 'hash-255-way')
3735.31.4 by John Arbash Meinel
Continue trying to reduce the friction for the groupcompress repo formats.
70
chk_serializer_255_bigpage = CHKSerializer(65536, 'hash-255-way')