Patchwork [08,of,10] histedit: track short hash instead of changectx object

login
register
mail settings
Submitter Pierre-Yves David
Date April 18, 2013, 3:29 p.m.
Message ID <5f2a7385734ad42ee819.1366298963@crater2.logilab.fr>
Download mbox | patch
Permalink /patch/1420/
State Accepted
Commit 36adbbe960caefd8501a849c764a04c94b357aff
Headers show

Comments

Pierre-Yves David - April 18, 2013, 3:29 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1366290815 -7200
#      Thu Apr 18 15:13:35 2013 +0200
# Node ID 5f2a7385734ad42ee819ae82ea4354feca17ce76
# Parent  25fec4235b7161d2952dd4ad354e16a58f3708af
histedit: track short hash instead of changectx object

This simplify set usage and allow use add missing check in later commit.

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -714,22 +714,23 @@  def verifyrules(rules, repo, ctxs):
 
     Will abort if there are to many or too few rules, a malformed rule,
     or a rule on a changeset outside of the user-given range.
     """
     parsed = []
-    if len(rules) != len(ctxs):
+    expected = set(str(c) for c in ctxs)
+    if len(rules) != len(expected):
         raise util.Abort(_('must specify a rule for each changeset once'))
     for r in rules:
         if ' ' not in r:
             raise util.Abort(_('malformed line "%s"') % r)
         action, rest = r.split(' ', 1)
         ha = rest.strip().split(' ', 1)[0]
         try:
             ha = str(repo[ha])  # ensure its a short hash
         except error.RepoError:
             raise util.Abort(_('unknown changeset %s listed') % ha)
-        if repo[ha] not in ctxs:
+        if ha not in expected:
             raise util.Abort(
                 _('may not use changesets other than the ones listed'))
         if action not in actiontable:
             raise util.Abort(_('unknown action "%s"') % action)
         parsed.append([action, ha])