/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

Implement to_files() for git merge directives.

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
 
    """
37
32
    import binascii
38
33
    try:
39
34
        binascii.unhexlify(hex)
71
66
        raise InvalidRevisionSpec(self.user_spec, branch)
72
67
 
73
68
    def _history(self, branch, revid):
74
 
        branch.lock_read()
75
 
        try:
76
 
            history = list(branch.repository.iter_reverse_revision_history(
77
 
                revid))
78
 
        finally:
79
 
            branch.unlock()
 
69
        history = list(branch.repository.iter_reverse_revision_history(revid))
80
70
        history.reverse()
81
71
        return history
82
72
 
93
83
 
94
84
    def _find_short_git_sha1(self, branch, sha1):
95
85
        from bzrlib.plugins.git.mapping import (
96
 
            ForeignGit,
97
86
            mapping_registry,
98
87
            )
99
88
        parse_revid = getattr(branch.repository, "lookup_bzr_revision_id",
106
95
                    foreign_revid, mapping = parse_revid(revid)
107
96
                except InvalidRevisionId:
108
97
                    continue
109
 
                if not isinstance(mapping.vcs, ForeignGit):
110
 
                    continue
111
98
                if foreign_revid.startswith(sha1):
112
99
                    history = self._history(branch, revid)
113
100
                    return RevisionInfo.from_revision_id(branch, revid, history)