[PATCH 3 of 4] histedit: clean abort when there is nothing to edit

Pierre-Yves David pierre-yves.david at ens-lyon.org
Sun Oct 14 17:05:45 CDT 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1350251882 -7200
# Node ID 5cc38d3be4551c945a42bf631200440bb308377f
# Parent  8aa4518d105cc56e78743464d1fb5daa9723bfd2
histedit: clean abort when there is nothing to edit

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -455,6 +455,9 @@
 
         keep = opts.get('keep', False)
         revs = between(repo, parent, topmost, keep)
+        if not revs:
+            ui.warn(_('nothing to edit\n'))
+            return 1
 
         ctxs = [repo[r] for r in revs]
         rules = opts.get('commands', '')
@@ -588,7 +591,7 @@
 
     When keep is false, the specified set can't have children."""
     ctxs = list(repo.set('%n::%n', old, new))
-    if not keep:
+    if ctxs and not keep:
         if repo.revs('(%ld::) - (%ld + hidden())', ctxs, ctxs):
             raise util.Abort(_('cannot edit history that would orphan nodes'))
         root = min(ctxs)
diff --git a/tests/test-histedit-revspec.t b/tests/test-histedit-revspec.t
--- a/tests/test-histedit-revspec.t
+++ b/tests/test-histedit-revspec.t
@@ -60,3 +60,10 @@
   #
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
+Run on a revision not ancestors of the current working directory.
+
+  $ hg up 2
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg histedit -r 4
+  nothing to edit
+  [1]


More information about the Mercurial-devel mailing list