~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml6.py

  • Committer: Aaron Bentley
  • Date: 2006-08-23 04:25:06 UTC
  • mto: (1910.2.43 format-bumps)
  • mto: This revision was merged to the branch mainline in revision 1997.
  • Revision ID: aaron.bentley@utoronto.ca-20060823042506-98adf009e8bd90d1
Make commits preserve root entry data

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from bzrlib import cache_utf8, inventory, errors, xml5
 
2
 
 
3
 
 
4
class Serializer_v6(xml5.Serializer_v5):
 
5
 
 
6
    def _append_inventory_root(self, append, inv):
 
7
        """Append the inventory root to output."""
 
8
        append('<inventory')
 
9
        append(' format="6"')
 
10
        append(' revision_id="')
 
11
        append(xml5._encode_and_escape(inv.revision_id))
 
12
        append('>\n')
 
13
        self._append_entry(append, inv.root)
 
14
 
 
15
    def _parent_condition(self, ie):
 
16
        return ie.parent_id is not None
 
17
 
 
18
    def _unpack_inventory(self, elt):
 
19
        """Construct from XML Element"""
 
20
        assert elt.tag == 'inventory'
 
21
        format = elt.get('format')
 
22
        if format is not None:
 
23
            if format != '6':
 
24
                raise errors.BzrError("invalid format version %r on inventory"
 
25
                                      % format)
 
26
        revision_id = elt.get('revision_id')
 
27
        if revision_id is not None:
 
28
            revision_id = cache_utf8.get_cached_unicode(revision_id)
 
29
        inv = inventory.Inventory(root_id=None, revision_id=revision_id)
 
30
        for e in elt:
 
31
            ie = self._unpack_entry(e, none_parents=True)
 
32
            inv.add(ie)
 
33
        return inv
 
34
 
 
35
 
 
36
serializer_v6 = Serializer_v6()