Patchwork [2,of,5] crecord: make _getstatuslines update numstatuslines

login
register
mail settings
Submitter Jun Wu
Date Nov. 28, 2016, 11:52 p.m.
Message ID <bb6a5e96a536b37075e1.1480377126@x1c>
Download mbox | patch
Permalink /patch/17770/
State Accepted
Headers show

Comments

Jun Wu - Nov. 28, 2016, 11:52 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1479939795 0
#      Wed Nov 23 22:23:15 2016 +0000
# Node ID bb6a5e96a536b37075e1c79f7b74d19dfe671827
# Parent  e48c90823ca48725263c5cc2040827c31d6e447b
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r bb6a5e96a536
crecord: make _getstatuslines update numstatuslines

We are going to make the text in the status window dynamically generated,
so its size would be dynamic. Change getstatuslines to update
"numstatuslines" automatically. Fix an issue where "numstatuslines" being 1
makes the chunkpad disappear.

Patch

diff --git a/mercurial/crecord.py b/mercurial/crecord.py
--- a/mercurial/crecord.py
+++ b/mercurial/crecord.py
@@ -542,5 +542,5 @@  class curseschunkselector(object):
         self.numpadlines = None
 
-        self.numstatuslines = 2
+        self.numstatuslines = 1
 
         # keep a running count of the number of lines printed to the pad
@@ -956,4 +956,7 @@  class curseschunkselector(object):
                      _(" (f)old/unfold; (c)onfirm applied; (q)uit; (?) help "
                        "| [X]=hunk applied **=folded, toggle [a]mend mode")]
+        if len(lines) != self.numstatuslines:
+            self.numstatuslines = len(lines)
+            self.statuswin.resize(self.numstatuslines, self.xscreensize)
         return [util.ellipsis(l, self.xscreensize - 1) for l in lines]
 
@@ -980,5 +983,5 @@  class curseschunkselector(object):
             self.chunkpad.refresh(self.firstlineofpadtoprint, 0,
                                   self.numstatuslines, 0,
-                                  self.yscreensize + 1 - self.numstatuslines,
+                                  self.yscreensize - self.numstatuslines,
                                   self.xscreensize)
         except curses.error: