Patchwork [1,of,5,STABLE] crecord: extra most on 'main' in a sub function

login
register
mail settings
Submitter Pierre-Yves David
Date April 12, 2017, 8:41 a.m.
Message ID <a8c09dc71f99e929d254.1491986476@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/20127/
State Accepted
Headers show

Comments

Pierre-Yves David - April 12, 2017, 8:41 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1490533512 -7200
#      Sun Mar 26 15:05:12 2017 +0200
# Branch stable
# Node ID a8c09dc71f99e929d2545ee4366231aa98d73d9d
# Parent  8110d49e0558d3b50f8e82b5aa95c8f0e53e47e4
# EXP-Topic crecord-windows
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r a8c09dc71f99
crecord: extra most on 'main' in a sub function

There are some setup and cleanup necessary around the main code, that
setup/cleanup code needs multiple adjustments so we extract the core code into
its own function first for clarity.
Augie Fackler - April 12, 2017, 8:47 p.m.
On Wed, Apr 12, 2017 at 10:41:16AM +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
> # Date 1490533512 -7200
> #      Sun Mar 26 15:05:12 2017 +0200
> # Branch stable
> # Node ID a8c09dc71f99e929d2545ee4366231aa98d73d9d
> # Parent  8110d49e0558d3b50f8e82b5aa95c8f0e53e47e4
> # EXP-Topic crecord-windows
> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r a8c09dc71f99
> crecord: extra most on 'main' in a sub function

Did you mean "extract most of 'main' into a sub function"?

>
> There are some setup and cleanup necessary around the main code, that
> setup/cleanup code needs multiple adjustments so we extract the core code into
> its own function first for clarity.
>
> diff --git a/mercurial/crecord.py b/mercurial/crecord.py
> --- a/mercurial/crecord.py
> +++ b/mercurial/crecord.py
> @@ -1613,6 +1613,10 @@ are you sure you want to review/edit and
>
>          origsigwinchhandler = signal.signal(signal.SIGWINCH,
>                                              self.sigwinchhandler)
> +        return self._main(stdscr)
> +        signal.signal(signal.SIGWINCH, origsigwinchhandler)
> +
> +    def _main(self, stdscr):
>          self.stdscr = stdscr
>          # error during initialization, cannot be printed in the curses
>          # interface, it should be printed by the calling code
> @@ -1663,4 +1667,3 @@ are you sure you want to review/edit and
>                  keypressed = "foobar"
>              if self.handlekeypressed(keypressed):
>                  break
> -        signal.signal(signal.SIGWINCH, origsigwinchhandler)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Pierre-Yves David - April 12, 2017, 8:48 p.m.
On 04/12/2017 10:47 PM, Augie Fackler wrote:
> On Wed, Apr 12, 2017 at 10:41:16AM +0200, Pierre-Yves David wrote:
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
>> # Date 1490533512 -7200
>> #      Sun Mar 26 15:05:12 2017 +0200
>> # Branch stable
>> # Node ID a8c09dc71f99e929d2545ee4366231aa98d73d9d
>> # Parent  8110d49e0558d3b50f8e82b5aa95c8f0e53e47e4
>> # EXP-Topic crecord-windows
>> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
>> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r a8c09dc71f99
>> crecord: extra most on 'main' in a sub function
>
> Did you mean "extract most of 'main' into a sub function"?

I did, my bad.

Patch

diff --git a/mercurial/crecord.py b/mercurial/crecord.py
--- a/mercurial/crecord.py
+++ b/mercurial/crecord.py
@@ -1613,6 +1613,10 @@  are you sure you want to review/edit and
 
         origsigwinchhandler = signal.signal(signal.SIGWINCH,
                                             self.sigwinchhandler)
+        return self._main(stdscr)
+        signal.signal(signal.SIGWINCH, origsigwinchhandler)
+
+    def _main(self, stdscr):
         self.stdscr = stdscr
         # error during initialization, cannot be printed in the curses
         # interface, it should be printed by the calling code
@@ -1663,4 +1667,3 @@  are you sure you want to review/edit and
                 keypressed = "foobar"
             if self.handlekeypressed(keypressed):
                 break
-        signal.signal(signal.SIGWINCH, origsigwinchhandler)