/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 breezy/git/branch.py

  • Committer: Jelmer Vernooij
  • Date: 2019-07-07 17:22:07 UTC
  • mfrom: (7363 work)
  • mto: This revision was merged to the branch mainline in revision 7378.
  • Revision ID: jelmer@jelmer.uk-20190707172207-nnugeuwvxsxo62wa
merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
    )
83
83
 
84
84
 
 
85
def _calculate_revnos(branch):
 
86
    if branch._format.stores_revno():
 
87
        return True
 
88
    config = branch.get_config_stack()
 
89
    return config.get('calculate_revnos')
 
90
 
 
91
 
85
92
class GitPullResult(branch.PullResult):
86
93
    """Result of a pull from a Git branch."""
87
94
 
88
95
    def _lookup_revno(self, revid):
89
96
        if not isinstance(revid, bytes):
90
97
            raise TypeError(revid)
 
98
        if not _calculate_revnos(self.target_branch):
 
99
            return None
91
100
        # Try in source branch first, it'll be faster
92
101
        with self.target_branch.lock_read():
93
102
            return self.target_branch.revision_id_to_revno(revid)
324
333
    def set_reference(self, controldir, name, target):
325
334
        return controldir.set_branch_reference(target, name)
326
335
 
 
336
    def stores_revno(self):
 
337
        """True if this branch format store revision numbers."""
 
338
        return False
 
339
 
327
340
 
328
341
class LocalGitBranchFormat(GitBranchFormat):
329
342
 
808
821
        raise TypeError(revid)
809
822
    # Try in source branch first, it'll be faster
810
823
    with local_branch.lock_read():
 
824
        if not _calculate_revnos(local_branch):
 
825
            return None
811
826
        try:
812
827
            return local_branch.revision_id_to_revno(revid)
813
828
        except errors.NoSuchRevision:
816
831
                return graph.find_distance_to_null(
817
832
                    revid, [(revision.NULL_REVISION, 0)])
818
833
            except errors.GhostRevisionsHaveNoRevno:
 
834
                if not _calculate_revnos(remote_branch):
 
835
                    return None
819
836
                # FIXME: Check using graph.find_distance_to_null() ?
820
837
                with remote_branch.lock_read():
821
838
                    return remote_branch.revision_id_to_revno(revid)