changeset 29465:00d2bf4137e6

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. Before this patch, the autoverb logic only applied to one rule at a time. This moves that logic one step up so that it can iterate over all the rules and rearrange as needed.
author Sean Farley <sean@farley.io>
date Thu, 26 May 2016 16:46:10 -0700
parents 87c184c9bfef
children a0efbfbba7b5
files hgext/histedit.py
diffstat 1 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/histedit.py	Thu Jun 30 13:06:19 2016 -0700
+++ b/hgext/histedit.py	Thu May 26 16:46:10 2016 -0700
@@ -423,14 +423,6 @@
         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)
@@ -1317,6 +1309,20 @@
 
     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