# HG changeset patch # User Christian Ebert # Date 1309690683 -7200 # Node ID 82015736cc7eeead37ad50c96561ff7369719f6c # Parent 0d4e44410b4dcf0466848b28fc6ffe64d6d7933d Reuse already present working contexts for match Shortens overlong line as side-effect. diff -r 0d4e44410b4d -r 82015736cc7e hgkw/keyword.py --- a/hgkw/keyword.py Fri Jul 01 14:52:14 2011 +0200 +++ b/hgkw/keyword.py Sun Jul 03 12:58:03 2011 +0200 @@ -322,11 +322,11 @@ text = self.kwt.shrink(self.path, text) return super(kwfilelog, self).cmp(node, text) -def _status(ui, repo, kwt, *pats, **opts): +def _status(ui, repo, wctx, kwt, *pats, **opts): '''Bails out if [keyword] configuration is not active. Returns status of working directory.''' if kwt: - return repo.status(match=scmutil.match(repo[None], pats, opts), clean=True, + return repo.status(match=scmutil.match(wctx, pats, opts), clean=True, unknown=opts.get('unknown') or opts.get('all')) if ui.configitems('keyword'): raise util.Abort(_('[keyword] patterns cannot match')) @@ -340,7 +340,7 @@ kwt = kwtools['templater'] wlock = repo.wlock() try: - status = _status(ui, repo, kwt, *pats, **opts) + status = _status(ui, repo, wctx, kwt, *pats, **opts) modified, added, removed, deleted, unknown, ignored, clean = status if modified or added or removed or deleted: raise util.Abort(_('outstanding uncommitted changes')) @@ -475,13 +475,13 @@ i = ignored (not tracked) ''' kwt = kwtools['templater'] - status = _status(ui, repo, kwt, *pats, **opts) + wctx = repo[None] + status = _status(ui, repo, wctx, kwt, *pats, **opts) cwd = pats and repo.getcwd() or '' modified, added, removed, deleted, unknown, ignored, clean = status files = [] if not opts.get('unknown') or opts.get('all'): files = sorted(modified + added + clean) - wctx = repo[None] kwfiles = kwt.iskwfile(files, wctx) kwdeleted = kwt.iskwfile(deleted, wctx) kwunknown = kwt.iskwfile(unknown, wctx)