Patchwork crecord: restore SIGWINCH handler before return

login
register
mail settings
Submitter Jun Wu
Date Aug. 24, 2016, 10:30 a.m.
Message ID <b43b1fd0de59f5bb0ee9.1472034615@x1c>
Download mbox | patch
Permalink /patch/16399/
State Accepted
Headers show

Comments

Jun Wu - Aug. 24, 2016, 10:30 a.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1472034247 -3600
#      Wed Aug 24 11:24:07 2016 +0100
# Node ID b43b1fd0de59f5bb0ee9e04e9fee00f9bf00f32f
# Parent  4ddfb730789d56b6c597dce2c0556b63fbb0d48a
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r b43b1fd0de59
crecord: restore SIGWINCH handler before return

Previously, the SIGWINCH handler does not get cleared and if the commit
message editor also needs SIGWINCH handling (like vim), the two SIGWINCH
handlers (the editor's, ours) will have a race. And we may erase the
editor's screen content.

This patch restores SIGWINCH handler to address the above issue.
Augie Fackler - Aug. 24, 2016, 1:58 p.m.
On Wed, Aug 24, 2016 at 11:30:15AM +0100, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1472034247 -3600
> #      Wed Aug 24 11:24:07 2016 +0100
> # Node ID b43b1fd0de59f5bb0ee9e04e9fee00f9bf00f32f
> # Parent  4ddfb730789d56b6c597dce2c0556b63fbb0d48a
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r b43b1fd0de59
> crecord: restore SIGWINCH handler before return

queued, thanks

>
> Previously, the SIGWINCH handler does not get cleared and if the commit
> message editor also needs SIGWINCH handling (like vim), the two SIGWINCH
> handlers (the editor's, ours) will have a race. And we may erase the
> editor's screen content.
>
> This patch restores SIGWINCH handler to address the above issue.
>
> diff --git a/mercurial/crecord.py b/mercurial/crecord.py
> --- a/mercurial/crecord.py
> +++ b/mercurial/crecord.py
> @@ -1265,3 +1265,2 @@ class curseschunkselector(object):
>              self.chunkpad = curses.newpad(self.numpadlines, self.xscreensize)
> -            # todo: try to resize commit message window if possible
>          except curses.error:
> @@ -1591,3 +1590,4 @@ are you sure you want to review/edit and
>
> -        signal.signal(signal.SIGWINCH, self.sigwinchhandler)
> +        origsigwinchhandler = signal.signal(signal.SIGWINCH,
> +                                            self.sigwinchhandler)
>          self.stdscr = stdscr
> @@ -1642,1 +1642,2 @@ are you sure you want to review/edit and
>                  break
> +        signal.signal(signal.SIGWINCH, origsigwinchhandler)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/crecord.py b/mercurial/crecord.py
--- a/mercurial/crecord.py
+++ b/mercurial/crecord.py
@@ -1265,3 +1265,2 @@  class curseschunkselector(object):
             self.chunkpad = curses.newpad(self.numpadlines, self.xscreensize)
-            # todo: try to resize commit message window if possible
         except curses.error:
@@ -1591,3 +1590,4 @@  are you sure you want to review/edit and
 
-        signal.signal(signal.SIGWINCH, self.sigwinchhandler)
+        origsigwinchhandler = signal.signal(signal.SIGWINCH,
+                                            self.sigwinchhandler)
         self.stdscr = stdscr
@@ -1642,1 +1642,2 @@  are you sure you want to review/edit and
                 break
+        signal.signal(signal.SIGWINCH, origsigwinchhandler)