Patchwork histedit: Show file names in multiple line format

login
register
mail settings
Submitter Yu Feng
Date April 25, 2019, 9:46 p.m.
Message ID <d6d86496b7bc2c812097.1556228789@feyu.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/39834/
State Accepted
Headers show

Comments

via Mercurial-devel - May 2, 2019, 11:51 p.m.
I've queued these mostly bases on Jordi's review. Thanks to both of you!


On Thu, Apr 25, 2019 at 8:44 PM Yu Feng <rainwoodman@gmail.com> wrote:

> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -1227,6 +1227,13 @@ def addln(win, y, x, line, color=None):
>      else:
>          win.addstr(y, x, line)
>
> +def _trunc_head(line, n):
> +    if len(line) <= n: return line
> +    return '> ' + line[-(n - 2):]
> +def _trunc_tail(line, n):
> +    if len(line) <= n: return line
> +    return line[:n - 2] + ' >'
>

test-check-pylint.t points out that the lines should be broken after the
colons (please install pylint to run that test in the future). I've added
newlines after the colons above in flight this time.
Jordi Gutiérrez Hermoso - May 3, 2019, 2:21 a.m.
On Thu, 2019-05-02 at 16:51 -0700, Martin von Zweigbergk wrote:
> I've queued these mostly bases on Jordi's review. Thanks to both of you!

Wait wait, I had stylistic complaints, but I couldn't get to them! Ah,
well, I'll submit follow-ups. These patches are definite improvements.
Yu Feng - May 5, 2019, 8:05 p.m.
Thanks for looking into this.

Is there anything that I shall do from my end?

- Yu

On Thu, May 2, 2019 at 7:21 PM Jordi Gutiérrez Hermoso <jordigh@octave.org>
wrote:

> On Thu, 2019-05-02 at 16:51 -0700, Martin von Zweigbergk wrote:
> > I've queued these mostly bases on Jordi's review. Thanks to both of you!
>
> Wait wait, I had stylistic complaints, but I couldn't get to them! Ah,
> well, I'll submit follow-ups. These patches are definite improvements.
>
via Mercurial-devel - May 6, 2019, 3:57 p.m.
On Sun, May 5, 2019 at 1:05 PM Feng Yu <rainwoodman@gmail.com> wrote:

> Thanks for looking into this.
>
> Is there anything that I shall do from my end?
>

No, I don't think so.


>
> - Yu
>
> On Thu, May 2, 2019 at 7:21 PM Jordi Gutiérrez Hermoso <jordigh@octave.org>
> wrote:
>
>> On Thu, 2019-05-02 at 16:51 -0700, Martin von Zweigbergk wrote:
>> > I've queued these mostly bases on Jordi's review. Thanks to both of you!
>>
>> Wait wait, I had stylistic complaints, but I couldn't get to them! Ah,
>> well, I'll submit follow-ups. These patches are definite improvements.
>>
>

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1227,6 +1227,13 @@  def addln(win, y, x, line, color=None):
     else:
         win.addstr(y, x, line)
 
+def _trunc_head(line, n):
+    if len(line) <= n: return line
+    return '> ' + line[-(n - 2):]
+def _trunc_tail(line, n):
+    if len(line) <= n: return line
+    return line[:n - 2] + ' >'
+
 def patchcontents(state):
     repo = state['repo']
     rule = state['rules'][state['pos']]
@@ -1284,11 +1291,23 @@  def _chisteditmain(repo, rules, stdscr):
         line = "bookmark:  {0}".format(' '.join(bms))
         win.addstr(3, 1, line[:length])
 
-        line = "files:     {0}".format(','.join(ctx.files()))
+        line = "summary:   {0}".format(ctx.description().splitlines()[0])
         win.addstr(4, 1, line[:length])
 
-        line = "summary:   {0}".format(ctx.description().splitlines()[0])
-        win.addstr(5, 1, line[:length])
+        line = "files:     "
+        win.addstr(5, 1, line)
+        fnx = 1 + len(line)
+        fnmaxx = length - fnx + 1
+        y = 5
+        fnmaxn = maxy - (1 + y) - 1
+        files = ctx.files()
+        for i, line1 in enumerate(files):
+            if len(files) > fnmaxn and i == fnmaxn - 1:
+                win.addstr(y, fnx, _trunc_tail(','.join(files[i:]), fnmaxx))
+                y = y + 1
+                break
+            win.addstr(y, fnx, _trunc_head(line1, fnmaxx))
+            y = y + 1
 
         conflicts = rule.conflicts
         if len(conflicts) > 0:
@@ -1297,7 +1316,7 @@  def _chisteditmain(repo, rules, stdscr):
         else:
             conflictstr = 'no overlap'
 
-        win.addstr(6, 1, conflictstr[:length])
+        win.addstr(y, 1, conflictstr[:length])
         win.noutrefresh()
 
     def helplines(mode):
@@ -1379,9 +1398,9 @@  pgup/K: move patch up, pgdn/J: move patc
         maxy, maxx = stdscr.getmaxyx()
         helplen = len(helplines(mode))
         return {
-            'commit': (8, maxx),
+            'commit': (12, maxx),
             'help': (helplen, maxx),
-            'main': (maxy - helplen - 8, maxx),
+            'main': (maxy - helplen - 12, maxx),
         }
 
     def drawvertwin(size, y, x):