/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/bzr/xml5.py

  • Committer: Jelmer Vernooij
  • Date: 2018-08-21 19:28:52 UTC
  • mfrom: (7078 work)
  • mto: This revision was merged to the branch mainline in revision 7101.
  • Revision ID: jelmer@jelmer.uk-20180821192852-ipy6m8q95bbst223
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
from bzrlib import (
 
17
from __future__ import absolute_import
 
18
 
 
19
from .. import (
18
20
    cache_utf8,
19
21
    errors,
 
22
    )
 
23
from . import (
20
24
    inventory,
21
25
    xml6,
22
 
    xml8,
23
 
    )
 
26
    )
 
27
from .xml_serializer import (
 
28
    encode_and_escape,
 
29
    get_utf8_or_ascii,
 
30
    unpack_inventory_entry,
 
31
    )
 
32
 
24
33
 
25
34
class Serializer_v5(xml6.Serializer_v6):
26
35
    """Version 5 serializer
27
36
 
28
37
    Packs objects into XML and vice versa.
29
38
    """
30
 
    format_num = '5'
 
39
    format_num = b'5'
31
40
    root_id = inventory.ROOT_ID
32
41
 
33
42
    def _unpack_inventory(self, elt, revision_id, entry_cache=None,
35
44
        """Construct from XML Element
36
45
        """
37
46
        root_id = elt.get('file_id') or inventory.ROOT_ID
38
 
        root_id = xml8._get_utf8_or_ascii(root_id)
 
47
        root_id = get_utf8_or_ascii(root_id)
39
48
 
40
49
        format = elt.get('format')
41
50
        if format is not None:
52
61
        #   avoiding attributes     2.46s
53
62
        #   adding assertions       2.50s
54
63
        #   last_parent cache       2.52s (worse, removed)
55
 
        unpack_entry = self._unpack_entry
56
64
        byid = inv._byid
57
65
        for e in elt:
58
 
            ie = unpack_entry(e, entry_cache=entry_cache,
 
66
            ie = unpack_inventory_entry(e, entry_cache=entry_cache,
59
67
                              return_from_cache=return_from_cache)
60
68
            parent_id = ie.parent_id
61
69
            if parent_id is None:
91
99
    def _append_inventory_root(self, append, inv):
92
100
        """Append the inventory root to output."""
93
101
        if inv.root.file_id not in (None, inventory.ROOT_ID):
94
 
            fileid1 = ' file_id="'
95
 
            fileid2 = xml8._encode_and_escape(inv.root.file_id)
 
102
            fileid1 = b' file_id="'
 
103
            fileid2 = encode_and_escape(inv.root.file_id)
96
104
        else:
97
 
            fileid1 = ""
98
 
            fileid2 = ""
 
105
            fileid1 = b""
 
106
            fileid2 = b""
99
107
        if inv.revision_id is not None:
100
 
            revid1 = ' revision_id="'
101
 
            revid2 = xml8._encode_and_escape(inv.revision_id)
 
108
            revid1 = b' revision_id="'
 
109
            revid2 = encode_and_escape(inv.revision_id)
102
110
        else:
103
 
            revid1 = ""
104
 
            revid2 = ""
105
 
        append('<inventory%s%s format="5"%s%s>\n' % (
 
111
            revid1 = b""
 
112
            revid2 = b""
 
113
        append(b'<inventory%s%s format="5"%s%s>\n' % (
106
114
            fileid1, fileid2, revid1, revid2))
107
115
 
108
116