1
# Copyright (C) 2008 Canonical Ltd
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.
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.
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
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
"""Serializer object for CHK based inventory storage."""
26
class CHKSerializerSubtree(xml6.Serializer_v6):
27
"""A CHKInventory based serializer that supports tree references"""
29
supported_kinds = set(['file', 'directory', 'symlink', 'tree-reference'])
31
revision_format_num = None
32
support_altered_by_hack = False
34
def _unpack_entry(self, elt):
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,
47
return xml6.Serializer_v6._unpack_entry(self, elt)
50
class CHKSerializer(xml5.Serializer_v5):
51
"""A CHKInventory based serializer with 'plain' behaviour."""
54
revision_format_num = None
55
support_altered_by_hack = False
58
chk_serializer_subtree = CHKSerializerSubtree()
59
chk_serializer = CHKSerializer()