diff -r e8b9a500f2e1 -r 2a8b0a71c2ec hgkw/keyword.py --- a/hgkw/keyword.py Tue Jan 16 05:02:38 2007 +0100 +++ b/hgkw/keyword.py Tue Jan 16 12:09:37 2007 +0100 @@ -48,6 +48,10 @@ ... ''' +from mercurial.i18n import gettext as _ +# above line for backwards compatibility; can be changed to +# from mercurial.i18n import _ +# some day from mercurial import cmdutil, templater, util from mercurial.node import * import os.path, re, sys, time @@ -71,18 +75,12 @@ def kwfmatches(ui, repo, files): '''Selects candidates for keyword substitution configured in keyword section in hgrc.''' - files = [f for f in files if not f.startswith('.hg')] - if not files: + names = [pat for pat, opt in ui.configitems('keyword') if opt == 'expand'] + if not names: + ui.warn(_('keyword: no filename patterns for expansion\n')) return [] - candidates = [] - kwfmatchers = [util.matcher(repo.root, '', [pat], [], [])[1] - for pat, opt in ui.configitems('keyword') if opt == 'expand'] - for f in files: - for mf in kwfmatchers: - if mf(f): - candidates.append(f) - break - return candidates + kwfmatcher = util.matcher(repo.root, cwd='', names=names, exc=['.hg*'])[1] + return [f for f in files if kwfmatcher(f)] class kwtemplater(object): @@ -183,10 +181,6 @@ def pretxnkw(ui, repo, hooktype, **args): '''pretxncommit hook that collects candidates for keyword expansion on commit and expands keywords in working dir.''' - from mercurial.i18n import gettext as _ - # above line for backwards compatibility; can be changed to - # from mercurial.i18n import _ - # some day from mercurial import commands cmd, sysargs, globalopts, cmdopts = commands.parse(ui, sys.argv[1:])[1:]