diff --git a/hgext/histedit.py b/hgext/histedit.py
index ffa194c3a83c8952802f789da93c884e4c4b4e09_aGdleHQvaGlzdGVkaXQucHk=..2ff243c415b43440af82fa3e965105205eff9ee4_aGdleHQvaGlzdGVkaXQucHk= 100644
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1316,7 +1316,8 @@
     rules are in the format [ [act, ctx], ...] like in state.rules
     """
     if repo.ui.configbool("experimental", "histedit.autoverb"):
+        newact = util.sortdict()
         for act in actions:
             ctx = repo[act.node]
             summary = _getsummary(ctx)
             fword = summary.split(' ', 1)[0].lower()
@@ -1319,9 +1320,11 @@
         for act in actions:
             ctx = repo[act.node]
             summary = _getsummary(ctx)
             fword = summary.split(' ', 1)[0].lower()
+            added = False
+
             # 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
@@ -1323,8 +1326,28 @@
             # 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
+                    # get the target summary
+                    tsum = summary[len(fword) + 1:].lstrip()
+                    # safe but slow: reverse iterate over the actions so we
+                    # don't clash on two commits having the same summary
+                    for na, l in reversed(list(newact.iteritems())):
+                        actx = repo[na.node]
+                        asum = _getsummary(actx)
+                        if asum == tsum:
+                            added = True
+                            l.append(act)
+                            break
+
+            if not added:
+                newact[act] = []
+
+        # copy over and flatten the new list
+        actions = []
+        for na, l in newact.iteritems():
+            actions.append(na)
+            actions += l
 
     rules = '\n'.join([act.torule() for act in actions])
     rules += '\n\n'
diff --git a/tests/test-histedit-arguments.t b/tests/test-histedit-arguments.t
index ffa194c3a83c8952802f789da93c884e4c4b4e09_dGVzdHMvdGVzdC1oaXN0ZWRpdC1hcmd1bWVudHMudA==..2ff243c415b43440af82fa3e965105205eff9ee4_dGVzdHMvdGVzdC1oaXN0ZWRpdC1hcmd1bWVudHMudA== 100644
--- a/tests/test-histedit-arguments.t
+++ b/tests/test-histedit-arguments.t
@@ -507,7 +507,5 @@
   $ hg init autoverb
   $ cd autoverb
   $ echo alpha >> alpha
-  $ hg addr
-  adding alpha
-  $ hg ci -m one
+  $ hg ci -qAm one
   $ echo alpha >> alpha
@@ -513,6 +511,6 @@
   $ echo alpha >> alpha
-  $ hg ci -m two
-  $ echo alpha >> alpha
-  $ hg ci -m "roll! three"
+  $ hg ci -qm two
+  $ echo beta >> beta
+  $ hg ci -qAm "roll! one"
 
   $ hg log --style compact --graph
@@ -517,7 +515,7 @@
 
   $ hg log --style compact --graph
-  @  2[tip]   1b0b0b04c8fe   1970-01-01 00:00 +0000   test
-  |    roll! three
+  @  2[tip]   4f34d0f8b5fa   1970-01-01 00:00 +0000   test
+  |    roll! one
   |
   o  1   579e40513370   1970-01-01 00:00 +0000   test
   |    two
@@ -528,5 +526,7 @@
 
 Check that 'roll' is selected by default
 
-  $ HGEDITOR=cat hg histedit 1 --config experimental.histedit.autoverb=True
+  $ HGEDITOR=cat hg histedit 0 --config experimental.histedit.autoverb=True
+  pick 6058cbb6cfd7 0 one
+  roll 4f34d0f8b5fa 2 roll! one
   pick 579e40513370 1 two
@@ -532,3 +532,2 @@
   pick 579e40513370 1 two
-  roll 1b0b0b04c8fe 2 roll! three
   
@@ -534,5 +533,5 @@
   
-  # Edit history between 579e40513370 and 1b0b0b04c8fe
+  # Edit history between 6058cbb6cfd7 and 4f34d0f8b5fa
   #
   # Commits are listed from least to most recent
   #