hgext/fix.py
changeset 48116 5ced12cfa41b
parent 47924 66ff8d3865b3
child 48178 f12a19d03d2c
equal deleted inserted replaced
48115:b067d22dc6ad 48116:5ced12cfa41b
   142 from mercurial import (
   142 from mercurial import (
   143     cmdutil,
   143     cmdutil,
   144     context,
   144     context,
   145     copies,
   145     copies,
   146     error,
   146     error,
       
   147     logcmdutil,
   147     match as matchmod,
   148     match as matchmod,
   148     mdiff,
   149     mdiff,
   149     merge,
   150     merge,
   150     mergestate as mergestatemod,
   151     mergestate as mergestatemod,
   151     obsolete,
   152     obsolete,
   418 def getrevstofix(ui, repo, opts):
   419 def getrevstofix(ui, repo, opts):
   419     """Returns the set of revision numbers that should be fixed"""
   420     """Returns the set of revision numbers that should be fixed"""
   420     if opts[b'all']:
   421     if opts[b'all']:
   421         revs = repo.revs(b'(not public() and not obsolete()) or wdir()')
   422         revs = repo.revs(b'(not public() and not obsolete()) or wdir()')
   422     elif opts[b'source']:
   423     elif opts[b'source']:
   423         source_revs = scmutil.revrange(repo, opts[b'source'])
   424         source_revs = logcmdutil.revrange(repo, opts[b'source'])
   424         revs = set(repo.revs(b'(%ld::) - obsolete()', source_revs))
   425         revs = set(repo.revs(b'(%ld::) - obsolete()', source_revs))
   425         if wdirrev in source_revs:
   426         if wdirrev in source_revs:
   426             # `wdir()::` is currently empty, so manually add wdir
   427             # `wdir()::` is currently empty, so manually add wdir
   427             revs.add(wdirrev)
   428             revs.add(wdirrev)
   428         if repo[b'.'].rev() in revs:
   429         if repo[b'.'].rev() in revs:
   429             revs.add(wdirrev)
   430             revs.add(wdirrev)
   430     else:
   431     else:
   431         revs = set(scmutil.revrange(repo, opts[b'rev']))
   432         revs = set(logcmdutil.revrange(repo, opts[b'rev']))
   432         if opts.get(b'working_dir'):
   433         if opts.get(b'working_dir'):
   433             revs.add(wdirrev)
   434             revs.add(wdirrev)
   434         for rev in revs:
   435         for rev in revs:
   435             checkfixablectx(ui, repo, repo[rev])
   436             checkfixablectx(ui, repo, repo[rev])
   436     # Allow fixing only wdir() even if there's an unfinished operation
   437     # Allow fixing only wdir() even if there's an unfinished operation
   616     --whole is used.
   617     --whole is used.
   617     """
   618     """
   618     # The --base flag overrides the usual logic, and we give every revision
   619     # The --base flag overrides the usual logic, and we give every revision
   619     # exactly the set of baserevs that the user specified.
   620     # exactly the set of baserevs that the user specified.
   620     if opts.get(b'base'):
   621     if opts.get(b'base'):
   621         baserevs = set(scmutil.revrange(repo, opts.get(b'base')))
   622         baserevs = set(logcmdutil.revrange(repo, opts.get(b'base')))
   622         if not baserevs:
   623         if not baserevs:
   623             baserevs = {nullrev}
   624             baserevs = {nullrev}
   624         basectxs = {repo[rev] for rev in baserevs}
   625         basectxs = {repo[rev] for rev in baserevs}
   625         return {rev: basectxs for rev in revstofix}
   626         return {rev: basectxs for rev in revstofix}
   626 
   627