comparison hgext/fix.py @ 44561:368f85c5dfc0

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
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 12 Dec 2019 16:24:43 -0800
parents 40f4a75938ba
children 9f5e94bbc606
comparison
equal deleted inserted replaced
44560:40f4a75938ba 44561:368f85c5dfc0
398 398
399 399
400 def getrevstofix(ui, repo, opts): 400 def getrevstofix(ui, repo, opts):
401 """Returns the set of revision numbers that should be fixed""" 401 """Returns the set of revision numbers that should be fixed"""
402 revs = set(scmutil.revrange(repo, opts[b'rev'])) 402 revs = set(scmutil.revrange(repo, opts[b'rev']))
403 if opts.get(b'working_dir'):
404 revs.add(wdirrev)
403 for rev in revs: 405 for rev in revs:
404 checkfixablectx(ui, repo, repo[rev]) 406 checkfixablectx(ui, repo, repo[rev])
405 if revs: 407 # Allow fixing only wdir() even if there's an unfinished operation
408 if not (len(revs) == 1 and wdirrev in revs):
406 cmdutil.checkunfinished(repo) 409 cmdutil.checkunfinished(repo)
407 rewriteutil.precheck(repo, revs, b'fix') 410 rewriteutil.precheck(repo, revs, b'fix')
408 if opts.get(b'working_dir'): 411 if wdirrev in revs and list(merge.mergestate.read(repo).unresolved()):
409 revs.add(wdirrev) 412 raise error.Abort(b'unresolved conflicts', hint=b"use 'hg resolve'")
410 if list(merge.mergestate.read(repo).unresolved()):
411 raise error.Abort(b'unresolved conflicts', hint=b"use 'hg resolve'")
412 if not revs: 413 if not revs:
413 raise error.Abort( 414 raise error.Abort(
414 b'no changesets specified', hint=b'use --rev or --working-dir' 415 b'no changesets specified', hint=b'use --rev or --working-dir'
415 ) 416 )
416 return revs 417 return revs