~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Jelmer Vernooij
  • Date: 2012-03-14 13:34:43 UTC
  • mto: This revision was merged to the branch mainline in revision 6503.
  • Revision ID: jelmer@samba.org-20120314133443-49xanzettqvnh7zh
Remove more .set_revision_history / .revision_history references.

Show diffs side-by-side

added added

removed removed

Lines of Context:
767
767
        raise NotImplementedError(self.print_file)
768
768
 
769
769
    @needs_write_lock
770
 
    def _set_revision_history(self, rev_history):
771
 
        if len(rev_history) == 0:
772
 
            revid = _mod_revision.NULL_REVISION
773
 
        else:
774
 
            revid = rev_history[-1]
775
 
        if rev_history != self._lefthand_history(revid):
776
 
            raise errors.NotLefthandHistory(rev_history)
777
 
        self.set_last_revision_info(len(rev_history), revid)
778
 
        self._cache_revision_history(rev_history)
779
 
        for hook in Branch.hooks['set_rh']:
780
 
            hook(self, rev_history)
781
 
 
782
 
    @needs_write_lock
783
770
    def set_last_revision_info(self, revno, revision_id):
784
771
        """Set the last revision of this branch.
785
772
 
1790
1777
class BranchHooks(Hooks):
1791
1778
    """A dictionary mapping hook name to a list of callables for branch hooks.
1792
1779
 
1793
 
    e.g. ['set_rh'] Is the list of items to be called when the
1794
 
    set_revision_history function is invoked.
 
1780
    e.g. ['post_push'] Is the list of items to be called when the
 
1781
    push function is invoked.
1795
1782
    """
1796
1783
 
1797
1784
    def __init__(self):
1801
1788
        notified.
1802
1789
        """
1803
1790
        Hooks.__init__(self, "bzrlib.branch", "Branch.hooks")
1804
 
        self.add_hook('set_rh',
1805
 
            "Invoked whenever the revision history has been set via "
1806
 
            "set_revision_history. The api signature is (branch, "
1807
 
            "revision_history), and the branch will be write-locked. "
1808
 
            "The set_rh hook can be expensive for bzr to trigger, a better "
1809
 
            "hook to use is Branch.post_change_branch_tip.", (0, 15))
1810
1791
        self.add_hook('open',
1811
1792
            "Called with the Branch object that has been opened after a "
1812
1793
            "branch is opened.", (1, 8))
2781
2762
        self._write_revision_history(rev_history)
2782
2763
        self._clear_cached_state()
2783
2764
        self._cache_revision_history(rev_history)
2784
 
        for hook in Branch.hooks['set_rh']:
2785
 
            hook(self, rev_history)
2786
2765
        if Branch.hooks['post_change_branch_tip']:
2787
2766
            self._run_post_change_branch_tip_hooks(old_revno, old_revid)
2788
2767