/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 bzrlib/xml5.py

  • Committer: Robert Collins
  • Date: 2010-05-06 11:08:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506110810-h3j07fh5gmw54s25
Cleaner matcher matching revised unlocking protocol.

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