# HG changeset patch # User Christian Ebert # Date 1169813453 0 # Node ID d5c80df59655a755ee69e31985224a7629c3282c # Parent 85ed7d71ba0f220a5a49923ebd11b50e858e8eb4 No reposetup when no filenames are specified for expansion Second stab at stopping reposetup. This time kwtemplater is still initialized in kwfilelog and pretxnkw, and not in reposetup. Watchout: Giving ui an extra-attribute in reposetup might still be problematic. diff -r 85ed7d71ba0f -r d5c80df59655 hgkw/keyword.py --- a/hgkw/keyword.py Tue Jan 23 15:26:33 2007 +0000 +++ b/hgkw/keyword.py Fri Jan 26 12:10:53 2007 +0000 @@ -108,20 +108,6 @@ sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) return os.path.splitext(os.path.basename(__file__))[0] -def kwfmatches(ui, repo, files): - '''Selects and weeds out candidates for keyword substitution - by patterns configured in [keyword] section in hgrc.''' - inc, exc = [], ['.hg*'] - for pat, opt in ui.configitems('keyword'): - if opt != 'ignore': - inc.append(pat) - else: - exc.append(pat) - if not inc: - return [] - kwfmatcher = util.matcher(repo.root, inc=inc, exc=exc)[1] - return [f for f in files if kwfmatcher(f)] - class kwtemplater(object): ''' Sets up keyword templates, corresponding keyword regex, and @@ -155,6 +141,17 @@ if not repo.local(): return + inc, exc = [], ['.hg*'] + for pat, opt in ui.configitems('keyword'): + if opt != 'ignore': + inc.append(pat) + else: + exc.append(pat) + if not inc: + return + + ui.kwfmatcher = util.matcher(repo.root, inc=inc, exc=exc)[1] + class kwrepo(repo.__class__): def file(self, f): if f[0] == '/': @@ -172,7 +169,7 @@ self._repo = repo self._path = path # only init kwtemplater if needed - if not isinstance(repo, int) and kwfmatches(ui, repo, [path]): + if not isinstance(repo, int) and ui.kwfmatcher(path): self.kwt = kwtemplater(ui, repo) else: self.kwt = None @@ -221,7 +218,7 @@ files, match, anypats = cmdutil.matchpats(repo, sysargs, cmdopts) modified, added = repo.status(files=files, match=match)[:2] - candidates = kwfmatches(ui, repo, modified+added) + candidates = [f for f in modified + added if ui.kwfmatcher(f)] if not candidates: return