20
20
class Serializer_v6(xml5.Serializer_v5):
21
"""This serialiser adds rich roots."""
24
26
def _append_inventory_root(self, append, inv):
25
27
"""Append the inventory root to output."""
27
append(' format="%s"' % self.format_num)
28
28
if inv.revision_id is not None:
29
append(' revision_id="')
30
append(xml5._encode_and_escape(inv.revision_id))
32
self._append_entry(append, inv.root)
34
def _parent_condition(self, ie):
35
return ie.parent_id is not None
37
def _unpack_inventory(self, elt):
29
revid1 = ' revision_id="'
30
revid2 = xml5._encode_and_escape(inv.revision_id)
34
append('<inventory format="%s"%s%s>\n' % (
35
self.format_num, revid1, revid2))
36
append('<directory file_id="%s name="%s revision="%s />\n' % (
37
xml5._encode_and_escape(inv.root.file_id),
38
xml5._encode_and_escape(inv.root.name),
39
xml5._encode_and_escape(inv.root.revision)))
41
def _check_revisions(self, inv):
42
"""Extension point for subclasses to check during serialisation.
44
By default no checking is done.
46
:param inv: An inventory about to be serialised, to be checked.
47
:raises: AssertionError if an error has occured.
49
assert inv.revision_id is not None
50
assert inv.root.revision is not None
52
def _unpack_inventory(self, elt, revision_id=None):
38
53
"""Construct from XML Element"""
39
54
if elt.tag != 'inventory':
40
55
raise errors.UnexpectedInventoryFormat('Root tag is %r' % elt.tag)