Patchwork [10,of,10] histedit: more precise user message when changeset is missing

login
register
mail settings
Submitter Pierre-Yves David
Date April 18, 2013, 3:29 p.m.
Message ID <2b48b445e5a02a6a62de.1366298965@crater2.logilab.fr>
Download mbox | patch
Permalink /patch/1423/
State Accepted
Commit 1163ff06ce897e6be7b336f535b29d47449418c6
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 1366291670 -7200
#      Thu Apr 18 15:27:50 2013 +0200
# Node ID 2b48b445e5a02a6a62defc1983a2b88b548df284
# Parent  9de585ccdbc97f1e6cb551a086d4087e2c208ca3
histedit: more precise user message when changeset is missing

Now that we explicitly detect duplicated changeset, we can explicitly detect
missing one. We cover the same case than before, some other and we offer a
better error message in all case.

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -716,12 +716,10 @@  def verifyrules(rules, repo, ctxs):
     or a rule on a changeset outside of the user-given range.
     """
     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:
         if ' ' not in r:
             raise util.Abort(_('malformed line "%s"') % r)
         action, rest = r.split(' ', 1)
         ha = rest.strip().split(' ', 1)[0]
@@ -736,10 +734,14 @@  def verifyrules(rules, repo, ctxs):
             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])
+    missing = sorted(expected - seen)  # sort to stabilize output
+    if missing:
+        raise util.Abort(_('missing rules for changeset %s') % missing[0],
+                         hint=_('do you want to use the drop action?'))
     return parsed
 
 def processreplacement(repo, replacements):
     """process the list of replacements to return
 
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
@@ -75,11 +75,12 @@  Test that missing revision are detected
 
   $ HGEDITOR=cat hg histedit "tip^^" --commands - << EOF
   > pick eb57da33312f 2 three
   > pick 08d98a8350f3 4 five
   > EOF
-  abort: must specify a rule for each changeset once
+  abort: missing rules for changeset c8e68270e35a
+  (do you want to use the drop action?)
   [255]
 
 Test that extra revision are detected
 ---------------------------------------