/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: 2017-07-23 22:06:41 UTC
  • mfrom: (6738 trunk)
  • mto: This revision was merged to the branch mainline in revision 6739.
  • Revision ID: jelmer@jelmer.uk-20170723220641-69eczax9bmv8d6kk
Merge trunk, address review comments.

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