diff --git a/hgext3rd/continue.py b/hgext3rd/continue.py new file mode 100644 --- /dev/null +++ b/hgext3rd/continue.py @@ -0,0 +1,49 @@ +# +# Copyright 2017 Facebook, Inc. +# +# This software may be used and distributed according to the terms of the +# GNU General Public License version 2 or any later version. + +"""continues an interrupted command (figures out what command you interupted) +""" + +from mercurial import ( + cmdutil, + dispatch, + error, + extensions, + registrar +) + +from mercurial.i18n import _ + +from hgext3rd.conflictinfo import findconflictcommand + +cmdtable = {} +command = registrar.command(cmdtable) +testedwith = 'ships-with-fb-hgext' + +def _rerun(ui, repo, cmd): + req = dispatch.request(cmd, ui=ui, repo=repo) + dispatch.dispatch(req) + +@command('continue', [], _('hg continue')) +def continuecmd(ui, repo, *revs, **opts): + """continues an interrupted command + """ + cmd = findconflictcommand(repo) + if cmd is None: + raise error.Abort(_('nothing to continue')) + + _rerun(ui, repo, cmd['to_continue'].split(' ')) + + +@command('abort', [], _('hg abort')) +def abortcmd(ui, repo, *revs, **opts): + """aborts an interrupted command + """ + cmd = findconflictcommand(repo) + if cmd is None: + raise error.Abort(_('nothing to abort')) + + _rerun(ui, repo, cmd['to_abort'].split(' ')) \ No newline at end of file diff --git a/hgext3rd/undo.py b/hgext3rd/undo.py --- a/hgext3rd/undo.py +++ b/hgext3rd/undo.py @@ -124,7 +124,8 @@ # upstream change. repo.invalidatevolatilesets() safelog(repo, command) - del os.environ['_undologactive'] + if '_undologactive' in os.environ: + del os.environ['_undologactive'] return result