From patchwork Sat May 7 07:02:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2, of, 2, RFC] histedit: add experimental config for using the first word of the commit From: Sean Farley X-Patchwork-Id: 14964 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Sat, 07 May 2016 00:02:10 -0700 # HG changeset patch # User Sean Farley # 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