/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

Some fixes for colocated branch handling.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
# Please note that imports are delayed as much as possible here since
19
19
# if DWIM revspecs are supported this module is imported by __init__.py.
20
20
 
 
21
from bzrlib import version_info as bzrlib_version
21
22
from bzrlib.errors import (
22
23
    InvalidRevisionId,
23
24
    InvalidRevisionSpec,
67
68
                              default_mapping.revision_id_foreign_to_bzr)(sha1)
68
69
        try:
69
70
            if branch.repository.has_revision(bzr_revid):
70
 
                history = self._history(branch, bzr_revid)
71
 
                return RevisionInfo.from_revision_id(branch, bzr_revid, history)
 
71
                if bzrlib_version < (2, 5):
 
72
                    history = branch.revision_history()
 
73
                    return RevisionInfo.from_revision_id(branch, bzr_revid, history)
 
74
                else:
 
75
                    return RevisionInfo.from_revision_id(branch, bzr_revid)
72
76
        except GitSmartRemoteNotSupported:
73
77
            return RevisionInfo(branch, None, bzr_revid)
74
78
        raise InvalidRevisionSpec(self.user_spec, branch)
75
79
 
76
 
    def _history(self, branch, revid):
77
 
        branch.lock_read()
78
 
        try:
79
 
            history = list(branch.repository.iter_reverse_revision_history(
80
 
                revid))
81
 
        finally:
82
 
            branch.unlock()
83
 
        history.reverse()
84
 
        return history
85
 
 
86
80
    def __nonzero__(self):
87
81
        # The default implementation uses branch.repository.has_revision()
88
82
        if self.rev_id is None:
111
105
                if not isinstance(mapping.vcs, ForeignGit):
112
106
                    continue
113
107
                if foreign_revid.startswith(sha1):
114
 
                    history = self._history(branch, revid)
115
 
                    return RevisionInfo.from_revision_id(branch, revid, history)
 
108
                    if bzrlib_version < (2, 5):
 
109
                        history = branch.revision_history()
 
110
                        return RevisionInfo.from_revision_id(branch, revid, history)
 
111
                    else:
 
112
                        return RevisionInfo.from_revision_id(branch, revid)
116
113
            raise InvalidRevisionSpec(self.user_spec, branch)
117
114
        finally:
118
115
            branch.repository.unlock()