# HG changeset patch # User Pierre-Yves David # Date 1500837646 -7200 # Node ID ebca049e8ca9668188d332c79000e197a7366f08 # Parent ae690d39fc92ac5416c3048541ef71623d6a55af amend: use precheck to validate revision This gives us standard check and standard error message. diff --git a/hgext3rd/evolve/cmdrewrite.py b/hgext3rd/evolve/cmdrewrite.py --- a/hgext3rd/evolve/cmdrewrite.py +++ b/hgext3rd/evolve/cmdrewrite.py @@ -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() diff --git a/tests/test-sharing.t b/tests/test-sharing.t --- a/tests/test-sharing.t +++ b/tests/test-sharing.t @@ -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