diff hgext/uncommit.py @ 35253:98f97eb20597

rewriteutil: use precheck() in uncommit and amend commands Differential Revision: https://phab.mercurial-scm.org/D1526
author Pulkit Goyal <7895pulkit@gmail.com>
date Tue, 28 Nov 2017 05:50:45 +0530
parents 9e339c97fabb
children 8a0cac20a1ad
line wrap: on
line diff
--- a/hgext/uncommit.py	Fri Nov 24 03:44:50 2017 +0530
+++ b/hgext/uncommit.py	Tue Nov 28 05:50:45 2017 +0530
@@ -28,10 +28,10 @@
     copies,
     error,
     node,
-    obsolete,
     obsutil,
     pycompat,
     registrar,
+    rewriteutil,
     scmutil,
 )
 
@@ -155,23 +155,14 @@
     opts = pycompat.byteskwargs(opts)
 
     with repo.wlock(), repo.lock():
-        wctx = repo[None]
 
         if not pats and not repo.ui.configbool('experimental',
                                                 'uncommitondirtywdir'):
             cmdutil.bailifchanged(repo)
-        if wctx.parents()[0].node() == node.nullid:
-            raise error.Abort(_("cannot uncommit null changeset"))
-        if len(wctx.parents()) > 1:
-            raise error.Abort(_("cannot uncommit while merging"))
         old = repo['.']
-        if not old.mutable():
-            raise error.Abort(_('cannot uncommit public changesets'))
+        rewriteutil.precheck(repo, [old.rev()], 'uncommit')
         if len(old.parents()) > 1:
             raise error.Abort(_("cannot uncommit merge changeset"))
-        allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
-        if not allowunstable and old.children():
-            raise error.Abort(_('cannot uncommit changeset with children'))
 
         with repo.transaction('uncommit'):
             match = scmutil.match(old, pats, opts)