Patchwork [2,of,2,RFC] histedit: add experimental config for using the first word of the commit

login
register
mail settings
Submitter Sean Farley
Date May 7, 2016, 7:02 a.m.
Message ID <dd7915236f69edd5f779.1462604530@laptop.local>
Download mbox | patch
Permalink /patch/14964/
State Superseded
Commit ceca932c080d0de52ece0e8dd0226f006c7b9cb1
Headers show

Comments

Sean Farley - May 7, 2016, 7:02 a.m.
# HG changeset patch
# User Sean Farley <sean@farley.io>
# Date 1462583556 25200
#      Fri May 06 18:12:36 2016 -0700
# Node ID dd7915236f69edd5f779faec20bd08308a89ed27
# Parent  d4c7748adeeadbb736376a57030c5255f3ac8bfb
# EXP-Topic histedit-auto
histedit: add experimental config for using the first word of the commit

This allows users to start a commit with "roll! foo bar" so that when this is
opened in histedit, the default action will be "roll". Currently, we'll allow
any known verb to be used but this is experimental.
Jun Wu - May 7, 2016, 11:20 p.m.
I like the idea and this looks good to me.

"autohistedit" sounds a bit too broad. But it's in "experimental" so doesn't
matter much. When we move it to "histedit" I vote something like
"histedit.autoverb".


On 05/07/2016 08:02 AM, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean@farley.io>
> # Date 1462583556 25200
> #      Fri May 06 18:12:36 2016 -0700
> # Node ID dd7915236f69edd5f779faec20bd08308a89ed27
> # Parent  d4c7748adeeadbb736376a57030c5255f3ac8bfb
> # EXP-Topic histedit-auto
> histedit: add experimental config for using the first word of the commit
>
> This allows users to start a commit with "roll! foo bar" so that when this is
> opened in histedit, the default action will be "roll". Currently, we'll allow
> any known verb to be used but this is experimental.
>
> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -416,10 +416,18 @@ class histeditaction(object):
>          """
>          ctx = self.repo[self.node]
>          summary = ''
>          if ctx.description():
>              summary = ctx.description().splitlines()[0]
> +
> +        fword = summary.split(' ', 1)[0].lower()
> +        # if it doesn't end with the special character '!' just skip this
> +        if (self.repo.ui.configbool("experimental", "autohistedit") and
> +            initial and fword.endswith('!')):
> +            fword = fword[:-1]
> +            if fword in primaryactions | secondaryactions | tertiaryactions:
> +                self.verb = fword
>          line = '%s %s %d %s' % (self.verb, ctx, ctx.rev(), summary)
>          # trim to 75 columns by default so it's not stupidly wide in my editor
>          # (the 5 more are left for verb)
>          maxlen = self.repo.ui.configint('histedit', 'linelen', default=80)
>          maxlen = max(maxlen, 22) # avoid truncating hash
Sean Farley - May 8, 2016, 12:48 a.m.
Jun Wu <quark@fb.com> writes:

> I like the idea and this looks good to me.

Thanks!

> "autohistedit" sounds a bit too broad. But it's in "experimental" so doesn't
> matter much. When we move it to "histedit" I vote something like
> "histedit.autoverb".

Sure, autoverb sounds fine to me (fine with me to name it
experimental.autoverb since that seems fairly unique).
Augie Fackler - May 11, 2016, 1:37 a.m.
On Sat, May 07, 2016 at 05:48:25PM -0700, Sean Farley wrote:
>
> Jun Wu <quark@fb.com> writes:
>
> > I like the idea and this looks good to me.
>
> Thanks!
>
> > "autohistedit" sounds a bit too broad. But it's in "experimental" so doesn't
> > matter much. When we move it to "histedit" I vote something like
> > "histedit.autoverb".
>
> Sure, autoverb sounds fine to me (fine with me to name it
> experimental.autoverb since that seems fairly unique).

I also like where it's going, and have considered writing the feature
myself at times. Can I get a v2 with tests?

As for the color to paint the bikeshed, can I interest you in
experimental.histedit.autoverb? That seems the most explicit for now,
I guess.

> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
timeless - May 11, 2016, 3:10 a.m.
On Tue, May 10, 2016 at 9:37 PM, Augie Fackler <raf@durin42.com> wrote:
>
> As for the color to paint the bikeshed, can I interest you in
> experimental.histedit.autoverb? That seems the most explicit for now,

how about commitverb?

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -416,10 +416,18 @@  class histeditaction(object):
         """
         ctx = self.repo[self.node]
         summary = ''
         if ctx.description():
             summary = ctx.description().splitlines()[0]
+
+        fword = summary.split(' ', 1)[0].lower()
+        # if it doesn't end with the special character '!' just skip this
+        if (self.repo.ui.configbool("experimental", "autohistedit") and
+            initial and fword.endswith('!')):
+            fword = fword[:-1]
+            if fword in primaryactions | secondaryactions | tertiaryactions:
+                self.verb = fword
         line = '%s %s %d %s' % (self.verb, ctx, ctx.rev(), summary)
         # trim to 75 columns by default so it's not stupidly wide in my editor
         # (the 5 more are left for verb)
         maxlen = self.repo.ui.configint('histedit', 'linelen', default=80)
         maxlen = max(maxlen, 22) # avoid truncating hash