hgkw/keyword.py
changeset 268 14ebaa9eaf1d
parent 266 50ce25f8c676
child 269 b5b64c9da876
equal deleted inserted replaced
267:4a24c3acd4f2 268:14ebaa9eaf1d
   322         kwfiles = [f for f in files if ui.kwfmatcher(f)
   322         kwfiles = [f for f in files if ui.kwfmatcher(f)
   323                    and not os.path.islink(repo.wjoin(f))]
   323                    and not os.path.islink(repo.wjoin(f))]
   324         return kwfiles, files
   324         return kwfiles, files
   325     except AttributeError:
   325     except AttributeError:
   326         if ui.configitems('keyword'):
   326         if ui.configitems('keyword'):
   327             err = _('[keyword] patterns cannot match')
   327             raise util.Abort(_('[keyword] patterns cannot match'))
   328         else:
   328         raise util.Abort(_('no [keyword] patterns configured'))
   329             err = _('no [keyword] patterns configured')
       
   330         raise util.Abort(err)
       
   331 
   329 
   332 def _overwrite(ui, repo, expand, *pats, **opts):
   330 def _overwrite(ui, repo, expand, *pats, **opts):
   333     '''Expands/shrinks keywords in working directory.'''
   331     '''Expands/shrinks keywords in working directory.'''
   334     bail_if_changed(repo)
   332     bail_if_changed(repo)
   335     wlock = lock = None
   333     wlock = lock = None
   364     _overwrite(ui, repo, True, *pats, **opts)
   362     _overwrite(ui, repo, True, *pats, **opts)
   365 
   363 
   366 def files(ui, repo, *pats, **opts):
   364 def files(ui, repo, *pats, **opts):
   367     '''print files currently configured for keyword expansion
   365     '''print files currently configured for keyword expansion
   368 
   366 
   369     Crosscheck which files in working directory
   367     Crosscheck which files in working directory are target of expansion,
   370     are matched by [keyword] config patterns.
   368     that is, files matched by [keyword] config patterns but not symlinks.
   371     '''
   369     '''
   372     kwfiles, files = _weedfiles(ui, repo, *pats, **opts)
   370     kwfiles, files = _weedfiles(ui, repo, *pats, **opts)
   373     cwd = pats and repo.getcwd() or ''
   371     cwd = pats and repo.getcwd() or ''
   374     flag = opts['all'] and 1 or 0
   372     allf = opts['all']
   375     ignored = opts['ignored']
   373     ignored = opts['ignored']
       
   374     flag = (allf or ui.verbose) and 1 or 0
   376     if not ignored:
   375     if not ignored:
   377         format = ('%s\n', 'K %s\n')[flag]
   376         format = ('%s\n', 'K %s\n')[flag]
   378         for k in kwfiles:
   377         for k in kwfiles:
   379             ui.write(format % _pathto(repo, cwd, k))
   378             ui.write(format % _pathto(repo, cwd, k))
   380     if flag or ignored:
   379     if flag or ignored: