17
17
"""Remove the last revision from the history of the current branch."""
19
from __future__ import absolute_import
21
19
# TODO: make the guts of this methods on tree, branch.
25
23
revision as _mod_revision,
27
from .branch import Branch
28
from .errors import BoundBranchOutOfDate
31
def remove_tags(branch, graph, old_tip, parents):
32
"""Remove tags on revisions between old_tip and new_tip.
34
:param branch: Branch to remove tags from
35
:param graph: Graph object for branch repository
36
:param old_tip: Old branch tip
37
:param parents: New parents
38
:return: Names of the removed tags
40
reverse_tags = branch.tags.get_reverse_tag_dict()
41
ancestors = graph.find_unique_ancestors(old_tip, parents)
43
for revid, tags in reverse_tags.items():
44
if revid not in ancestors:
47
branch.tags.delete_tag(tag)
48
removed_tags.append(tag)
25
from bzrlib.branch import Branch
26
from bzrlib.errors import BoundBranchOutOfDate
52
29
def uncommit(branch, dry_run=False, verbose=False, revno=None, tree=None,
53
local=False, keep_tags=False):
54
31
"""Remove the last revision from the supplied branch.
56
33
:param dry_run: Don't actually change anything
59
36
:param local: If this branch is bound, only remove the revisions from the
60
37
local branch. If this branch is not bound, it is an error to pass
62
:param keep_tags: Whether to keep tags pointing at the removed revisions
92
67
new_revno = revno - 1
69
revid_iterator = branch.repository.iter_reverse_revision_history(
94
71
cur_revno = old_revno
95
72
new_revision_id = old_tip
96
73
graph = branch.repository.get_graph()
97
for rev_id in graph.iter_lefthand_ancestry(old_tip):
74
for rev_id in revid_iterator:
98
75
if cur_revno == new_revno:
99
76
new_revision_id = rev_id
102
print('Removing revno %d: %s' % (cur_revno, rev_id))
79
print 'Removing revno %d: %s' % (cur_revno, rev_id)
104
81
parents = graph.get_parent_map([rev_id]).get(rev_id, None)
130
107
hook_new_tip = None
131
108
hook(hook_local, hook_master, old_revno, old_tip, new_revno,
133
if not _mod_revision.is_null(new_revision_id):
134
parents = [new_revision_id]
137
110
if tree is not None:
111
if not _mod_revision.is_null(new_revision_id):
112
parents = [new_revision_id]
138
115
parents.extend(reversed(pending_merges))
139
116
tree.set_parent_ids(parents)
140
if branch.supports_tags() and not keep_tags:
141
remove_tags(branch, graph, old_tip, parents)
143
118
for item in reversed(unlockable):