/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-03-04 00:16:27 UTC
  • mfrom: (7293 work)
  • mto: This revision was merged to the branch mainline in revision 7318.
  • Revision ID: jelmer@jelmer.uk-20190304001627-v6u7o6pf97tukhek
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
70
66
            )
71
67
 
72
68
        bzr_revid = getattr(branch.repository, "lookup_foreign_revision_id",
73
 
                              default_mapping.revision_id_foreign_to_bzr)(sha1)
 
69
                            default_mapping.revision_id_foreign_to_bzr)(sha1)
74
70
        try:
75
71
            if branch.repository.has_revision(bzr_revid):
76
72
                return RevisionInfo.from_revision_id(branch, bzr_revid)
110
106
 
111
107
    def _match_on(self, branch, revs):
112
108
        loc = self.spec.find(':')
113
 
        git_sha1 = self.spec[loc+1:].encode("utf-8")
 
109
        git_sha1 = self.spec[loc + 1:].encode("utf-8")
114
110
        if len(git_sha1) > 40 or not valid_git_sha1(git_sha1):
115
111
            raise InvalidRevisionSpec(self.user_spec, branch)
116
112
        from . import (