# HG changeset patch # User Pierre-Yves David # Date 1366291344 -7200 # Node ID 81de87f8b4801b3e53c995ee59f94db1d94e1222 # Parent 36adbbe960caefd8501a849c764a04c94b357aff histedit: protect against duplicated entries Before this change one would issue rules with duplicated entries. For this to happen some other changeset had to be missing to maintain the rules length. diff -r 36adbbe960ca -r 81de87f8b480 hgext/histedit.py --- a/hgext/histedit.py Thu Apr 18 15:13:35 2013 +0200 +++ b/hgext/histedit.py Thu Apr 18 15:22:24 2013 +0200 @@ -717,6 +717,7 @@ """ 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 @@ 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 -r 36adbbe960ca -r 81de87f8b480 tests/test-histedit-arguments.t --- a/tests/test-histedit-arguments.t Thu Apr 18 15:13:35 2013 +0200 +++ b/tests/test-histedit-arguments.t Thu Apr 18 15:22:24 2013 +0200 @@ -124,6 +124,19 @@ 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 ---------------------------------------