~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml5.py

  • Committer: Ian Clatworthy
  • Date: 2009-09-09 15:30:59 UTC
  • mto: (4634.37.2 prepare-2.0)
  • mto: This revision was merged to the branch mainline in revision 4689.
  • Revision ID: ian.clatworthy@canonical.com-20090909153059-sb038agvd38ci2q8
more link fixes in the User Guide

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
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
17
from bzrlib import (
20
18
    cache_utf8,
21
19
    errors,
22
20
    inventory,
23
21
    xml6,
24
 
    )
25
 
from bzrlib.xml_serializer import (
26
 
    encode_and_escape,
27
 
    get_utf8_or_ascii,
28
 
    unpack_inventory_entry,
29
 
    )
30
 
 
 
22
    xml8,
 
23
    )
31
24
 
32
25
class Serializer_v5(xml6.Serializer_v6):
33
26
    """Version 5 serializer
37
30
    format_num = '5'
38
31
    root_id = inventory.ROOT_ID
39
32
 
40
 
    def _unpack_inventory(self, elt, revision_id, entry_cache=None,
41
 
                          return_from_cache=False):
 
33
    def _unpack_inventory(self, elt, revision_id, entry_cache=None):
42
34
        """Construct from XML Element
43
35
        """
44
36
        root_id = elt.get('file_id') or inventory.ROOT_ID
45
 
        root_id = get_utf8_or_ascii(root_id)
 
37
        root_id = xml8._get_utf8_or_ascii(root_id)
46
38
 
47
39
        format = elt.get('format')
48
40
        if format is not None:
59
51
        #   avoiding attributes     2.46s
60
52
        #   adding assertions       2.50s
61
53
        #   last_parent cache       2.52s (worse, removed)
 
54
        unpack_entry = self._unpack_entry
62
55
        byid = inv._byid
63
56
        for e in elt:
64
 
            ie = unpack_inventory_entry(e, entry_cache=entry_cache,
65
 
                              return_from_cache=return_from_cache)
 
57
            ie = unpack_entry(e, entry_cache=entry_cache)
66
58
            parent_id = ie.parent_id
67
59
            if parent_id is None:
68
60
                ie.parent_id = parent_id = root_id
98
90
        """Append the inventory root to output."""
99
91
        if inv.root.file_id not in (None, inventory.ROOT_ID):
100
92
            fileid1 = ' file_id="'
101
 
            fileid2 = encode_and_escape(inv.root.file_id)
 
93
            fileid2 = xml8._encode_and_escape(inv.root.file_id)
102
94
        else:
103
95
            fileid1 = ""
104
96
            fileid2 = ""
105
97
        if inv.revision_id is not None:
106
98
            revid1 = ' revision_id="'
107
 
            revid2 = encode_and_escape(inv.revision_id)
 
99
            revid2 = xml8._encode_and_escape(inv.revision_id)
108
100
        else:
109
101
            revid1 = ""
110
102
            revid2 = ""