# HG changeset patch # User Pierre-Yves David # Date 1350251882 -7200 # Node ID d9da327516f88729d9e47cfa6e69554c1fb0cc58 # Parent ef7760f0be879926507fd932700bd9bf7ca69456 histedit: clean abort when there is nothing to edit diff -r ef7760f0be87 -r d9da327516f8 hgext/histedit.py --- 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) diff -r ef7760f0be87 -r d9da327516f8 tests/test-histedit-revspec.t --- a/tests/test-histedit-revspec.t Mon Oct 15 00:05:16 2012 +0200 +++ b/tests/test-histedit-revspec.t Sun Oct 14 23:58:02 2012 +0200 @@ -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]