comparison hgext/histedit.py @ 19047:81de87f8b480

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.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Thu, 18 Apr 2013 15:22:24 +0200
parents 36adbbe960ca
children 1163ff06ce89
comparison
equal deleted inserted replaced
19046:36adbbe960ca 19047:81de87f8b480
715 Will abort if there are to many or too few rules, a malformed rule, 715 Will abort if there are to many or too few rules, a malformed rule,
716 or a rule on a changeset outside of the user-given range. 716 or a rule on a changeset outside of the user-given range.
717 """ 717 """
718 parsed = [] 718 parsed = []
719 expected = set(str(c) for c in ctxs) 719 expected = set(str(c) for c in ctxs)
720 seen = set()
720 if len(rules) != len(expected): 721 if len(rules) != len(expected):
721 raise util.Abort(_('must specify a rule for each changeset once')) 722 raise util.Abort(_('must specify a rule for each changeset once'))
722 for r in rules: 723 for r in rules:
723 if ' ' not in r: 724 if ' ' not in r:
724 raise util.Abort(_('malformed line "%s"') % r) 725 raise util.Abort(_('malformed line "%s"') % r)
729 except error.RepoError: 730 except error.RepoError:
730 raise util.Abort(_('unknown changeset %s listed') % ha) 731 raise util.Abort(_('unknown changeset %s listed') % ha)
731 if ha not in expected: 732 if ha not in expected:
732 raise util.Abort( 733 raise util.Abort(
733 _('may not use changesets other than the ones listed')) 734 _('may not use changesets other than the ones listed'))
735 if ha in seen:
736 raise util.Abort(_('duplicated command for changeset %s') % ha)
737 seen.add(ha)
734 if action not in actiontable: 738 if action not in actiontable:
735 raise util.Abort(_('unknown action "%s"') % action) 739 raise util.Abort(_('unknown action "%s"') % action)
736 parsed.append([action, ha]) 740 parsed.append([action, ha])
737 return parsed 741 return parsed
738 742