/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/revspec.py

  • Committer: Jelmer Vernooij
  • Date: 2019-06-02 02:35:46 UTC
  • mfrom: (7309 work)
  • mto: This revision was merged to the branch mainline in revision 7319.
  • Revision ID: jelmer@jelmer.uk-20190602023546-lqco868tnv26d8ow
merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
# Please note that imports are delayed as much as possible here since
22
22
# if DWIM revspecs are supported this module is imported by __init__.py.
23
23
 
24
 
from .. import version_info as breezy_version
25
24
from ..errors import (
26
25
    InvalidRevisionId,
27
26
    InvalidRevisionSpec,
41
40
    :param hex: Hex string to validate
42
41
    :return: Boolean
43
42
    """
44
 
    import binascii
45
43
    try:
46
 
        binascii.unhexlify(hex)
47
 
    except TypeError:
48
 
        return False
49
 
    except binascii.Error:
 
44
        int(hex, 16)
 
45
    except ValueError:
50
46
        return False
51
47
    else:
52
48
        return True
53
49
 
54
50
 
55
51
class RevisionSpec_git(RevisionSpec):
56
 
    """Selects a revision using a Subversion revision number."""
57
 
 
58
 
    help_txt = """Selects a revision using a Git revision sha1.
 
52
    """Selects a revision using a Git commit SHA1."""
 
53
 
 
54
    help_txt = """Selects a revision using a Git commit SHA1.
 
55
 
 
56
    Selects a revision using a Git commit SHA1, short or long.
 
57
 
 
58
    This works for both native Git repositories and Git revisions
 
59
    imported into Bazaar repositories.
59
60
    """
60
61
 
61
62
    prefix = 'git:'
70
71
            )
71
72
 
72
73
        bzr_revid = getattr(branch.repository, "lookup_foreign_revision_id",
73
 
                              default_mapping.revision_id_foreign_to_bzr)(sha1)
 
74
                            default_mapping.revision_id_foreign_to_bzr)(sha1)
74
75
        try:
75
76
            if branch.repository.has_revision(bzr_revid):
76
77
                return RevisionInfo.from_revision_id(branch, bzr_revid)
110
111
 
111
112
    def _match_on(self, branch, revs):
112
113
        loc = self.spec.find(':')
113
 
        git_sha1 = self.spec[loc+1:].encode("utf-8")
 
114
        git_sha1 = self.spec[loc + 1:].encode("utf-8")
114
115
        if len(git_sha1) > 40 or not valid_git_sha1(git_sha1):
115
116
            raise InvalidRevisionSpec(self.user_spec, branch)
116
117
        from . import (