diff hgext/histedit.py @ 17766:d9da327516f8

histedit: clean abort when there is nothing to edit
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Sun, 14 Oct 2012 23:58:02 +0200
parents ef7760f0be87
children a787e46d3b94
line wrap: on
line diff
--- a/hgext/histedit.py	Mon Oct 15 00:05:16 2012 +0200
+++ b/hgext/histedit.py	Sun Oct 14 23:58:02 2012 +0200
@@ -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)