/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-02-07 02:14:30 UTC
  • mto: This revision was merged to the branch mainline in revision 7492.
  • Revision ID: jelmer@jelmer.uk-20200207021430-m49iq3x4x8xlib6x
Drop python2 support.

Show diffs side-by-side

added added

removed removed

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