/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: 2009-02-20 06:16:22 UTC
  • mfrom: (4023 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4027.
  • Revision ID: andrew.bennetts@canonical.com-20090220061622-te9miq29rlfqiwwv
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
174
174
    def is_locked(self):
175
175
        raise NotImplementedError(self.is_locked)
176
176
 
 
177
    def _lefthand_history(self, revision_id, last_rev=None,
 
178
                          other_branch=None):
 
179
        if 'evil' in debug.debug_flags:
 
180
            mutter_callsite(4, "_lefthand_history scales with history.")
 
181
        # stop_revision must be a descendant of last_revision
 
182
        graph = self.repository.get_graph()
 
183
        if last_rev is not None:
 
184
            if not graph.is_ancestor(last_rev, revision_id):
 
185
                # our previous tip is not merged into stop_revision
 
186
                raise errors.DivergedBranches(self, other_branch)
 
187
        # make a new revision history from the graph
 
188
        parents_map = graph.get_parent_map([revision_id])
 
189
        if revision_id not in parents_map:
 
190
            raise errors.NoSuchRevision(self, revision_id)
 
191
        current_rev_id = revision_id
 
192
        new_history = []
 
193
        check_not_reserved_id = _mod_revision.check_not_reserved_id
 
194
        # Do not include ghosts or graph origin in revision_history
 
195
        while (current_rev_id in parents_map and
 
196
               len(parents_map[current_rev_id]) > 0):
 
197
            check_not_reserved_id(current_rev_id)
 
198
            new_history.append(current_rev_id)
 
199
            current_rev_id = parents_map[current_rev_id][0]
 
200
            parents_map = graph.get_parent_map([current_rev_id])
 
201
        new_history.reverse()
 
202
        return new_history
 
203
 
177
204
    def lock_write(self):
178
205
        raise NotImplementedError(self.lock_write)
179
206
 
819
846
        """Set a new push location for this branch."""
820
847
        raise NotImplementedError(self.set_push_location)
821
848
 
 
849
    def _run_post_change_branch_tip_hooks(self, old_revno, old_revid):
 
850
        """Run the post_change_branch_tip hooks."""
 
851
        hooks = Branch.hooks['post_change_branch_tip']
 
852
        if not hooks:
 
853
            return
 
854
        new_revno, new_revid = self.last_revision_info()
 
855
        params = ChangeBranchTipParams(
 
856
            self, old_revno, new_revno, old_revid, new_revid)
 
857
        for hook in hooks:
 
858
            hook(params)
 
859
 
 
860
    def _run_pre_change_branch_tip_hooks(self, new_revno, new_revid):
 
861
        """Run the pre_change_branch_tip hooks."""
 
862
        hooks = Branch.hooks['pre_change_branch_tip']
 
863
        if not hooks:
 
864
            return
 
865
        old_revno, old_revid = self.last_revision_info()
 
866
        params = ChangeBranchTipParams(
 
867
            self, old_revno, new_revno, old_revid, new_revid)
 
868
        for hook in hooks:
 
869
            try:
 
870
                hook(params)
 
871
            except errors.TipChangeRejected:
 
872
                raise
 
873
            except Exception:
 
874
                exc_info = sys.exc_info()
 
875
                hook_name = Branch.hooks.get_hook_name(hook)
 
876
                raise errors.HookFailed(
 
877
                    'pre_change_branch_tip', hook_name, exc_info)
 
878
 
822
879
    def set_parent(self, url):
823
880
        raise NotImplementedError(self.set_parent)
824
881
 
1795
1852
                new_history = rev.get_history(self.repository)[1:]
1796
1853
        destination.set_revision_history(new_history)
1797
1854
 
1798
 
    def _run_pre_change_branch_tip_hooks(self, new_revno, new_revid):
1799
 
        """Run the pre_change_branch_tip hooks."""
1800
 
        hooks = Branch.hooks['pre_change_branch_tip']
1801
 
        if not hooks:
1802
 
            return
1803
 
        old_revno, old_revid = self.last_revision_info()
1804
 
        params = ChangeBranchTipParams(
1805
 
            self, old_revno, new_revno, old_revid, new_revid)
1806
 
        for hook in hooks:
1807
 
            try:
1808
 
                hook(params)
1809
 
            except errors.TipChangeRejected:
1810
 
                raise
1811
 
            except Exception:
1812
 
                exc_info = sys.exc_info()
1813
 
                hook_name = Branch.hooks.get_hook_name(hook)
1814
 
                raise errors.HookFailed(
1815
 
                    'pre_change_branch_tip', hook_name, exc_info)
1816
 
 
1817
 
    def _run_post_change_branch_tip_hooks(self, old_revno, old_revid):
1818
 
        """Run the post_change_branch_tip hooks."""
1819
 
        hooks = Branch.hooks['post_change_branch_tip']
1820
 
        if not hooks:
1821
 
            return
1822
 
        new_revno, new_revid = self.last_revision_info()
1823
 
        params = ChangeBranchTipParams(
1824
 
            self, old_revno, new_revno, old_revid, new_revid)
1825
 
        for hook in hooks:
1826
 
            hook(params)
1827
 
 
1828
1855
    @needs_write_lock
1829
1856
    def set_last_revision_info(self, revno, revision_id):
1830
1857
        """Set the last revision of this branch.
1853
1880
            history.pop()
1854
1881
        return history
1855
1882
 
1856
 
    def _lefthand_history(self, revision_id, last_rev=None,
1857
 
                          other_branch=None):
1858
 
        if 'evil' in debug.debug_flags:
1859
 
            mutter_callsite(4, "_lefthand_history scales with history.")
1860
 
        # stop_revision must be a descendant of last_revision
1861
 
        graph = self.repository.get_graph()
1862
 
        if last_rev is not None:
1863
 
            if not graph.is_ancestor(last_rev, revision_id):
1864
 
                # our previous tip is not merged into stop_revision
1865
 
                raise errors.DivergedBranches(self, other_branch)
1866
 
        # make a new revision history from the graph
1867
 
        parents_map = graph.get_parent_map([revision_id])
1868
 
        if revision_id not in parents_map:
1869
 
            raise errors.NoSuchRevision(self, revision_id)
1870
 
        current_rev_id = revision_id
1871
 
        new_history = []
1872
 
        check_not_reserved_id = _mod_revision.check_not_reserved_id
1873
 
        # Do not include ghosts or graph origin in revision_history
1874
 
        while (current_rev_id in parents_map and
1875
 
               len(parents_map[current_rev_id]) > 0):
1876
 
            check_not_reserved_id(current_rev_id)
1877
 
            new_history.append(current_rev_id)
1878
 
            current_rev_id = parents_map[current_rev_id][0]
1879
 
            parents_map = graph.get_parent_map([current_rev_id])
1880
 
        new_history.reverse()
1881
 
        return new_history
1882
 
 
1883
1883
    @needs_write_lock
1884
1884
    def generate_revision_history(self, revision_id, last_rev=None,
1885
1885
        other_branch=None):