Patchwork histedit: add a config allowing changing histedit rule line length limit

login
register
mail settings
Submitter Mateusz Kwapich
Date Feb. 26, 2015, 9:46 a.m.
Message ID <d223d1b0cc6ebda31edd.1424943977@dev1429.prn1.facebook.com>
Download mbox | patch
Permalink /patch/7833/
State Superseded
Commit 4047982904f8b14255c2bdbf1b37e3c25e960777
Headers show

Comments

Mateusz Kwapich - Feb. 26, 2015, 9:46 a.m.
# HG changeset patch
# User Mateusz Kwapich <mitrandir@fb.com>
# Date 1421880324 28800
#      Wed Jan 21 14:45:24 2015 -0800
# Node ID d223d1b0cc6ebda31edda6710b9c05ca1926b8fb
# Parent  ff5caa8dfd993680d9602ca6ebb14da9de10d5f4
histedit: add a config allowing changing histedit rule line length limit

Since many users are using terminals wider than 80 chars there should be an
option to have longer lines in histedit editor.

Even if the summary line is shorter than 80 chars after adding action line
prefixes (like "pick 7c2fd3b9020c") it doesn't fit there anymore. Setting
it to for example 110 would be a  nice option to have.
Jordi GutiƩrrez Hermoso - Feb. 26, 2015, 1:31 p.m.
On Thu, 2015-02-26 at 01:46 -0800, Mateusz Kwapich wrote:
> # HG changeset patch
> # User Mateusz Kwapich <mitrandir@fb.com>
> # Date 1421880324 28800
> #      Wed Jan 21 14:45:24 2015 -0800
> # Node ID d223d1b0cc6ebda31edda6710b9c05ca1926b8fb
> # Parent  ff5caa8dfd993680d9602ca6ebb14da9de10d5f4
> histedit: add a config allowing changing histedit rule line length limit
[snip]
> +    maxlen = ui.configint('histedit', 'action_line_maxlen', default=80)

We don't use underscores in option names. Justjamallthewordstogether.
Look at `hg help config` for examples.

While we're talking about docs, this option needs some. They should go
in `hg help -e histedit`.

- Jordi G. H.
Augie Fackler - Feb. 26, 2015, 5:51 p.m.
On Thu, Feb 26, 2015 at 8:31 AM, Jordi GutiƩrrez Hermoso
<jordigh@octave.org> wrote:
>> histedit: add a config allowing changing histedit rule line length limit
> [snip]
>> +    maxlen = ui.configint('histedit', 'action_line_maxlen', default=80)
>
> We don't use underscores in option names. Justjamallthewordstogether.
> Look at `hg help config` for examples.

I'd probably go with histedit.linelen for the name.

>
> While we're talking about docs, this option needs some. They should go
> in `hg help -e histedit`.

+1

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -638,7 +638,7 @@  def _histedit(ui, repo, state, *freeargs
 
         ctxs = [repo[r] for r in revs]
         if not rules:
-            rules = '\n'.join([makedesc(c) for c in ctxs])
+            rules = '\n'.join([makedesc(ui, c) for c in ctxs])
             rules += '\n\n'
             rules += editcomment % (node.short(root), node.short(topmost))
             rules = ui.edit(rules, ui.username())
@@ -805,7 +805,7 @@  def between(repo, old, new, keep):
             raise util.Abort(_('cannot edit immutable changeset: %s') % root)
     return [c.node() for c in ctxs]
 
-def makedesc(c):
+def makedesc(ui, c):
     """build a initial action line for a ctx `c`
 
     line are in the form:
@@ -817,7 +817,9 @@  def makedesc(c):
         summary = c.description().splitlines()[0]
     line = 'pick %s %d %s' % (c, c.rev(), summary)
     # trim to 80 columns so it's not stupidly wide in my editor
-    return util.ellipsis(line, 80)
+    maxlen = ui.configint('histedit', 'action_line_maxlen', default=80)
+    maxlen = max(maxlen, 22) # avoid truncating hash
+    return util.ellipsis(line, maxlen)
 
 def verifyrules(rules, repo, ctxs):
     """Verify that there exists exactly one edit rule per given changeset.