fix: refactor getrevstofix() to define revisions first, then validate them
This refactoring makes it easier to add a new way of specifying
revisions (I'm about to add a `--source`, which adds the specified
revisions and their descendants).
Differential Revision: https://phab.mercurial-scm.org/D8285
--- a/hgext/fix.py Fri Dec 13 15:14:57 2019 -0800
+++ b/hgext/fix.py Thu Dec 12 16:24:43 2019 -0800
@@ -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'