hgkw/keyword.py
changeset 310 574128f982a2
parent 309 a5f5bbf4a668
child 314 d9f84b36de26
--- a/hgkw/keyword.py	Sun Dec 02 08:15:36 2007 +0100
+++ b/hgkw/keyword.py	Sun Dec 02 08:32:19 2007 +0100
@@ -112,7 +112,7 @@
     def __init__(self, ui, repo, inc, exc):
         self.ui = ui
         self.repo = repo
-        self.match = util.matcher(repo.root, inc=inc, exc=exc)[1]
+        self.matcher = util.matcher(repo.root, inc=inc, exc=exc)[1]
         self.node = None
         self.path = ''
 
@@ -203,6 +203,9 @@
             return t2 != text
         return revlog.revlog.cmp(self, node, text)
 
+def _iskwfile(f, kwtemplater, link):
+    return not link(f) and kwtemplater.matcher(f)
+
 def _status(ui, repo, kwtemplater, *pats, **opts):
     '''Bails out if [keyword] configuration is not active.
     Returns status of working directory.'''
@@ -222,7 +225,7 @@
         files = [f for f in ctx.files() if mf.has_key(f)]
     else:
         notify = ui.note  # kwexpand/kwshrink
-    candidates = [f for f in files if not mf.linkf(f) and kwtemplater.match(f)]
+    candidates = [f for f in files if _iskwfile(f, kwtemplater, mf.linkf)]
     if candidates:
         candidates.sort()
         action = expand and 'expanding' or 'shrinking'
@@ -357,7 +360,7 @@
     else:
         files = modified + added + clean
     files.sort()
-    kwfiles = [f for f in files if _kwtemplater.match(f) and not repo._link(f)]
+    kwfiles = [f for f in files if _iskwfile(f, _kwtemplater, repo._link)]
     cwd = pats and repo.getcwd() or ''
     allf = opts['all']
     ignore = opts['ignore']
@@ -423,7 +426,7 @@
         def file(self, f, kwmatch=False):
             if f[0] == '/':
                 f = f[1:]
-            if kwmatch or _kwtemplater.match(f):
+            if kwmatch or _kwtemplater.matcher(f):
                 return kwfilelog(self.sopener, f, _kwtemplater)
             return filelog.filelog(self.sopener, f)