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

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Thu Apr 18 10:29:23 CDT 2013


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at 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.

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])


More information about the Mercurial-devel mailing list