/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: 2019-03-04 05:10:44 UTC
  • mfrom: (7293 work)
  • mto: This revision was merged to the branch mainline in revision 7294.
  • Revision ID: jelmer@jelmer.uk-20190304051044-vph4s8p9qvpy2qe9
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    )
38
38
from ..revision import (
39
39
    NULL_REVISION,
 
40
    Revision,
40
41
    )
41
42
from ..sixish import (
42
43
    PY3,
377
378
        """
378
379
        return deserialize_fileid_map(blob.data)
379
380
 
 
381
    def get_revision_id(self, commit):
 
382
        if commit.encoding:
 
383
            encoding = commit.encoding.decode('ascii')
 
384
        else:
 
385
            encoding = 'utf-8'
 
386
        message, metadata = self._decode_commit_message(
 
387
            None, commit.message, encoding)
 
388
        if metadata.revision_id:
 
389
            return metadata.revision_id
 
390
        return self.revision_id_foreign_to_bzr(commit.id)
 
391
 
380
392
    def import_commit(self, commit, lookup_parent_revid):
381
393
        """Convert a git commit to a bzr revision.
382
394
 
452
464
            elif k == HG_EXTRA:
453
465
                hgk, hgv = v.split(b':', 1)
454
466
                if hgk not in (HG_EXTRA_AMEND_SOURCE, ):
455
 
                    raise UnknownMercurialCommitExtra(commit, hgk)
 
467
                    raise UnknownMercurialCommitExtra(commit, [hgk])
456
468
                extra_lines.append(k + b' ' + v + b'\n')
457
469
            else:
458
470
                unknown_extra_fields.append(k)
499
511
    BZR_DUMMY_FILE = '.bzrdummy'
500
512
 
501
513
    def _decode_commit_message(self, rev, message, encoding):
 
514
        if rev is None:
 
515
            rev = Revision()
502
516
        message = self._extract_hg_metadata(rev, message)
503
517
        message = self._extract_git_svn_metadata(rev, message)
504
518
        message, metadata = self._extract_bzr_metadata(rev, message)
663
677
        self.paths = None
664
678
        self.mapping = mapping
665
679
 
666
 
    def all_file_ids(self):
667
 
        return self.file_ids.values()
668
 
 
669
680
    def set_file_id(self, path, file_id):
670
681
        if type(path) is not str:
671
682
            raise TypeError(path)