Mercurial > hg
comparison mercurial/debugcommands.py @ 50951:44c29568898f
debugfileset: migrate `opts` to native kwargs
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 21 Aug 2023 17:12:03 -0400 |
parents | 5dc20e1f0518 |
children | 45381a1dd367 |
comparison
equal
deleted
inserted
replaced
50950:5dc20e1f0518 | 50951:44c29568898f |
---|---|
1567 def debugfileset(ui, repo, expr, **opts): | 1567 def debugfileset(ui, repo, expr, **opts): |
1568 '''parse and apply a fileset specification''' | 1568 '''parse and apply a fileset specification''' |
1569 from . import fileset | 1569 from . import fileset |
1570 | 1570 |
1571 fileset.symbols # force import of fileset so we have predicates to optimize | 1571 fileset.symbols # force import of fileset so we have predicates to optimize |
1572 opts = pycompat.byteskwargs(opts) | 1572 |
1573 ctx = logcmdutil.revsingle(repo, opts.get(b'rev'), None) | 1573 ctx = logcmdutil.revsingle(repo, opts.get('rev'), None) |
1574 | 1574 |
1575 stages = [ | 1575 stages = [ |
1576 (b'parsed', pycompat.identity), | 1576 (b'parsed', pycompat.identity), |
1577 (b'analyzed', filesetlang.analyze), | 1577 (b'analyzed', filesetlang.analyze), |
1578 (b'optimized', filesetlang.optimize), | 1578 (b'optimized', filesetlang.optimize), |
1579 ] | 1579 ] |
1580 stagenames = {n for n, f in stages} | 1580 stagenames = {n for n, f in stages} |
1581 | 1581 |
1582 showalways = set() | 1582 showalways = set() |
1583 if ui.verbose and not opts[b'show_stage']: | 1583 if ui.verbose and not opts['show_stage']: |
1584 # show parsed tree by --verbose (deprecated) | 1584 # show parsed tree by --verbose (deprecated) |
1585 showalways.add(b'parsed') | 1585 showalways.add(b'parsed') |
1586 if opts[b'show_stage'] == [b'all']: | 1586 if opts['show_stage'] == [b'all']: |
1587 showalways.update(stagenames) | 1587 showalways.update(stagenames) |
1588 else: | 1588 else: |
1589 for n in opts[b'show_stage']: | 1589 for n in opts['show_stage']: |
1590 if n not in stagenames: | 1590 if n not in stagenames: |
1591 raise error.Abort(_(b'invalid stage name: %s') % n) | 1591 raise error.Abort(_(b'invalid stage name: %s') % n) |
1592 showalways.update(opts[b'show_stage']) | 1592 showalways.update(opts['show_stage']) |
1593 | 1593 |
1594 tree = filesetlang.parse(expr) | 1594 tree = filesetlang.parse(expr) |
1595 for n, f in stages: | 1595 for n, f in stages: |
1596 tree = f(tree) | 1596 tree = f(tree) |
1597 if n in showalways: | 1597 if n in showalways: |
1598 if opts[b'show_stage'] or n != b'parsed': | 1598 if opts['show_stage'] or n != b'parsed': |
1599 ui.write(b"* %s:\n" % n) | 1599 ui.write(b"* %s:\n" % n) |
1600 ui.write(filesetlang.prettyformat(tree), b"\n") | 1600 ui.write(filesetlang.prettyformat(tree), b"\n") |
1601 | 1601 |
1602 files = set() | 1602 files = set() |
1603 if opts[b'all_files']: | 1603 if opts['all_files']: |
1604 for r in repo: | 1604 for r in repo: |
1605 c = repo[r] | 1605 c = repo[r] |
1606 files.update(c.files()) | 1606 files.update(c.files()) |
1607 files.update(c.substate) | 1607 files.update(c.substate) |
1608 if opts[b'all_files'] or ctx.rev() is None: | 1608 if opts['all_files'] or ctx.rev() is None: |
1609 wctx = repo[None] | 1609 wctx = repo[None] |
1610 files.update( | 1610 files.update( |
1611 repo.dirstate.walk( | 1611 repo.dirstate.walk( |
1612 scmutil.matchall(repo), | 1612 scmutil.matchall(repo), |
1613 subrepos=list(wctx.substate), | 1613 subrepos=list(wctx.substate), |
1619 else: | 1619 else: |
1620 files.update(ctx.files()) | 1620 files.update(ctx.files()) |
1621 files.update(ctx.substate) | 1621 files.update(ctx.substate) |
1622 | 1622 |
1623 m = ctx.matchfileset(repo.getcwd(), expr) | 1623 m = ctx.matchfileset(repo.getcwd(), expr) |
1624 if opts[b'show_matcher'] or (opts[b'show_matcher'] is None and ui.verbose): | 1624 if opts['show_matcher'] or (opts['show_matcher'] is None and ui.verbose): |
1625 ui.writenoi18n(b'* matcher:\n', stringutil.prettyrepr(m), b'\n') | 1625 ui.writenoi18n(b'* matcher:\n', stringutil.prettyrepr(m), b'\n') |
1626 for f in sorted(files): | 1626 for f in sorted(files): |
1627 if not m(f): | 1627 if not m(f): |
1628 continue | 1628 continue |
1629 ui.write(b"%s\n" % f) | 1629 ui.write(b"%s\n" % f) |