[PATCH] crecord: restore SIGWINCH handler before return

Jun Wu quark at fb.com
Wed Aug 24 10:30:15 UTC 2016


# HG changeset patch
# User Jun Wu <quark at 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.

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)


More information about the Mercurial-devel mailing list