Patchwork record: make m key open an editor for the commit message (issue5667)

login
register
mail settings
Submitter Peter Vitt
Date Aug. 28, 2017, 12:21 p.m.
Message ID <7644a854-fa4b-64e1-45c4-fe54173fd444@uni-siegen.de>
Download mbox | patch
Permalink /patch/23394/
State Accepted
Headers show

Comments

Peter Vitt - Aug. 28, 2017, 12:21 p.m.
# HG changeset patch
# User Peter Vitt <peter.vitt2@uni-siegen.de>
# Date 1503920611 -7200
#      Mon Aug 28 13:43:31 2017 +0200
# Node ID 22ab2b29950a783a5ee52b20693a0b4f9c174fae
# Parent  4e8a46c25facaebca476634d52dd78431d3143e8
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.

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
Augie Fackler - Aug. 28, 2017, 6:13 p.m.
Your patch looks good, but I'm unable to apply it. Did you mail this by pasting into your mail client instead of using `hg email`?

> On Aug 28, 2017, at 08:21, Peter Vitt <peter.vitt2@uni-siegen.de> wrote:
> 
> # HG changeset patch
> # User Peter Vitt <peter.vitt2@uni-siegen.de>
> # Date 1503920611 -7200
> #      Mon Aug 28 13:43:31 2017 +0200
> # Node ID 22ab2b29950a783a5ee52b20693a0b4f9c174fae
> # Parent  4e8a46c25facaebca476634d52dd78431d3143e8
> 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.
> 
> diff -r 4e8a46c25fac -r 22ab2b29950a mercurial/crecord.py
> --- a/mercurial/crecord.py      Tue Aug 22 11:00:00 2017 +0200
> +++ 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
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Augie Fackler - Aug. 28, 2017, 6:15 p.m.
> On Aug 28, 2017, at 14:13, Augie Fackler <raf@durin42.com> wrote:
> 
> Your patch looks good, but I'm unable to apply it. Did you mail this by pasting into your mail client instead of using `hg email`?

While writing this reply I spotted the damage to the patch from your mailer and was able to un-do it, so your patch is queued, thanks!

In the future please be aware that mail clients do terrible things to patches. :/

> 
>> On Aug 28, 2017, at 08:21, Peter Vitt <peter.vitt2@uni-siegen.de> wrote:
>> 
>> # HG changeset patch
>> # User Peter Vitt <peter.vitt2@uni-siegen.de>
>> # Date 1503920611 -7200
>> #      Mon Aug 28 13:43:31 2017 +0200
>> # Node ID 22ab2b29950a783a5ee52b20693a0b4f9c174fae
>> # Parent  4e8a46c25facaebca476634d52dd78431d3143e8
>> 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.
>> 
>> diff -r 4e8a46c25fac -r 22ab2b29950a mercurial/crecord.py
>> --- a/mercurial/crecord.py      Tue Aug 22 11:00:00 2017 +0200
>> +++ 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
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@mercurial-scm.org
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
Peter Vitt - Aug. 28, 2017, 6:55 p.m.
On 08/28/2017 08:15 PM, Augie Fackler wrote:
> 
>> On Aug 28, 2017, at 14:13, Augie Fackler <raf@durin42.com> wrote:
>>
>> Your patch looks good, but I'm unable to apply it. Did you mail this by pasting into your mail client instead of using `hg email`?
> 
> While writing this reply I spotted the damage to the patch from your mailer and was able to un-do it, so your patch is queued, thanks!
> 
> In the future please be aware that mail clients do terrible things to patches. :/

Sorry for that. I already recognized that after sending the mail. I'll
do better next time :)


>>
>>> On Aug 28, 2017, at 08:21, Peter Vitt <peter.vitt2@uni-siegen.de> wrote:
>>>
>>> # HG changeset patch
>>> # User Peter Vitt <peter.vitt2@uni-siegen.de>
>>> # Date 1503920611 -7200
>>> #      Mon Aug 28 13:43:31 2017 +0200
>>> # Node ID 22ab2b29950a783a5ee52b20693a0b4f9c174fae
>>> # Parent  4e8a46c25facaebca476634d52dd78431d3143e8
>>> 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.
>>>
>>> diff -r 4e8a46c25fac -r 22ab2b29950a mercurial/crecord.py
>>> --- a/mercurial/crecord.py      Tue Aug 22 11:00:00 2017 +0200
>>> +++ 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
>>> _______________________________________________
>>> Mercurial-devel mailing list
>>> Mercurial-devel@mercurial-scm.org
>>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>>
>

Patch

diff -r 4e8a46c25fac -r 22ab2b29950a mercurial/crecord.py
--- a/mercurial/crecord.py      Tue Aug 22 11:00:00 2017 +0200
+++ 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