/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 GitRepository.revision_graph_can_have_wrong_parents().

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    InvalidRevisionSpec,
22
22
    NoSuchRevision,
23
23
    )
 
24
from bzrlib.revision import (
 
25
    NULL_REVISION,
 
26
    )
24
27
from bzrlib.revisionspec import (
25
28
    RevisionInfo,
26
29
    RevisionSpec,
29
32
from bzrlib.plugins.git import (
30
33
    lazy_check_versions,
31
34
    )
 
35
from bzrlib.plugins.git.errors import (
 
36
    GitSmartRemoteNotSupported,
 
37
    )
32
38
from bzrlib.plugins.git.mapping import (
33
39
    mapping_registry,
34
40
    )
40
46
    """
41
47
    
42
48
    prefix = 'git:'
 
49
    wants_revision_history = False
43
50
 
44
51
    def _lookup_git_sha1(self, branch, sha1):
45
 
        bzr_revid = branch.mapping.revision_id_foreign_to_bzr(git_sha1)
46
 
        if branch.repository.has_revision(bzr_revid):
47
 
            history = self._history(branch, bzr_revid)
48
 
            return RevisionInfo.from_revision_id(branch, bzr_revid, history)
 
52
        bzr_revid = branch.mapping.revision_id_foreign_to_bzr(sha1)
 
53
        try:
 
54
            if branch.repository.has_revision(bzr_revid):
 
55
                history = self._history(branch, bzr_revid)
 
56
                return RevisionInfo.from_revision_id(branch, bzr_revid, history)
 
57
        except GitSmartRemoteNotSupported:
 
58
            return RevisionInfo(branch, None, bzr_revid)
49
59
        raise InvalidRevisionSpec(self.user_spec, branch)
50
60
 
51
61
    def _history(self, branch, revid):
53
63
        history.reverse()
54
64
        return history
55
65
 
 
66
    def __nonzero__(self):
 
67
        # The default implementation uses branch.repository.has_revision()
 
68
        if self.rev_id is None:
 
69
            return False
 
70
        if self.rev_id == NULL_REVISION:
 
71
            return False
 
72
        return True
 
73
 
56
74
    def _find_short_git_sha1(self, branch, sha1):
57
75
        parse_revid = getattr(branch.repository, "lookup_git_revid",
58
76
                              mapping_registry.parse_revision_id)