hgkw/keyword.py
branchstable
changeset 599 4362f0ef265a
parent 597 795a95d7dc61
child 600 b40e7861defd
equal deleted inserted replaced
593:23da65f04361 599:4362f0ef265a
   357     '''
   357     '''
   358     # 3rd argument sets expansion to True
   358     # 3rd argument sets expansion to True
   359     _kwfwrite(ui, repo, True, *pats, **opts)
   359     _kwfwrite(ui, repo, True, *pats, **opts)
   360 
   360 
   361 def files(ui, repo, *pats, **opts):
   361 def files(ui, repo, *pats, **opts):
   362     '''print filenames configured for keyword expansion
   362     '''show files configured for keyword expansion
   363 
   363 
   364     Check which filenames in the working directory are matched by the
   364     List which files in the working directory are matched by the
   365     [keyword] configuration patterns.
   365     [keyword] configuration patterns.
   366 
   366 
   367     Useful to prevent inadvertent keyword expansion and to speed up
   367     Useful to prevent inadvertent keyword expansion and to speed up
   368     execution by including only filenames that are actual candidates
   368     execution by including only files that are actual candidates
   369     for expansion.
   369     for expansion.
   370 
   370 
   371     Use -u/--untracked to display untracked filenames as well.
   371     See "hg help keyword" on how to construct patterns both for
       
   372     inclusion and exclusion of files.
       
   373 
       
   374     Use -u/--untracked to list untracked files as well.
       
   375 
       
   376     With -a/--all and -v/--verbose the codes used to show the status
       
   377     of files are:
       
   378     K = keyword expansion candidate
       
   379     k = keyword expansion candidate (untracked)
       
   380     I = ignored
       
   381     i = ignored (untracked)
   372     '''
   382     '''
   373     kwt = kwtools['templater']
   383     kwt = kwtools['templater']
   374     status = _status(ui, repo, kwt, opts.get('untracked'), *pats, **opts)
   384     status = _status(ui, repo, kwt, opts.get('untracked'), *pats, **opts)
   375     modified, added, removed, deleted, unknown, ignored, clean = status
   385     modified, added, removed, deleted, unknown, ignored, clean = status
   376     files = sorted(modified + added + clean + unknown)
   386     files = sorted(modified + added + clean)
   377     wctx = repo[None]
   387     wctx = repo[None]
   378     kwfiles = [f for f in files if kwt.iskwfile(f, wctx.flags)]
   388     kwfiles = [f for f in files if kwt.iskwfile(f, wctx.flags)]
       
   389     kwuntracked = [f for f in unknown if kwt.iskwfile(f, wctx.flags)]
   379     cwd = pats and repo.getcwd() or ''
   390     cwd = pats and repo.getcwd() or ''
   380     kwfstats = not opts.get('ignore') and (('K', kwfiles),) or ()
   391     kwfstats = (not opts.get('ignore') and
       
   392                 (('K', kwfiles), ('k', kwuntracked),) or ())
   381     if opts.get('all') or opts.get('ignore'):
   393     if opts.get('all') or opts.get('ignore'):
   382         kwfstats += (('I', [f for f in files if f not in kwfiles]),)
   394         kwfstats += (('I', [f for f in files if f not in kwfiles]),
       
   395                      ('i', [f for f in unknown if f not in kwuntracked]),)
   383     for char, filenames in kwfstats:
   396     for char, filenames in kwfstats:
   384         fmt = (opts.get('all') or ui.verbose) and '%s %%s\n' % char or '%s\n'
   397         fmt = (opts.get('all') or ui.verbose) and '%s %%s\n' % char or '%s\n'
   385         for f in filenames:
   398         for f in filenames:
   386             ui.write(fmt % repo.pathto(f, cwd))
   399             ui.write(fmt % repo.pathto(f, cwd))
   387 
   400