diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -717,6 +717,7 @@ def verifyrules(rules, repo, ctxs): """ parsed = [] expected = set(str(c) for c in ctxs) + seen = set() if len(rules) != len(expected): raise util.Abort(_('must specify a rule for each changeset once')) for r in rules: @@ -731,6 +732,9 @@ def verifyrules(rules, repo, ctxs): if ha not in expected: raise util.Abort( _('may not use changesets other than the ones listed')) + if ha in seen: + raise util.Abort(_('duplicated command for changeset %s') % ha) + seen.add(ha) if action not in actiontable: raise util.Abort(_('unknown action "%s"') % action) parsed.append([action, ha]) 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 @@ -124,6 +124,19 @@ Test unknown command abort: unknown action "coin" [255] +Test duplicated changeset +--------------------------------------- + +So one is missing and one appear twice. + + $ HGEDITOR=cat hg histedit "tip^^" --commands - << EOF + > pick eb57da33312f 2 three + > pick eb57da33312f 2 three + > pick 08d98a8350f3 4 five + > EOF + abort: duplicated command for changeset eb57da33312f + [255] + Test short version of command ---------------------------------------