[PATCH 2 of 2 V2] histedit: add experimental config for using the first word of the commit

Sean Farley sean at farley.io
Tue May 24 16:28:27 EDT 2016


Martin von Zweigbergk <martinvonz at google.com> writes:

> On Tue, May 17, 2016 at 4:12 PM, Sean Farley <sean at farley.io> wrote:
>> # HG changeset patch
>> # User Sean Farley <sean at farley.io>
>> # Date 1462583556 25200
>> #      Fri May 06 18:12:36 2016 -0700
>> # Node ID 75fc0323200de860fafc4203714f334224673af4
>> # 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 "verb! ..." so that when this is
>> opened in histedit, the default action will be "verb". For example, "roll! foo"
>> will default to the action "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", "histedit.autoverb") 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
>> diff --git a/tests/test-histedit-arguments.t b/tests/test-histedit-arguments.t
>> --- a/tests/test-histedit-arguments.t
>> +++ b/tests/test-histedit-arguments.t
>> @@ -497,5 +497,55 @@ amend should not be blocked by the ongoi
>>    > [experimental]
>>    > evolution=createmarkers,allowunstable
>>    > EOF
>>    $ hg commit --amend -m 'allow this fold'
>>    $ hg histedit --continue
>> +
>> +  $ cd ..
>> +
>> +Test autoverb feature
>> +
>> +  $ hg init autoverb
>> +  $ cd autoverb
>> +  $ echo alpha >> alpha
>> +  $ hg addr
>> +  adding alpha
>> +  $ hg ci -m one
>> +  $ echo alpha >> alpha
>> +  $ hg ci -m two
>> +  $ echo alpha >> alpha
>> +  $ hg ci -m "roll! three"
>
> Having used git before, I would expect "roll! one" to tell histedit to
> also apply this patch efter the one with commit message (starting
> with) "one". Future plans?

Sure, that sounds cool. What happens with multiple commit messages? e.g.

one
two
roll! one
roll! one

?


More information about the Mercurial-devel mailing list