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

Merge test-run support.

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 ..errors import (
 
24
from ... import version_info as breezy_version
 
25
from ...errors import (
25
26
    InvalidRevisionId,
26
27
    InvalidRevisionSpec,
27
28
    )
28
 
from ..revision import (
 
29
from ...revision import (
29
30
    NULL_REVISION,
30
31
)
31
 
from ..revisionspec import (
 
32
from ...revisionspec import (
32
33
    RevisionInfo,
33
34
    RevisionSpec,
34
35
    )
40
41
    :param hex: Hex string to validate
41
42
    :return: Boolean
42
43
    """
 
44
    import binascii
43
45
    try:
44
 
        int(hex, 16)
45
 
    except ValueError:
 
46
        binascii.unhexlify(hex)
 
47
    except TypeError:
 
48
        return False
 
49
    except binascii.Error:
46
50
        return False
47
51
    else:
48
52
        return True
49
53
 
50
54
 
51
55
class RevisionSpec_git(RevisionSpec):
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.
 
56
    """Selects a revision using a Subversion revision number."""
 
57
 
 
58
    help_txt = """Selects a revision using a Git revision sha1.
60
59
    """
61
60
 
62
61
    prefix = 'git:'
71
70
            )
72
71
 
73
72
        bzr_revid = getattr(branch.repository, "lookup_foreign_revision_id",
74
 
                            default_mapping.revision_id_foreign_to_bzr)(sha1)
 
73
                              default_mapping.revision_id_foreign_to_bzr)(sha1)
75
74
        try:
76
75
            if branch.repository.has_revision(bzr_revid):
77
76
                return RevisionInfo.from_revision_id(branch, bzr_revid)
111
110
 
112
111
    def _match_on(self, branch, revs):
113
112
        loc = self.spec.find(':')
114
 
        git_sha1 = self.spec[loc + 1:].encode("utf-8")
115
 
        if (len(git_sha1) > 40 or len(git_sha1) < 4 or
116
 
                not valid_git_sha1(git_sha1)):
 
113
        git_sha1 = self.spec[loc+1:].encode("utf-8")
 
114
        if len(git_sha1) > 40 or not valid_git_sha1(git_sha1):
117
115
            raise InvalidRevisionSpec(self.user_spec, branch)
118
116
        from . import (
119
117
            lazy_check_versions,