174
174
def is_locked(self):
175
175
raise NotImplementedError(self.is_locked)
177
def _lefthand_history(self, revision_id, last_rev=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
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()
177
204
def lock_write(self):
178
205
raise NotImplementedError(self.lock_write)
819
846
"""Set a new push location for this branch."""
820
847
raise NotImplementedError(self.set_push_location)
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']
854
new_revno, new_revid = self.last_revision_info()
855
params = ChangeBranchTipParams(
856
self, old_revno, new_revno, old_revid, new_revid)
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']
865
old_revno, old_revid = self.last_revision_info()
866
params = ChangeBranchTipParams(
867
self, old_revno, new_revno, old_revid, new_revid)
871
except errors.TipChangeRejected:
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)
822
879
def set_parent(self, url):
823
880
raise NotImplementedError(self.set_parent)
1795
1852
new_history = rev.get_history(self.repository)[1:]
1796
1853
destination.set_revision_history(new_history)
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']
1803
old_revno, old_revid = self.last_revision_info()
1804
params = ChangeBranchTipParams(
1805
self, old_revno, new_revno, old_revid, new_revid)
1809
except errors.TipChangeRejected:
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)
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']
1822
new_revno, new_revid = self.last_revision_info()
1823
params = ChangeBranchTipParams(
1824
self, old_revno, new_revno, old_revid, new_revid)
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.
1856
def _lefthand_history(self, revision_id, last_rev=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
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()
1883
1883
@needs_write_lock
1884
1884
def generate_revision_history(self, revision_id, last_rev=None,
1885
1885
other_branch=None):