diff hgext/fix.py @ 43936:699d6be3820a

fix: use rewriteutil.precheck() instead of reimplementing it Differential Revision: https://phab.mercurial-scm.org/D7687
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 17 Dec 2019 10:55:50 -0800
parents dda49ec2b54a
children eebdd6709868
line wrap: on
line diff
--- a/hgext/fix.py	Tue Dec 17 11:09:22 2019 -0800
+++ b/hgext/fix.py	Tue Dec 17 10:55:50 2019 -0800
@@ -144,9 +144,9 @@
     match as matchmod,
     mdiff,
     merge,
-    obsolete,
     pycompat,
     registrar,
+    rewriteutil,
     scmutil,
     util,
     worker,
@@ -403,7 +403,7 @@
         checkfixablectx(ui, repo, repo[rev])
     if revs:
         cmdutil.checkunfinished(repo)
-        checknodescendants(repo, revs)
+        rewriteutil.precheck(repo, revs, b'fix')
     if opts.get(b'working_dir'):
         revs.add(wdirrev)
         if list(merge.mergestate.read(repo).unresolved()):
@@ -415,22 +415,8 @@
     return revs
 
 
-def checknodescendants(repo, revs):
-    if not obsolete.isenabled(repo, obsolete.allowunstableopt) and repo.revs(
-        b'(%ld::) - (%ld)', revs, revs
-    ):
-        raise error.Abort(
-            _(b'can only fix a changeset together with all its descendants')
-        )
-
-
 def checkfixablectx(ui, repo, ctx):
     """Aborts if the revision shouldn't be replaced with a fixed one."""
-    if not ctx.mutable():
-        raise error.Abort(
-            b'can\'t fix immutable changeset %s'
-            % (scmutil.formatchangeid(ctx),)
-        )
     if ctx.obsolete():
         # It would be better to actually check if the revision has a successor.
         allowdivergence = ui.configbool(