/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: Marius Kruger
  • Date: 2010-07-10 21:28:56 UTC
  • mto: (5384.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5385.
  • Revision ID: marius.kruger@enerweb.co.za-20100710212856-uq4ji3go0u5se7hx
* Update documentation
* add NEWS

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
 
    osutils,
23
 
    )
24
 
from . import (
25
20
    inventory,
26
21
    xml6,
27
 
    )
28
 
from .xml_serializer import (
29
 
    encode_and_escape,
30
 
    get_utf8_or_ascii,
31
 
    unpack_inventory_entry,
32
 
    )
33
 
 
 
22
    xml8,
 
23
    )
34
24
 
35
25
class Serializer_v5(xml6.Serializer_v6):
36
26
    """Version 5 serializer
37
27
 
38
28
    Packs objects into XML and vice versa.
39
29
    """
40
 
    format_num = b'5'
 
30
    format_num = '5'
41
31
    root_id = inventory.ROOT_ID
42
32
 
43
33
    def _unpack_inventory(self, elt, revision_id, entry_cache=None,
45
35
        """Construct from XML Element
46
36
        """
47
37
        root_id = elt.get('file_id') or inventory.ROOT_ID
48
 
        root_id = get_utf8_or_ascii(root_id)
 
38
        root_id = xml8._get_utf8_or_ascii(root_id)
49
39
 
50
40
        format = elt.get('format')
51
41
        if format is not None:
62
52
        #   avoiding attributes     2.46s
63
53
        #   adding assertions       2.50s
64
54
        #   last_parent cache       2.52s (worse, removed)
 
55
        unpack_entry = self._unpack_entry
65
56
        byid = inv._byid
66
57
        for e in elt:
67
 
            ie = unpack_inventory_entry(e, entry_cache=entry_cache,
68
 
                                        return_from_cache=return_from_cache)
 
58
            ie = unpack_entry(e, entry_cache=entry_cache,
 
59
                              return_from_cache=return_from_cache)
69
60
            parent_id = ie.parent_id
70
61
            if parent_id is None:
71
62
                ie.parent_id = parent_id = root_id
78
69
                raise errors.DuplicateFileId(ie.file_id,
79
70
                                             byid[ie.file_id])
80
71
            if ie.name in parent.children:
81
 
                raise errors.BzrError(
82
 
                    "%s is already versioned" % (
83
 
                        osutils.pathjoin(
84
 
                            inv.id2path(parent_id), ie.name).encode('utf-8'),))
 
72
                raise errors.BzrError("%s is already versioned"
 
73
                    % (osutils.pathjoin(inv.id2path(parent_id),
 
74
                       ie.name).encode('utf-8'),))
85
75
            parent.children[ie.name] = ie
86
76
            byid[ie.file_id] = ie
87
77
        if revision_id is not None:
101
91
    def _append_inventory_root(self, append, inv):
102
92
        """Append the inventory root to output."""
103
93
        if inv.root.file_id not in (None, inventory.ROOT_ID):
104
 
            fileid = b''.join([b' file_id="', encode_and_escape(inv.root.file_id), b'"'])
 
94
            fileid1 = ' file_id="'
 
95
            fileid2 = xml8._encode_and_escape(inv.root.file_id)
105
96
        else:
106
 
            fileid = b""
 
97
            fileid1 = ""
 
98
            fileid2 = ""
107
99
        if inv.revision_id is not None:
108
 
            revid = b''.join([b' revision_id="', encode_and_escape(inv.revision_id), b'"'])
 
100
            revid1 = ' revision_id="'
 
101
            revid2 = xml8._encode_and_escape(inv.revision_id)
109
102
        else:
110
 
            revid = b""
111
 
        append(b'<inventory%s format="5"%s>\n' % (fileid, revid))
 
103
            revid1 = ""
 
104
            revid2 = ""
 
105
        append('<inventory%s%s format="5"%s%s>\n' % (
 
106
            fileid1, fileid2, revid1, revid2))
112
107
 
113
108
 
114
109
serializer_v5 = Serializer_v5()