/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

More work on roundtrip push support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
    InvalidRevisionId,
23
23
    InvalidRevisionSpec,
24
24
    )
 
25
from bzrlib.revision import (
 
26
    NULL_REVISION,
 
27
)
25
28
from bzrlib.revisionspec import (
26
29
    RevisionInfo,
27
30
    RevisionSpec,
71
74
        raise InvalidRevisionSpec(self.user_spec, branch)
72
75
 
73
76
    def _history(self, branch, revid):
74
 
        history = list(branch.repository.iter_reverse_revision_history(revid))
 
77
        branch.lock_read()
 
78
        try:
 
79
            history = list(branch.repository.iter_reverse_revision_history(
 
80
                revid))
 
81
        finally:
 
82
            branch.unlock()
75
83
        history.reverse()
76
84
        return history
77
85
 
78
86
    def __nonzero__(self):
79
 
        from bzrlib.revision import (
80
 
            NULL_REVISION,
81
 
            )
82
87
        # The default implementation uses branch.repository.has_revision()
83
88
        if self.rev_id is None:
84
89
            return False
88
93
 
89
94
    def _find_short_git_sha1(self, branch, sha1):
90
95
        from bzrlib.plugins.git.mapping import (
 
96
            ForeignGit,
91
97
            mapping_registry,
92
98
            )
93
99
        parse_revid = getattr(branch.repository, "lookup_bzr_revision_id",
96
102
        try:
97
103
            graph = branch.repository.get_graph()
98
104
            for revid, _ in graph.iter_ancestry([branch.last_revision()]):
 
105
                if revid == NULL_REVISION:
 
106
                    continue
99
107
                try:
100
108
                    foreign_revid, mapping = parse_revid(revid)
101
109
                except InvalidRevisionId:
102
110
                    continue
 
111
                if not isinstance(mapping.vcs, ForeignGit):
 
112
                    continue
103
113
                if foreign_revid.startswith(sha1):
104
114
                    history = self._history(branch, revid)
105
115
                    return RevisionInfo.from_revision_id(branch, revid, history)