534 ''' |
534 ''' |
535 # 3rd argument sets expansion to True |
535 # 3rd argument sets expansion to True |
536 _kwfwrite(ui, repo, True, *pats, **opts) |
536 _kwfwrite(ui, repo, True, *pats, **opts) |
537 |
537 |
538 def files(ui, repo, *pats, **opts): |
538 def files(ui, repo, *pats, **opts): |
539 '''print filenames configured for keyword expansion |
539 '''show files configured for keyword expansion |
540 |
540 |
541 Check which filenames in the working directory are matched by the |
541 List which files in the working directory are matched by the |
542 [keyword] configuration patterns. |
542 [keyword] configuration patterns. |
543 |
543 |
544 Useful to prevent inadvertent keyword expansion and to speed up |
544 Useful to prevent inadvertent keyword expansion and to speed up |
545 execution by including only filenames that are actual candidates |
545 execution by including only files that are actual candidates |
546 for expansion. |
546 for expansion. |
547 |
547 |
548 Use -u/--untracked to display untracked filenames as well. |
548 See "hg help keyword" on how to construct patterns both for |
|
549 inclusion and exclusion of files. |
|
550 |
|
551 Use -u/--untracked to list untracked files as well. |
|
552 |
|
553 With -a/--all and -v/--verbose the codes used to show the status |
|
554 of files are: |
|
555 K = keyword expansion candidate |
|
556 k = keyword expansion candidate (untracked) |
|
557 I = ignored |
|
558 i = ignored (untracked) |
549 ''' |
559 ''' |
550 kwt = kwtools['templater'] |
560 kwt = kwtools['templater'] |
551 status = _status(ui, repo, kwt, opts.get('untracked'), *pats, **opts) |
561 status = _status(ui, repo, kwt, opts.get('untracked'), *pats, **opts) |
552 modified, added, removed, deleted, unknown, ignored, clean = status |
562 modified, added, removed, deleted, unknown, ignored, clean = status |
553 try: |
563 try: |
554 # f67d1468ac50 |
564 # f67d1468ac50 |
555 files = util.sort(modified + added + clean + unknown) |
565 files = util.sort(modified + added + clean) |
556 except AttributeError: |
566 except AttributeError: |
557 files = modified + added + clean |
567 files = modified + added + clean |
558 if opts.get('untracked'): |
|
559 files += unknown |
|
560 files.sort() |
568 files.sort() |
561 try: |
569 try: |
562 # f6c00b17387c |
570 # f6c00b17387c |
563 wctx = repo[None] |
571 wctx = repo[None] |
564 except TypeError: |
572 except TypeError: |
569 islink = lambda p: 'l' in wctx.fileflags(p) |
577 islink = lambda p: 'l' in wctx.fileflags(p) |
570 else: |
578 else: |
571 mf = wctx.manifest() |
579 mf = wctx.manifest() |
572 islink = mf.linkf |
580 islink = mf.linkf |
573 kwfiles = [f for f in files if kwt.iskwfile(f, islink)] |
581 kwfiles = [f for f in files if kwt.iskwfile(f, islink)] |
|
582 kwuntracked = [f for f in unknown if kwt.iskwfile(f, islink)] |
574 cwd = pats and repo.getcwd() or '' |
583 cwd = pats and repo.getcwd() or '' |
575 kwfstats = not opts.get('ignore') and (('K', kwfiles),) or () |
584 kwfstats = (not opts.get('ignore') and |
|
585 (('K', kwfiles), ('k', kwuntracked),) or ()) |
576 if opts.get('all') or opts.get('ignore'): |
586 if opts.get('all') or opts.get('ignore'): |
577 kwfstats += (('I', [f for f in files if f not in kwfiles]),) |
587 kwfstats += (('I', [f for f in files if f not in kwfiles]), |
|
588 ('i', [f for f in unknown if f not in kwuntracked]),) |
578 for char, filenames in kwfstats: |
589 for char, filenames in kwfstats: |
579 fmt = (opts.get('all') or ui.verbose) and '%s %%s\n' % char or '%s\n' |
590 fmt = (opts.get('all') or ui.verbose) and '%s %%s\n' % char or '%s\n' |
580 for f in filenames: |
591 for f in filenames: |
581 ui.write(fmt % _pathto(repo, f, cwd)) |
592 ui.write(fmt % _pathto(repo, f, cwd)) |
582 |
593 |