Mercurial > hg
changeset 33973:a1cd6eae2ad3
record: make the m key open an editor for the commit message (issue5667)
With the former crecord extension, the user could edit the commit
message while he was de-/selecting hunks. By pressing 'm', an editor
showed up to edit the commit message.
With record being part of mercurial, this feature is not available
anymore. However, the help text still mentions it.
As the infrastructure needed is still present, this feature is quite
easily ported from the crecord extension to mercurial.
It seems there is no test coverage for record ui, so I tested this patch
manually on my local machine.
author | Peter Vitt <peter.vitt2@uni-siegen.de> |
---|---|
date | Mon, 28 Aug 2017 13:43:31 +0200 |
parents | b1f75d8e887a |
children | 45a8cd74de4e |
files | mercurial/crecord.py |
diffstat | 1 files changed, 18 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/crecord.py Tue Aug 22 16:59:02 2017 -0400 +++ b/mercurial/crecord.py Mon Aug 28 13:43:31 2017 +0200 @@ -1440,6 +1440,17 @@ except curses.error: pass + def commitMessageWindow(self): + "Create a temporary commit message editing window on the screen." + + curses.raw() + curses.def_prog_mode() + curses.endwin() + self.commenttext = self.ui.edit(self.commenttext, self.ui.username()) + curses.cbreak() + self.stdscr.refresh() + self.stdscr.keypad(1) # allow arrow-keys to continue to function + def confirmationwindow(self, windowtext): "display an informational window, then wait for and return a keypress." @@ -1661,6 +1672,8 @@ self.togglefolded() elif keypressed in ["F"]: self.togglefolded(foldparent=True) + elif keypressed in ["m"]: + self.commitMessageWindow() elif keypressed in ["?"]: self.helpwindow() self.stdscr.clear() @@ -1736,3 +1749,8 @@ keypressed = "foobar" if self.handlekeypressed(keypressed): break + + if self.commenttext != "": + whitespaceremoved = re.sub("(?m)^\s.*(\n|$)", "", self.commenttext) + if whitespaceremoved != "": + self.opts['message'] = self.commenttext