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

login
register
mail settings
Submitter Mateusz Kwapich
Date Feb. 26, 2015, 6:14 p.m.
Message ID <e75e5456ec6971fb5026.1424974490@dev1429.prn1.facebook.com>
Download mbox | patch
Permalink /patch/7836/
State Superseded
Headers show

Comments

Mateusz Kwapich - Feb. 26, 2015, 6:14 p.m.
# HG changeset patch
# User Mateusz Kwapich <mitrandir@fb.com>
# Date 1421880324 28800
#      Wed Jan 21 14:45:24 2015 -0800
# Node ID e75e5456ec6971fb50263ca4526291d9a10ff01a
# 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, 8:42 p.m.
On Thu, 2015-02-26 at 10:14 -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 e75e5456ec6971fb50263ca4526291d9a10ff01a
> # Parent  ff5caa8dfd993680d9602ca6ebb14da9de10d5f4
> histedit: add a config allowing changing histedit rule line length limit
[snip]
> +Histedit rule lines are truncated to 80 characters by default. You can
> +customize this behaviour by setting histedit.linelen in your hg config
> +to desired length.

Sorry to bikeshed more, but I think the typical way to document such
features is to show what should be copied to the config file. I would
write,

    Histedit rule lines are truncated to 80 characters by default. You
    can customise this behaviour by setting a different length in your
    configuration file:

        [histedit]
        linelen = 120      # truncate rule lines at 120 characters

This appears to be the style in e.g. `hg help -e patchbomb`, `hg help
-e progress` or `hg help -e highlight`.
Gregory Szorc - Feb. 28, 2015, 2:33 a.m.
On Thu, Feb 26, 2015 at 12:42 PM, Jordi Gutiérrez Hermoso <
jordigh@octave.org> wrote:

> On Thu, 2015-02-26 at 10:14 -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 e75e5456ec6971fb50263ca4526291d9a10ff01a
> > # Parent  ff5caa8dfd993680d9602ca6ebb14da9de10d5f4
> > histedit: add a config allowing changing histedit rule line length limit
> [snip]
> > +Histedit rule lines are truncated to 80 characters by default. You can
> > +customize this behaviour by setting histedit.linelen in your hg config
> > +to desired length.
>
> Sorry to bikeshed more, but I think the typical way to document such
> features is to show what should be copied to the config file. I would
> write,
>
>     Histedit rule lines are truncated to 80 characters by default. You
>     can customise this behaviour by setting a different length in your
>     configuration file:
>
>         [histedit]
>         linelen = 120      # truncate rule lines at 120 characters
>
> This appears to be the style in e.g. `hg help -e patchbomb`, `hg help
> -e progress` or `hg help -e highlight`.
>

As I was writing some help patches a few weeks ago, I was trying to come up
with a way for config options related to extensions to be surfaced better.
The best I got was a separate docstring variable that could be inserted
into `hg help config`.

Another problem I've seen is that some core options aren't documented in
`hg help config` at all. I understand not wanting to expose some really
advanced options. But digging through source to discover hidden knobs is no
fun either. I don't want to say a registry of config options would be
useful. But it does solve a lot of problems for option discovery.
Pierre-Yves David - March 6, 2015, 1:28 a.m.
On 02/27/2015 06:33 PM, Gregory Szorc wrote:
> On Thu, Feb 26, 2015 at 12:42 PM, Jordi Gutiérrez Hermoso
> <jordigh@octave.org <mailto:jordigh@octave.org>> wrote:
>
>     On Thu, 2015-02-26 at 10:14 -0800, Mateusz Kwapich wrote:
>     > # HG changeset patch
>     > # User Mateusz Kwapich <mitrandir@fb.com <mailto:mitrandir@fb.com>>
>     > # Date 1421880324 28800
>     > #      Wed Jan 21 14:45:24 2015 -0800
>     > # Node ID e75e5456ec6971fb50263ca4526291d9a10ff01a
>     > # Parent  ff5caa8dfd993680d9602ca6ebb14da9de10d5f4
>     > histedit: add a config allowing changing histedit rule line length limit
>     [snip]
>     > +Histedit rule lines are truncated to 80 characters by default. You can
>     > +customize this behaviour by setting histedit.linelen in your hg config
>     > +to desired length.
>
>     Sorry to bikeshed more, but I think the typical way to document such
>     features is to show what should be copied to the config file. I would
>     write,
>
>          Histedit rule lines are truncated to 80 characters by default. You
>          can customise this behaviour by setting a different length in your
>          configuration file:
>
>              [histedit]
>              linelen = 120      # truncate rule lines at 120 characters
>
>     This appears to be the style in e.g. `hg help -e patchbomb`, `hg help
>     -e progress` or `hg help -e highlight`.
>
>
> As I was writing some help patches a few weeks ago, I was trying to come
> up with a way for config options related to extensions to be surfaced
> better. The best I got was a separate docstring variable that could be
> inserted into `hg help config`.
>
> Another problem I've seen is that some core options aren't documented in
> `hg help config` at all. I understand not wanting to expose some really
> advanced options. But digging through source to discover hidden knobs is
> no fun either. I don't want to say a registry of config options would be
> useful. But it does solve a lot of problems for option discovery.

I also feel like it would be useful to have some formal declaration of 
our config option.

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -142,6 +142,10 @@  If you run ``hg histedit --outgoing`` on
 as running ``hg histedit 836302820282``. If you need plan to push to a
 repository that Mercurial does not detect to be related to the source
 repo, you can add a ``--force`` option.
+
+Histedit rule lines are truncated to 80 characters by default. You can
+customize this behaviour by setting histedit.linelen in your hg config
+to desired length.
 """
 
 try:
@@ -638,7 +642,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 +809,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 +821,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', 'linelen', 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.