mercurial/commands.py
changeset 35244 98f97eb20597
parent 35225 7ce0ba3a1c32
child 35352 920cca6c8462
--- a/mercurial/commands.py	Fri Nov 24 03:44:50 2017 +0530
+++ b/mercurial/commands.py	Tue Nov 28 05:50:45 2017 +0530
@@ -49,6 +49,7 @@
     rcutil,
     registrar,
     revsetlang,
+    rewriteutil,
     scmutil,
     server,
     sshserver,
@@ -1541,13 +1542,7 @@
             raise error.Abort(_('cannot amend with ui.commitsubrepos enabled'))
 
         old = repo['.']
-        if not old.mutable():
-            raise error.Abort(_('cannot amend public changesets'))
-        if len(repo[None].parents()) > 1:
-            raise error.Abort(_('cannot amend while merging'))
-        allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
-        if not allowunstable and old.children():
-            raise error.Abort(_('cannot amend changeset with children'))
+        rewriteutil.precheck(repo, [old.rev()], 'amend')
 
         # Currently histedit gets confused if an amend happens while histedit
         # is in progress. Since we have a checkunfinished command, we are