[PATCH 1 of 2] rollback: add --force option (not used yet: that's next)
Greg Ward
greg-hg at gerg.ca
Thu Sep 29 21:55:15 CDT 2011
# HG changeset patch
# User Greg Ward <greg at gerg.ca>
# Date 1317349664 14400
# Node ID f295542f482d4b567fa6229b93c1854aca78792c
# Parent 9ec9dd8d1b2454281e03eaa1a804ef3de7e1a7d9
rollback: add --force option (not used yet: that's next)
(Arguably this should be folded with the next patch, but separating
them might make reviewing a bit easier.)
diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -590,12 +590,12 @@
kwt.restrict = restrict
return n
- def rollback(self, dryrun=False):
+ def rollback(self, dryrun=False, force=False):
wlock = self.wlock()
try:
if not dryrun:
changed = self['.'].files()
- ret = super(kwrepo, self).rollback(dryrun)
+ ret = super(kwrepo, self).rollback(dryrun, force)
if not dryrun:
ctx = self['.']
modified, added = _preselect(self[None].status(), changed)
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4584,7 +4584,8 @@
finally:
wlock.release()
- at command('rollback', dryrunopts)
+ at command('rollback', dryrunopts +
+ [('f', 'force', False, _('ignore safety measures'))])
def rollback(ui, repo, **opts):
"""roll back the last transaction (dangerous)
@@ -4614,7 +4615,8 @@
Returns 0 on success, 1 if no rollback data is available.
"""
- return repo.rollback(opts.get('dry_run'))
+ return repo.rollback(dryrun=opts.get('dry_run'),
+ force=opts.get('force'))
@command('root', [])
def root(ui, repo):
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -754,20 +754,20 @@
finally:
lock.release()
- def rollback(self, dryrun=False):
+ def rollback(self, dryrun=False, force=False):
wlock = lock = None
try:
wlock = self.wlock()
lock = self.lock()
if os.path.exists(self.sjoin("undo")):
- return self._rollback(dryrun)
+ return self._rollback(dryrun, force)
else:
self.ui.warn(_("no rollback information available\n"))
return 1
finally:
release(lock, wlock)
- def _rollback(self, dryrun):
+ def _rollback(self, dryrun, force):
ui = self.ui
try:
args = self.opener.read('undo.desc').splitlines()
diff --git a/tests/test-debugcomplete.t b/tests/test-debugcomplete.t
--- a/tests/test-debugcomplete.t
+++ b/tests/test-debugcomplete.t
@@ -257,7 +257,7 @@
rename: after, force, include, exclude, dry-run
resolve: all, list, mark, unmark, no-status, tool, include, exclude
revert: all, date, rev, no-backup, include, exclude, dry-run
- rollback: dry-run
+ rollback: dry-run, force
root:
showconfig: untrusted
tag: force, local, rev, remove, edit, message, date, user
More information about the Mercurial-devel
mailing list