Mercurial > hg
comparison hgext/keyword.py @ 50879:7e6cd8472dc8
keyword: migrate `opts` to native kwargs
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 20 Aug 2023 16:43:41 -0400 |
parents | fcb67b8c8107 |
children | 18c8c18993f0 |
comparison
equal
deleted
inserted
replaced
50878:bbaac3a222bb | 50879:7e6cd8472dc8 |
---|---|
418 | 418 |
419 def _status(ui, repo, wctx, kwt, *pats, **opts): | 419 def _status(ui, repo, wctx, kwt, *pats, **opts): |
420 """Bails out if [keyword] configuration is not active. | 420 """Bails out if [keyword] configuration is not active. |
421 Returns status of working directory.""" | 421 Returns status of working directory.""" |
422 if kwt: | 422 if kwt: |
423 opts = pycompat.byteskwargs(opts) | |
424 return repo.status( | 423 return repo.status( |
425 match=scmutil.match(wctx, pats, opts), | 424 match=scmutil.match(wctx, pats, pycompat.byteskwargs(opts)), |
426 clean=True, | 425 clean=True, |
427 unknown=opts.get(b'unknown') or opts.get(b'all'), | 426 unknown=opts.get('unknown') or opts.get('all'), |
428 ) | 427 ) |
429 if ui.configitems(b'keyword'): | 428 if ui.configitems(b'keyword'): |
430 raise error.Abort(_(b'[keyword] patterns cannot match')) | 429 raise error.Abort(_(b'[keyword] patterns cannot match')) |
431 raise error.Abort(_(b'no [keyword] patterns configured')) | 430 raise error.Abort(_(b'no [keyword] patterns configured')) |
432 | 431 |
602 if pats: | 601 if pats: |
603 cwd = repo.getcwd() | 602 cwd = repo.getcwd() |
604 else: | 603 else: |
605 cwd = b'' | 604 cwd = b'' |
606 files = [] | 605 files = [] |
607 opts = pycompat.byteskwargs(opts) | 606 |
608 if not opts.get(b'unknown') or opts.get(b'all'): | 607 if not opts.get('unknown') or opts.get('all'): |
609 files = sorted(status.modified + status.added + status.clean) | 608 files = sorted(status.modified + status.added + status.clean) |
610 kwfiles = kwt.iskwfile(files, wctx) | 609 kwfiles = kwt.iskwfile(files, wctx) |
611 kwdeleted = kwt.iskwfile(status.deleted, wctx) | 610 kwdeleted = kwt.iskwfile(status.deleted, wctx) |
612 kwunknown = kwt.iskwfile(status.unknown, wctx) | 611 kwunknown = kwt.iskwfile(status.unknown, wctx) |
613 if not opts.get(b'ignore') or opts.get(b'all'): | 612 if not opts.get('ignore') or opts.get('all'): |
614 showfiles = kwfiles, kwdeleted, kwunknown | 613 showfiles = kwfiles, kwdeleted, kwunknown |
615 else: | 614 else: |
616 showfiles = [], [], [] | 615 showfiles = [], [], [] |
617 if opts.get(b'all') or opts.get(b'ignore'): | 616 if opts.get('all') or opts.get('ignore'): |
618 showfiles += ( | 617 showfiles += ( |
619 [f for f in files if f not in kwfiles], | 618 [f for f in files if f not in kwfiles], |
620 [f for f in status.unknown if f not in kwunknown], | 619 [f for f in status.unknown if f not in kwunknown], |
621 ) | 620 ) |
622 kwlabels = b'enabled deleted enabledunknown ignored ignoredunknown'.split() | 621 kwlabels = b'enabled deleted enabledunknown ignored ignoredunknown'.split() |
623 kwstates = zip(kwlabels, pycompat.bytestr(b'K!kIi'), showfiles) | 622 kwstates = zip(kwlabels, pycompat.bytestr(b'K!kIi'), showfiles) |
624 fm = ui.formatter(b'kwfiles', opts) | 623 fm = ui.formatter(b'kwfiles', pycompat.byteskwargs(opts)) |
625 fmt = b'%.0s%s\n' | 624 fmt = b'%.0s%s\n' |
626 if opts.get(b'all') or ui.verbose: | 625 if opts.get('all') or ui.verbose: |
627 fmt = b'%s %s\n' | 626 fmt = b'%s %s\n' |
628 for kwstate, char, filenames in kwstates: | 627 for kwstate, char, filenames in kwstates: |
629 label = b'kwfiles.' + kwstate | 628 label = b'kwfiles.' + kwstate |
630 for f in filenames: | 629 for f in filenames: |
631 fm.startitem() | 630 fm.startitem() |