amend: use precheck to validate revision
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sun, 23 Jul 2017 21:20:46 +0200
changeset 2787 ebca049e8ca9
parent 2786 ae690d39fc92
child 2788 554c069cdc85
amend: use precheck to validate revision This gives us standard check and standard error message.
hgext3rd/evolve/cmdrewrite.py
tests/test-sharing.t
--- a/hgext3rd/evolve/cmdrewrite.py	Sun Jul 23 20:33:19 2017 +0200
+++ b/hgext3rd/evolve/cmdrewrite.py	Sun Jul 23 21:20:46 2017 +0200
@@ -114,7 +114,13 @@
             opts['message'] = repo['.'].description()
         _resolveoptions(ui, opts)
         _alias, commitcmd = cmdutil.findcmd('commit', commands.table)
-        return commitcmd[0](ui, repo, *pats, **opts)
+        try:
+            wlock = repo.wlock()
+            lock = repo.lock()
+            rewriteutil.precheck(repo, [repo['.'].rev()], action='amend')
+            return commitcmd[0](ui, repo, *pats, **opts)
+        finally:
+            lockmod.release(lock, wlock)
 
 def _touchedbetween(repo, source, dest, match=None):
     touched = set()
--- a/tests/test-sharing.t	Sun Jul 23 20:33:19 2017 +0200
+++ b/tests/test-sharing.t	Sun Jul 23 21:20:46 2017 +0200
@@ -147,7 +147,8 @@
 
 Now that the fix is public, we cannot amend it any more.
   $ hg amend -m 'fix bug 37'
-  abort: cannot amend public changesets
+  abort: cannot amend public changesets: de6151c48e1c
+  (see 'hg help phases' for details)
   [255]
 
 Figure SG05