diff -r 14ebaa9eaf1d -r b5b64c9da876 hgkw/keyword.py --- a/hgkw/keyword.py Mon Oct 15 10:25:20 2007 +0200 +++ b/hgkw/keyword.py Mon Oct 15 11:01:00 2007 +0200 @@ -308,20 +308,12 @@ return t2 != text return revlog.revlog.cmp(self, node, text) -def _weedfiles(ui, repo, *pats, **opts): - '''Collects files matching arguments and/or walkopts, - sorts out those that are configured for keyword expansion - and not links, and returns both lists.''' - files, match, anypats = cmdutil.matchpats(repo, pats, opts) - status = repo.status(files=files, match=match, list_clean=True) - modified, added, removed, deleted, unknown, ignored, clean = status - files = modified + added + clean - files.sort() +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 - kwfiles = [f for f in files if ui.kwfmatcher(f) - and not os.path.islink(repo.wjoin(f))] - return kwfiles, files + 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')) @@ -334,12 +326,14 @@ try: wlock = repo.wlock() lock = repo.lock() - kwfiles, files = _weedfiles(ui, repo, *pats, **opts) - if kwfiles: + 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()) # 3rd argument sets commit to False - kwt.overwrite(kwfiles, ctx.manifest(), False) + kwt.overwrite(candidates, ctx.manifest(), False) finally: del wlock, lock @@ -367,7 +361,12 @@ Crosscheck which files in working directory are target of expansion, that is, files matched by [keyword] config patterns but not symlinks. ''' - kwfiles, files = _weedfiles(ui, repo, *pats, **opts) + files, match, anypats = cmdutil.matchpats(repo, pats, opts) + status = repo.status(files=files, match=match, list_clean=True) + modified, added, removed, deleted, unknown, ignored, clean = status + files = modified + added + clean + files.sort() + kwfiles = _weedfiles(ui, repo, files) cwd = pats and repo.getcwd() or '' allf = opts['all'] ignored = opts['ignored'] @@ -376,7 +375,7 @@ format = ('%s\n', 'K %s\n')[flag] for k in kwfiles: ui.write(format % _pathto(repo, cwd, k)) - if flag or ignored: + if allf or ignored: format = ('%s\n', 'I %s\n')[flag] for i in [f for f in files if f not in kwfiles]: ui.write(format % _pathto(repo, cwd, i))