/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

Support user.signingkey configuration variable in .git/config.

Merged from https://code.launchpad.net/~jelmer/brz/local-git-key/+merge/381000

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