diff --git a/hgext3rd/interactiveui.py b/hgext3rd/interactiveui.py --- a/hgext3rd/interactiveui.py +++ b/hgext3rd/interactiveui.py @@ -12,12 +12,19 @@ import termios import tty -def clearline(): +from mercurial.i18n import _ + +from mercurial import ( + error, +) + +def clearline(n=1): w = sys.stdout # ANSI # ESC[#A : up # lines # ESC[K : clear to end of line - w.write('\033[1A\033[K') + for i in range(n): + w.write('\033[1A\033[K') w.flush() # From: @@ -107,8 +114,10 @@ def view(viewobj): done = False + if viewobj.ui.pageractive: + raise error.Abort(_("interactiveui doesn't work with pager")) s = viewobj.render() - print(s) + sys.stdout.write(s) while not done: output = getchar(sys.stdin.fileno()) if repr(output) == '\'q\'': @@ -123,7 +132,6 @@ viewobj.rightarrow() if repr(output) == '\'\\x1b[D\'': viewobj.leftarrow() - for i in range(len(s.split("\n"))): - clearline() + clearline(s.count("\n")) s = viewobj.render() - print(s) + sys.stdout.write(s) diff --git a/hgext3rd/undo.py b/hgext3rd/undo.py --- a/hgext3rd/undo.py +++ b/hgext3rd/undo.py @@ -653,6 +653,10 @@ ui = self.ui ui.pushbuffer() _preview(ui, self.repo, self.index) + repo.ui.status(_("<-: next " + "->: previous " + "q: abort " + "enter: confirm\n")) return ui.popbuffer() def rightarrow(self): self.index += 1 @@ -862,8 +866,8 @@ commandstr = _readnode(repo, "command.i", nodedict["command"]) commandlist = commandstr.split("\0")[1:] commandstr = " ".join(commandlist) - uimessage = 'undone to %s, before %s\n' % (time, commandstr) - repo.ui.status(_(uimessage)) + uimessage = _('undone to %s, before %s\n') % (time, commandstr) + repo.ui.status((uimessage)) def _computerelative(repo, reverseindex, absolute=False, branch=""): # allows for relative undos using @@ -1069,6 +1073,9 @@ # None # override "UNDOINDEX" as a variable usable in template + if not _gapcheck(ui, repo, reverseindex): + repo.ui.status(_("WARN: missing history between present and this" + " state\n")) overrides = { ('templates', 'UNDOINDEX'): str(reverseindex), } @@ -1082,6 +1089,17 @@ try: with ui.configoverride(overrides): cmdutil.graphlog(ui, repo, None, opts) + # informative output + nodedict = _readindex(repo, reverseindex) + time = _readnode(repo, "date.i", nodedict["date"]) + time = util.datestr([float(x) for x in time.split(" ")]) + + nodedict = _readindex(repo, reverseindex - 1) + commandstr = _readnode(repo, "command.i", nodedict["command"]) + commandlist = commandstr.split("\0")[1:] + commandstr = " ".join(commandlist) + uimessage = _('undo to %s, before %s\n') % (time, commandstr) + repo.ui.status((uimessage)) except IndexError: # don't print anything pass diff --git a/tests/test-undo.t b/tests/test-undo.t --- a/tests/test-undo.t +++ b/tests/test-undo.t @@ -734,6 +734,7 @@ o | ~ + undo to *, before ci -m prev1 (glob) $ hg undo -p -n 2 @ Undone | @@ -754,6 +755,7 @@ o | ~ + undo to *, before undo -b 3532 (glob) hg redo tests $ hg log -G -T compact