Patchwork D7687: fix: use rewriteutil.precheck() instead of reimplementing it

login
register
mail settings
Submitter phabricator
Date Dec. 18, 2019, 6:48 a.m.
Message ID <d1f1a6ead974fbd461ee4a7617cc75ae@localhost.localdomain>
Download mbox | patch
Permalink /patch/43971/
State Not Applicable
Headers show

Comments

phabricator - Dec. 18, 2019, 6:48 a.m.
Closed by commit rHG699d6be3820a: fix: use rewriteutil.precheck() instead of reimplementing it (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7687?vs=18831&id=18862

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7687/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7687

AFFECTED FILES
  hgext/fix.py
  tests/test-fix.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers, pulkit
Cc: mercurial-devel

Patch

diff --git a/tests/test-fix.t b/tests/test-fix.t
--- a/tests/test-fix.t
+++ b/tests/test-fix.t
@@ -264,10 +264,12 @@ 
   $ hg commit -Aqm "hello"
   $ hg phase -r 0 --public
   $ hg fix -r 0
-  abort: can't fix immutable changeset 0:6470986d2e7b
+  abort: cannot fix public changesets
+  (see 'hg help phases' for details)
   [255]
   $ hg fix -r 0 --working-dir
-  abort: can't fix immutable changeset 0:6470986d2e7b
+  abort: cannot fix public changesets
+  (see 'hg help phases' for details)
   [255]
   $ hg cat -r tip hello.whole
   hello
@@ -1171,7 +1173,7 @@ 
   $ printf "two\n" > foo.whole
   $ hg commit -m "second"
   $ hg --config experimental.evolution.allowunstable=False fix -r '.^'
-  abort: can only fix a changeset together with all its descendants
+  abort: cannot fix changeset with children
   [255]
   $ hg fix -r '.^'
   1 new orphan changesets
diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -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(