21
22
:param revno: Remove back to this revision
23
24
from bzrlib.atomicfile import AtomicFile
24
rh = branch.revision_history()
29
new_rev_history = AtomicFile(branch.control_files.controlfilename('revision-history'))
30
for r in range(revno-1, len(rh)):
33
print 'Removing revno %d: %s' % (len(rh)+1, rev_id)
35
new_rev_history.write('\n'.join(rh))
37
# Committing before we start removing files, because
38
# once we have removed at least one, all the rest are invalid.
40
new_rev_history.commit()
41
27
if tree is not None:
42
tree.set_last_revision(branch.last_revision())
44
new_rev_history.abort()
29
unlockable.append(tree)
32
unlockable.append(branch)
34
master = branch.get_master_branch()
35
if master is not None:
37
unlockable.append(master)
38
rh = branch.revision_history()
39
if master is not None and rh[-1] != master.last_revision():
40
raise BoundBranchOutOfDate(branch, master)
45
for r in range(revno-1, len(rh)):
48
print 'Removing revno %d: %s' % (len(rh)+1, rev_id)
51
# Committing before we start removing files, because
52
# once we have removed at least one, all the rest are invalid.
54
if master is not None:
55
master.set_revision_history(rh)
56
branch.set_revision_history(rh)
58
tree.set_last_revision(branch.last_revision())
60
for item in reversed(unlockable):