precheck: handle rewrite attempt of nullrev
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 24 Jul 2017 01:45:03 +0200
changeset 2785 b5a48e4aeec6
parent 2784 d17d193c4145
child 2786 ae690d39fc92
precheck: handle rewrite attempt of nullrev This is a common breaking case, so we handle and test it in the generic code.
hgext3rd/evolve/rewriteutil.py
tests/test-fold.t
--- a/hgext3rd/evolve/rewriteutil.py	Sun Jul 23 19:45:28 2017 +0200
+++ b/hgext3rd/evolve/rewriteutil.py	Mon Jul 24 01:45:03 2017 +0200
@@ -60,6 +60,10 @@
 
     <action> can be used to control the commit message.
     """
+    if node.nullrev in revs:
+        msg = _("cannot %s the null revision") % (action)
+        hint = _("no changeset checked out")
+        raise error.Abort(msg, hint=hint)
     publicrevs = repo.revs('%ld and public()', revs)
     if publicrevs:
         summary = _formatrevs(repo, publicrevs)
--- a/tests/test-fold.t	Sun Jul 23 19:45:28 2017 +0200
+++ b/tests/test-fold.t	Mon Jul 24 01:45:03 2017 +0200
@@ -42,6 +42,10 @@
 
 Test various error case
 
+  $ hg fold --exact null::
+  abort: cannot fold the null revision
+  (no changeset checked out)
+  [255]
   $ hg fold
   abort: no revisions specified
   [255]