# HG changeset patch # User Christian Ebert # Date 1192484570 -7200 # Node ID 35f43e2ce5b6a0fdc62d0dfb92864c976320f4f2 # Parent 371ce7fe5f13b62656193dc472f65c3c4e0a6540 For overwriting commands use node and manifest to speed up walk diff -r 371ce7fe5f13 -r 35f43e2ce5b6 hgkw/keyword.py --- a/hgkw/keyword.py Tue Oct 16 07:43:55 2007 +0200 +++ b/hgkw/keyword.py Mon Oct 15 23:42:50 2007 +0200 @@ -308,16 +308,10 @@ return t2 != text return revlog.revlog.cmp(self, node, text) -def _weedfiles(ui, repo, files): - '''Selects files that match [keyword] patterns and are not links.''' - try: - # use the full definition of repo._link for backwards compatibility - return [f for f in files if ui.kwfmatcher(f) - and not os.path.islink(repo.wjoin(f))] - except AttributeError: - if ui.configitems('keyword'): - raise util.Abort(_('[keyword] patterns cannot match')) - raise util.Abort(_('no [keyword] patterns configured')) +def _kwbailout(ui): + if ui.configitems('keyword'): + raise util.Abort(_('[keyword] patterns cannot match')) + raise util.Abort(_('no [keyword] patterns configured')) def _overwrite(ui, repo, expand, *pats, **opts): '''Expands/shrinks keywords in working directory.''' @@ -327,13 +321,19 @@ wlock = repo.wlock() lock = repo.lock() files, match, anypats = cmdutil.matchpats(repo, pats, opts) - clean = repo.status(files=files, match=match, list_clean=True)[6] - candidates = _weedfiles(ui, repo, clean) - if candidates: - ctx = repo.changectx() - kwt = kwtemplater(ui, repo, expand, node=ctx.node()) + ctx = repo.changectx() + node = ctx.node() + man = ctx.manifest() + try: + files = [f for src, f + in repo.walk(node=node, files=files, match=match) + if ui.kwfmatcher(f) and not man.linkf(f)] + except AttributeError: + _kwbailout(ui) + if files: + kwt = kwtemplater(ui, repo, expand, node=node) # 3rd argument sets commit to False - kwt.overwrite(candidates, ctx.manifest(), False) + kwt.overwrite(files, man, False) finally: del wlock, lock @@ -370,7 +370,12 @@ else: files = modified + added + clean files.sort() - kwfiles = _weedfiles(ui, repo, files) + try: + # use the full definition of repo._link for backwards compatibility + kwfiles = [f for f in files if ui.kwfmatcher(f) + and not os.path.islink(repo.wjoin(f))] + except AttributeError: + _kwbailout(ui) cwd = pats and repo.getcwd() or '' allf = opts['all'] ignore = opts['ignore']