/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/git/mapping.py

  • Committer: Jelmer Vernooij
  • Date: 2020-03-22 01:35:14 UTC
  • mfrom: (7490.7.6 work)
  • mto: This revision was merged to the branch mainline in revision 7499.
  • Revision ID: jelmer@jelmer.uk-20200322013514-7vw1ntwho04rcuj3
merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
"""Converters, etc for going between Bazaar and Git ids."""
20
20
 
21
 
from __future__ import absolute_import
22
 
 
23
21
import base64
24
22
import stat
25
23
 
39
37
    NULL_REVISION,
40
38
    Revision,
41
39
    )
42
 
from ..sixish import (
43
 
    PY3,
44
 
    text_type,
45
 
    viewitems,
46
 
    )
47
40
from .errors import (
48
41
    NoPushSupport,
49
42
    )
175
168
    def generate_file_id(self, path):
176
169
        # Git paths are just bytestrings
177
170
        # We must just hope they are valid UTF-8..
178
 
        if isinstance(path, text_type):
 
171
        if isinstance(path, str):
179
172
            path = path.encode("utf-8")
180
173
        if path == b"":
181
174
            return ROOT_ID
191
184
    def revid_as_refname(self, revid):
192
185
        if not isinstance(revid, bytes):
193
186
            raise TypeError(revid)
194
 
        if PY3:
195
 
            revid = revid.decode('utf-8')
 
187
        revid = revid.decode('utf-8')
196
188
        quoted_revid = urlutils.quote(revid)
197
189
        return b"refs/bzr/" + quoted_revid.encode('utf-8')
198
190
 
252
244
        (message, renames, branch, extra) = extract_hg_metadata(message)
253
245
        if branch is not None:
254
246
            rev.properties[u'hg:extra:branch'] = branch
255
 
        for name, value in viewitems(extra):
 
247
        for name, value in extra.items():
256
248
            rev.properties[u'hg:extra:' + name] = base64.b64encode(value)
257
249
        if renames:
258
250
            rev.properties[u'hg:renames'] = base64.b64encode(bencode.bencode(
259
 
                [(new, old) for (old, new) in viewitems(renames)]))
 
251
                [(new, old) for (old, new) in renames.items()]))
260
252
        return message
261
253
 
262
254
    def _extract_bzr_metadata(self, rev, message):
347
339
                 u'commit-timezone-neg-utc', u'git-implicit-encoding',
348
340
                 u'git-gpg-signature', u'git-explicit-encoding',
349
341
                 u'author-timestamp', u'file-modes'])
350
 
            for k, v in viewitems(rev.properties):
 
342
            for k, v in rev.properties.items():
351
343
                if k not in mapping_properties:
352
344
                    metadata.properties[k] = v
353
345
        if not lossy and metadata:
574
566
def symlink_to_blob(symlink_target):
575
567
    from dulwich.objects import Blob
576
568
    blob = Blob()
577
 
    if isinstance(symlink_target, text_type):
 
569
    if isinstance(symlink_target, str):
578
570
        symlink_target = symlink_target.encode('utf-8')
579
571
    blob.data = symlink_target
580
572
    return blob