diff hgext/histedit.py @ 43939:bde97bee321f

histedit: use rewriteutil.precheck() instead of reimplementing it We have had this nice utility since 490df753894d (rewriteutil: add a precheck function to check if revs can be rewritten, 2017-11-24). We got two callers soon thereafter, in 98f97eb20597 (rewriteutil: use precheck() in uncommit and amend commands, 2017-11-28). It's about time we use it in other places. rewriteutil.precheck() looks unfortunate for i18n (it seems to rely on an English verb for the action making sense in other languages), but hopefully not bad enough that we should avoid using it. Differential Revision: https://phab.mercurial-scm.org/D7684
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 17 Dec 2019 10:53:51 -0800
parents 29adf0a087a1
children 801b8d314791
line wrap: on
line diff
--- a/hgext/histedit.py	Thu Dec 12 23:25:16 2019 -0800
+++ b/hgext/histedit.py	Tue Dec 17 10:53:51 2019 -0800
@@ -230,6 +230,7 @@
     pycompat,
     registrar,
     repair,
+    rewriteutil,
     scmutil,
     state as statemod,
     util,
@@ -2306,23 +2307,9 @@
     When keep is false, the specified set can't have children."""
     revs = repo.revs(b'%n::%n', old, new)
     if revs and not keep:
-        if not obsolete.isenabled(
-            repo, obsolete.allowunstableopt
-        ) and repo.revs(b'(%ld::) - (%ld)', revs, revs):
-            raise error.Abort(
-                _(
-                    b'can only histedit a changeset together '
-                    b'with all its descendants'
-                )
-            )
+        rewriteutil.precheck(repo, revs, b'edit')
         if repo.revs(b'(%ld) and merge()', revs):
             raise error.Abort(_(b'cannot edit history that contains merges'))
-        root = repo[revs.first()]  # list is already sorted by repo.revs()
-        if not root.mutable():
-            raise error.Abort(
-                _(b'cannot edit public changeset: %s') % root,
-                hint=_(b"see 'hg help phases' for details"),
-            )
     return pycompat.maplist(repo.changelog.node, revs)