3
Remove the last revision from the history of the current branch.
9
def test_remove(filename):
10
if os.path.exists(filename):
13
print '* file does not exist: %r' % filename
16
def uncommit(branch, dry_run=False, verbose=False, revno=None):
17
"""Remove the last revision from the supplied branch.
19
:param dry_run: Don't actually change anything
20
:param verbose: Print each step as you do it
21
:param revno: Remove back to this revision
23
from bzrlib.atomicfile import AtomicFile
24
rh = branch.revision_history()
29
new_rev_history = AtomicFile(branch.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()
42
new_rev_history.abort()