From patchwork Tue Mar 17 02:10:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D8285: fix: refactor getrevstofix() to define revisions first, then validate them From: phabricator X-Patchwork-Id: 45795 Message-Id: <161ec179a27ccd0d1f6477fcc7ec2406@localhost.localdomain> To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Tue, 17 Mar 2020 02:10:54 +0000 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 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'