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

  • Committer: Andrew Bennetts
  • Date: 2008-06-25 06:48:25 UTC
  • mto: (3452.2.11 inter-remote-pack)
  • mto: This revision was merged to the branch mainline in revision 3511.
  • Revision ID: andrew.bennetts@canonical.com-20080625064825-rda4tckbyjtpbasd
Tweaks suggested by John's review: rename _check_if_descendant_or_diverged, move caching last_revision_info into base Branch, better use of lock decorators.

Show diffs side-by-side

added added

removed removed

Lines of Context:
85
85
        self.tags = self._make_tags()
86
86
        self._revision_history_cache = None
87
87
        self._revision_id_to_revno_cache = None
 
88
        self._last_revision_info_cache = None
88
89
 
89
90
    def break_lock(self):
90
91
        """Break a lock if one is present from another instance.
361
362
        """
362
363
        self._revision_history_cache = None
363
364
        self._revision_id_to_revno_cache = None
 
365
        self._last_revision_info_cache = None
364
366
 
365
367
    def _gen_revision_history(self):
366
368
        """Return sequence of revision hashes on to this branch.
413
415
        """Return last revision id, or NULL_REVISION."""
414
416
        return self.last_revision_info()[1]
415
417
 
 
418
    @needs_read_lock
416
419
    def last_revision_info(self):
417
420
        """Return information about the last revision.
418
421
 
419
 
        :return: A tuple (revno, last_revision_id).
 
422
        :return: A tuple (revno, revision_id).
420
423
        """
 
424
        if self._last_revision_info_cache is None:
 
425
            self._last_revision_info_cache = self._last_revision_info()
 
426
        return self._last_revision_info_cache
 
427
 
 
428
    def _last_revision_info(self):
421
429
        rh = self.revision_history()
422
430
        revno = len(rh)
423
431
        if revno:
484
492
            if not overwrite:
485
493
                if graph is None:
486
494
                    graph = self.repository.get_graph()
487
 
                if self._ensure_not_diverged(
 
495
                if self._check_if_descendant_or_diverged(
488
496
                        stop_revision, last_rev, graph, other):
489
497
                    # stop_revision is a descendant of last_rev, but we aren't
490
498
                    # overwriting, so we're done.
849
857
    def supports_tags(self):
850
858
        return self._format.supports_tags()
851
859
 
852
 
    def _ensure_not_diverged(self, revision_a, revision_b, graph, other_branch):
 
860
    def _check_if_descendant_or_diverged(self, revision_a, revision_b, graph,
 
861
                                         other_branch):
853
862
        """Ensure that revision_b is a descendant of revision_a.
854
863
 
855
864
        This is a helper function for update_revisions.
1911
1920
 
1912
1921
    def __init__(self, *args, **kwargs):
1913
1922
        super(BzrBranch6, self).__init__(*args, **kwargs)
1914
 
        self._last_revision_info_cache = None
1915
1923
        self._partial_revision_history_cache = []
1916
1924
 
1917
1925
    def _clear_cached_state(self):
1918
1926
        super(BzrBranch6, self)._clear_cached_state()
1919
 
        self._last_revision_info_cache = None
1920
1927
        self._partial_revision_history_cache = []
1921
1928
 
1922
 
    @needs_read_lock
1923
 
    def last_revision_info(self):
1924
 
        """Return information about the last revision.
1925
 
 
1926
 
        :return: A tuple (revno, revision_id).
1927
 
        """
1928
 
        if self._last_revision_info_cache is None:
1929
 
            self._last_revision_info_cache = self._last_revision_info()
1930
 
        return self._last_revision_info_cache
1931
 
 
1932
1929
    def _last_revision_info(self):
1933
1930
        revision_string = self._transport.get_bytes('last-revision')
1934
1931
        revno, revision_id = revision_string.rstrip('\n').split(' ', 1)