1841
1841
raise BzrCommandError('Please supply either one revision, or a range.')
1844
class cmd_uncommit(bzrlib.commands.Command):
1845
"""Remove the last committed revision.
1847
By supplying the --all flag, it will not only remove the entry
1848
from revision_history, but also remove all of the entries in the
1851
--verbose will print out what is being removed.
1852
--dry-run will go through all the motions, but not actually
1855
In the future, uncommit will create a changeset, which can then
1858
takes_options = ['all', 'verbose', 'revision',
1859
Option('dry-run', help='Don\'t actually make changes'),
1860
Option('force', help='Say yes to all questions.')]
1861
takes_args = ['location?']
1864
def run(self, location=None, all=False,
1865
dry_run=False, verbose=False,
1866
revision=None, force=False):
1867
from bzrlib.branch import Branch
1868
from bzrlib.log import log_formatter
1870
from bzrlib.uncommit import uncommit
1872
if location is None:
1874
b, relpath = Branch.open_containing(location)
1876
if revision is None:
1878
rev_id = b.last_revision()
1880
revno, rev_id = revision[0].in_history(b)
1882
print 'No revisions to uncommit.'
1884
for r in range(revno, b.revno()+1):
1885
rev_id = b.get_rev_id(r)
1886
lf = log_formatter('short', to_file=sys.stdout,show_timezone='original')
1887
lf.show(r, b.get_revision(rev_id), None)
1890
print 'Dry-run, pretending to remove the above revisions.'
1892
val = raw_input('Press <enter> to continue')
1894
print 'The above revision(s) will be removed.'
1896
val = raw_input('Are you sure [y/N]? ')
1897
if val.lower() not in ('y', 'yes'):
1901
uncommit(b, remove_files=all,
1902
dry_run=dry_run, verbose=verbose,
1844
1906
# these get imported and then picked up by the scan for cmd_*
1845
1907
# TODO: Some more consistent way to split command definitions across files;
1846
1908
# we do need to load at least some information about them to know of