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

  • Committer: Jelmer Vernooij
  • Date: 2010-05-05 09:58:55 UTC
  • mto: (0.200.912 trunk)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@samba.org-20100505095855-i0165hooflvk9chy
Ignore control files in inventories.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
 
31
31
def valid_git_sha1(hex):
 
32
    """Check if `hex` is a validly formatted Git SHA1.
 
33
    
 
34
    :param hex: Hex string to validate
 
35
    :return: Boolean
 
36
    """
32
37
    import binascii
33
38
    try:
34
39
        binascii.unhexlify(hex)
66
71
        raise InvalidRevisionSpec(self.user_spec, branch)
67
72
 
68
73
    def _history(self, branch, revid):
69
 
        history = list(branch.repository.iter_reverse_revision_history(revid))
 
74
        branch.lock_read()
 
75
        try:
 
76
            history = list(branch.repository.iter_reverse_revision_history(
 
77
                revid))
 
78
        finally:
 
79
            branch.unlock()
70
80
        history.reverse()
71
81
        return history
72
82
 
83
93
 
84
94
    def _find_short_git_sha1(self, branch, sha1):
85
95
        from bzrlib.plugins.git.mapping import (
 
96
            ForeignGit,
86
97
            mapping_registry,
87
98
            )
88
99
        parse_revid = getattr(branch.repository, "lookup_bzr_revision_id",
95
106
                    foreign_revid, mapping = parse_revid(revid)
96
107
                except InvalidRevisionId:
97
108
                    continue
 
109
                if not isinstance(mapping.vcs, ForeignGit):
 
110
                    continue
98
111
                if foreign_revid.startswith(sha1):
99
112
                    history = self._history(branch, revid)
100
113
                    return RevisionInfo.from_revision_id(branch, revid, history)