[PATCH 1 of 6] histedit: move autoverb logic from torule to ruleeditor
Sean Farley
sean at farley.io
Tue Jun 21 23:32:41 UTC 2016
# HG changeset patch
# User Sean Farley <sean at farley.io>
# Date 1464306370 25200
# Thu May 26 16:46:10 2016 -0700
# Node ID 01212d1f93a2a6c5c736dc0c7d45ffd1930e5c2f
# Parent aa1d56003872cba207d908706da059141dd901a5
# EXP-Topic autoverb
histedit: move autoverb logic from torule to ruleeditor
This is needed for an upcoming change that will automatically rearrange the
rules based on the commit message.
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -421,18 +421,10 @@ 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
@@ -1315,10 +1307,24 @@ def between(repo, old, new, keep):
def ruleeditor(repo, ui, actions, editcomment=""):
"""open an editor to edit rules
rules are in the format [ [act, ctx], ...] like in state.rules
"""
+ if repo.ui.configbool("experimental", "histedit.autoverb"):
+ for act in actions:
+ ctx = repo[act.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 fword.endswith('!'):
+ fword = fword[:-1]
+ if fword in primaryactions | secondaryactions | tertiaryactions:
+ act.verb = fword
+
rules = '\n'.join([act.torule(initial=True) for act in actions])
rules += '\n\n'
rules += editcomment
rules = ui.edit(rules, ui.username(), {'prefix': 'histedit'})
More information about the Mercurial-devel
mailing list