~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml5.py

  • Committer: Patch Queue Manager
  • Date: 2011-12-12 14:47:03 UTC
  • mfrom: (6355.1.9 serializer-avoids-xml)
  • Revision ID: pqm@pqm.ubuntu.com-20111212144703-suptg74yxhcpon4p
(jelmer) Avoid loading XML modules when importing CHKSerializer. (Jelmer
 Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
    errors,
20
20
    inventory,
21
21
    xml6,
22
 
    xml8,
23
 
    )
 
22
    )
 
23
from bzrlib.xml_serializer import (
 
24
    encode_and_escape,
 
25
    get_utf8_or_ascii,
 
26
    unpack_inventory_entry,
 
27
    )
 
28
 
24
29
 
25
30
class Serializer_v5(xml6.Serializer_v6):
26
31
    """Version 5 serializer
35
40
        """Construct from XML Element
36
41
        """
37
42
        root_id = elt.get('file_id') or inventory.ROOT_ID
38
 
        root_id = xml8._get_utf8_or_ascii(root_id)
 
43
        root_id = get_utf8_or_ascii(root_id)
39
44
 
40
45
        format = elt.get('format')
41
46
        if format is not None:
52
57
        #   avoiding attributes     2.46s
53
58
        #   adding assertions       2.50s
54
59
        #   last_parent cache       2.52s (worse, removed)
55
 
        unpack_entry = self._unpack_entry
56
60
        byid = inv._byid
57
61
        for e in elt:
58
 
            ie = unpack_entry(e, entry_cache=entry_cache,
 
62
            ie = unpack_inventory_entry(e, entry_cache=entry_cache,
59
63
                              return_from_cache=return_from_cache)
60
64
            parent_id = ie.parent_id
61
65
            if parent_id is None:
92
96
        """Append the inventory root to output."""
93
97
        if inv.root.file_id not in (None, inventory.ROOT_ID):
94
98
            fileid1 = ' file_id="'
95
 
            fileid2 = xml8._encode_and_escape(inv.root.file_id)
 
99
            fileid2 = encode_and_escape(inv.root.file_id)
96
100
        else:
97
101
            fileid1 = ""
98
102
            fileid2 = ""
99
103
        if inv.revision_id is not None:
100
104
            revid1 = ' revision_id="'
101
 
            revid2 = xml8._encode_and_escape(inv.revision_id)
 
105
            revid2 = encode_and_escape(inv.revision_id)
102
106
        else:
103
107
            revid1 = ""
104
108
            revid2 = ""