def nointerruptcmd(orig, ui, options, cmd, cmdfunc): # bail if not in interactive terminal if ui.configbool("nointerrupt", "interactiveonly", True): if not ui.fout.isatty() or ui.plain(): return orig(ui, options, cmd, cmdfunc) cmds, _cmdtableentry = cmdutil.findcmd(cmd, commands.table) shouldpreventinterrupt = ui.configbool("nointerrupt", "default-attend", False) for cmd in cmds: var = "attend-%s" % cmd if ui.config("nointerrupt", var): shouldpreventinterrupt = ui.configbool("nointerrupt", var) break if shouldpreventinterrupt: oldsiginthandler = signal.getsignal(signal.SIGINT) try: msg = ui.config( "nointerrupt", "message", "==========================\n" "Interrupting Mercurial may leave your repo in a bad state.\n" "If you really want to interrupt your current command, press\n" "CTRL-C again.\n" "==========================\n", ) signal.signal( signal.SIGINT, sigintprintwarninghandlerfactory(oldsiginthandler, msg)) except AttributeError: pass return orig(ui, options, cmd, cmdfunc)
def _extend_histedit(ui): histedit = extensions.find("histedit") _aliases, entry = cmdutil.findcmd("histedit", histedit.cmdtable) options = entry[1] options.append(("x", "retry", False, _("retry exec command that failed and try to continue"))) options.append(("", "show-plan", False, _("show remaining actions list"))) extensions.wrapfunction(histedit, "_histedit", _histedit) extensions.wrapfunction(histedit, "parserules", parserules)
def extsetup(ui): try: extensions.find("histedit") except KeyError: raise error.Abort( _("fbhistedit: please enable histedit extension as well")) defineactions() _extend_histedit(ui) rebase = extensions.find("rebase") extensions.wrapcommand(rebase.cmdtable, "rebase", _rebase, synopsis="[-i]") aliases, entry = cmdutil.findcmd("rebase", rebase.cmdtable) newentry = list(entry) options = newentry[1] # dirty hack because we need to change an existing switch for idx, opt in enumerate(options): if opt[0] == "i": del options[idx] options.append(("i", "interactive", False, "interactive rebase")) rebase.cmdtable["rebase"] = tuple(newentry)