D8285: fix: refactor getrevstofix() to define revisions first, then validate them

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Tue Mar 17 03:04:12 UTC 2020


Closed by commit rHG368f85c5dfc0: fix: refactor getrevstofix() to define revisions first, then validate them (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8285?vs=20799&id=20804

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

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

AFFECTED FILES
  hgext/fix.py

CHANGE DETAILS

diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -400,15 +400,16 @@
 def getrevstofix(ui, repo, opts):
     """Returns the set of revision numbers that should be fixed"""
     revs = set(scmutil.revrange(repo, opts[b'rev']))
+    if opts.get(b'working_dir'):
+        revs.add(wdirrev)
     for rev in revs:
         checkfixablectx(ui, repo, repo[rev])
-    if revs:
+    # Allow fixing only wdir() even if there's an unfinished operation
+    if not (len(revs) == 1 and wdirrev in revs):
         cmdutil.checkunfinished(repo)
         rewriteutil.precheck(repo, revs, b'fix')
-    if opts.get(b'working_dir'):
-        revs.add(wdirrev)
-        if list(merge.mergestate.read(repo).unresolved()):
-            raise error.Abort(b'unresolved conflicts', hint=b"use 'hg resolve'")
+    if wdirrev in revs and list(merge.mergestate.read(repo).unresolved()):
+        raise error.Abort(b'unresolved conflicts', hint=b"use 'hg resolve'")
     if not revs:
         raise error.Abort(
             b'no changesets specified', hint=b'use --rev or --working-dir'



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


More information about the Mercurial-devel mailing list