comparison mercurial/crecord.py @ 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 1e71a27dee97
children 6e6452bc441d
comparison
equal deleted inserted replaced
33972:b1f75d8e887a 33973:a1cd6eae2ad3
1437 try: 1437 try:
1438 with self.ui.timeblockedsection('crecord'): 1438 with self.ui.timeblockedsection('crecord'):
1439 helpwin.getkey() 1439 helpwin.getkey()
1440 except curses.error: 1440 except curses.error:
1441 pass 1441 pass
1442
1443 def commitMessageWindow(self):
1444 "Create a temporary commit message editing window on the screen."
1445
1446 curses.raw()
1447 curses.def_prog_mode()
1448 curses.endwin()
1449 self.commenttext = self.ui.edit(self.commenttext, self.ui.username())
1450 curses.cbreak()
1451 self.stdscr.refresh()
1452 self.stdscr.keypad(1) # allow arrow-keys to continue to function
1442 1453
1443 def confirmationwindow(self, windowtext): 1454 def confirmationwindow(self, windowtext):
1444 "display an informational window, then wait for and return a keypress." 1455 "display an informational window, then wait for and return a keypress."
1445 1456
1446 confirmwin = curses.newwin(self.yscreensize, 0, 0, 0) 1457 confirmwin = curses.newwin(self.yscreensize, 0, 0, 0)
1659 self.toggleedit(test=test) 1670 self.toggleedit(test=test)
1660 elif keypressed in ["f"]: 1671 elif keypressed in ["f"]:
1661 self.togglefolded() 1672 self.togglefolded()
1662 elif keypressed in ["F"]: 1673 elif keypressed in ["F"]:
1663 self.togglefolded(foldparent=True) 1674 self.togglefolded(foldparent=True)
1675 elif keypressed in ["m"]:
1676 self.commitMessageWindow()
1664 elif keypressed in ["?"]: 1677 elif keypressed in ["?"]:
1665 self.helpwindow() 1678 self.helpwindow()
1666 self.stdscr.clear() 1679 self.stdscr.clear()
1667 self.stdscr.refresh() 1680 self.stdscr.refresh()
1668 elif curses.unctrl(keypressed) in ["^L"]: 1681 elif curses.unctrl(keypressed) in ["^L"]:
1734 continue 1747 continue
1735 except curses.error: 1748 except curses.error:
1736 keypressed = "foobar" 1749 keypressed = "foobar"
1737 if self.handlekeypressed(keypressed): 1750 if self.handlekeypressed(keypressed):
1738 break 1751 break
1752
1753 if self.commenttext != "":
1754 whitespaceremoved = re.sub("(?m)^\s.*(\n|$)", "", self.commenttext)
1755 if whitespaceremoved != "":
1756 self.opts['message'] = self.commenttext