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

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 12:41:27 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521124127-iv8etg0vwymyai6y
s/bzr/brz/ in apport config.

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 .. import (
 
17
from __future__ import absolute_import
 
18
 
 
19
from brzlib import (
18
20
    cache_utf8,
19
21
    errors,
20
 
    osutils,
21
 
    )
22
 
from . import (
23
22
    inventory,
24
23
    xml6,
25
24
    )
26
 
from .xml_serializer import (
 
25
from brzlib.xml_serializer import (
27
26
    encode_and_escape,
28
27
    get_utf8_or_ascii,
29
28
    unpack_inventory_entry,
35
34
 
36
35
    Packs objects into XML and vice versa.
37
36
    """
38
 
    format_num = b'5'
 
37
    format_num = '5'
39
38
    root_id = inventory.ROOT_ID
40
39
 
41
40
    def _unpack_inventory(self, elt, revision_id, entry_cache=None,
63
62
        byid = inv._byid
64
63
        for e in elt:
65
64
            ie = unpack_inventory_entry(e, entry_cache=entry_cache,
66
 
                                        return_from_cache=return_from_cache)
 
65
                              return_from_cache=return_from_cache)
67
66
            parent_id = ie.parent_id
68
67
            if parent_id is None:
69
68
                ie.parent_id = parent_id = root_id
76
75
                raise errors.DuplicateFileId(ie.file_id,
77
76
                                             byid[ie.file_id])
78
77
            if ie.name in parent.children:
79
 
                raise errors.BzrError(
80
 
                    "%s is already versioned" % (
81
 
                        osutils.pathjoin(
82
 
                            inv.id2path(parent_id), ie.name).encode('utf-8'),))
 
78
                raise errors.BzrError("%s is already versioned"
 
79
                    % (osutils.pathjoin(inv.id2path(parent_id),
 
80
                       ie.name).encode('utf-8'),))
83
81
            parent.children[ie.name] = ie
84
82
            byid[ie.file_id] = ie
85
83
        if revision_id is not None:
99
97
    def _append_inventory_root(self, append, inv):
100
98
        """Append the inventory root to output."""
101
99
        if inv.root.file_id not in (None, inventory.ROOT_ID):
102
 
            fileid = b''.join([b' file_id="', encode_and_escape(inv.root.file_id), b'"'])
 
100
            fileid1 = ' file_id="'
 
101
            fileid2 = encode_and_escape(inv.root.file_id)
103
102
        else:
104
 
            fileid = b""
 
103
            fileid1 = ""
 
104
            fileid2 = ""
105
105
        if inv.revision_id is not None:
106
 
            revid = b''.join([b' revision_id="', encode_and_escape(inv.revision_id), b'"'])
 
106
            revid1 = ' revision_id="'
 
107
            revid2 = encode_and_escape(inv.revision_id)
107
108
        else:
108
 
            revid = b""
109
 
        append(b'<inventory%s format="5"%s>\n' % (fileid, revid))
 
109
            revid1 = ""
 
110
            revid2 = ""
 
111
        append('<inventory%s%s format="5"%s%s>\n' % (
 
112
            fileid1, fileid2, revid1, revid2))
110
113
 
111
114
 
112
115
serializer_v5 = Serializer_v5()