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

login
register
mail settings
Submitter phabricator
Date March 17, 2020, 2:10 a.m.
Message ID <161ec179a27ccd0d1f6477fcc7ec2406@localhost.localdomain>
Download mbox | patch
Permalink /patch/45795/
State Not Applicable
Headers show

Comments

phabricator - March 17, 2020, 2:10 a.m.
martinvonz updated this revision to Diff 20799.

REPOSITORY
  rHG Mercurial

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

BRANCH
  default

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




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

Patch

diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -399,15 +399,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'