/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/plugins/weave_fmt/xml4.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-07-04 12:50:55 UTC
  • mfrom: (7027.2.8 git-fixes)
  • Revision ID: breezy.the.bot@gmail.com-20180704125055-8nni25pn2439p48v
Fix eol handling in knits on Python 3, port fastimport plugin to Python 3.

Merged from https://code.launchpad.net/~jelmer/brz/fastimport-fixes/+merge/348924

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 bzrlib.xml_serializer import (
 
17
from __future__ import absolute_import
 
18
 
 
19
from ...bzr.xml_serializer import (
18
20
    Element,
19
21
    SubElement,
20
22
    XMLSerializer,
21
23
    escape_invalid_chars,
22
24
    )
23
 
from bzrlib.inventory import ROOT_ID, Inventory
24
 
import bzrlib.inventory as inventory
25
 
from bzrlib.revision import Revision
26
 
from bzrlib.errors import BzrError
 
25
from ...bzr.inventory import ROOT_ID, Inventory
 
26
from ...bzr import inventory
 
27
from ...revision import Revision
 
28
from ...errors import BzrError
27
29
 
28
30
 
29
31
class _Serializer_v4(XMLSerializer):
40
42
        """Convert InventoryEntry to XML element"""
41
43
        e = Element('entry')
42
44
        e.set('name', ie.name)
43
 
        e.set('file_id', ie.file_id)
 
45
        e.set('file_id', ie.file_id.decode('ascii'))
44
46
        e.set('kind', ie.kind)
45
47
 
46
48
        if ie.text_size is not None:
68
70
 
69
71
        :param revision_id: Ignored parameter used by xml5.
70
72
        """
71
 
        root_id = elt.get('file_id') or ROOT_ID
 
73
        root_id = elt.get('file_id')
 
74
        root_id = (root_id.encode('ascii') if root_id else ROOT_ID)
72
75
        inv = Inventory(root_id)
73
76
        for e in elt:
74
77
            ie = self._unpack_entry(e, entry_cache=entry_cache,
84
87
        ## nodes in the root directory, but it's cleaner to use one
85
88
        ## internally.
86
89
        parent_id = elt.get('parent_id')
87
 
        if parent_id is None:
88
 
            parent_id = ROOT_ID
 
90
        parent_id = (parent_id.encode('ascii') if parent_id else ROOT_ID)
89
91
 
 
92
        file_id = elt.get('file_id').encode('ascii')
90
93
        kind = elt.get('kind')
91
94
        if kind == 'directory':
92
 
            ie = inventory.InventoryDirectory(elt.get('file_id'),
 
95
            ie = inventory.InventoryDirectory(file_id,
93
96
                                              elt.get('name'),
94
97
                                              parent_id)
95
98
        elif kind == 'file':
96
 
            ie = inventory.InventoryFile(elt.get('file_id'),
 
99
            ie = inventory.InventoryFile(file_id,
97
100
                                         elt.get('name'),
98
101
                                         parent_id)
99
102
            ie.text_id = elt.get('text_id')
100
103
            ie.text_sha1 = elt.get('text_sha1')
 
104
            if ie.text_sha1 is not None:
 
105
                ie.text_sha1 = ie.text_sha1.encode('ascii')
101
106
            v = elt.get('text_size')
102
107
            ie.text_size = v and int(v)
103
108
        elif kind == 'symlink':
104
 
            ie = inventory.InventoryLink(elt.get('file_id'),
 
109
            ie = inventory.InventoryLink(file_id,
105
110
                                         elt.get('name'),
106
111
                                         parent_id)
107
112
            ie.symlink_target = elt.get('symlink_target')