[PATCH 3 of 7] keyword: make iskwfile() a weeding method in lieu of a boolean

Christian Ebert blacktrash at gmx.net
Fri Oct 8 12:40:16 CDT 2010


# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1286559586 -3600
# Node ID 3d44bf06cadd64b09cb0bff1615a0583df89d2cb
# Parent  9a248300cbb0570ba183edf36479c21fcb5b64a8
keyword: make iskwfile() a weeding method in lieu of a boolean

Update iskwfile docstring.

diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -191,16 +191,15 @@
             return self.substitute(data, path, ctx, self.re_kw.sub)
         return data
 
-    def iskwfile(self, path, flagfunc):
-        '''Returns true if path matches [keyword] pattern
-        and is not a symbolic link.
-        Caveat: localrepository._link fails on Windows.'''
-        return self.match(path) and not 'l' in flagfunc(path)
+    def iskwfile(self, cand, ctx):
+        '''Returns subset of candidates which are configured for keyword
+        expansion are not symbolic links.'''
+        return [f for f in cand if self.match(f) and not 'l' in ctx.flags(f)]
 
     def overwrite(self, ctx, candidates, lookup, expand):
         '''Overwrites selected files expanding/shrinking keywords.'''
         if self.restrict or lookup: # exclude kw_copy
-            candidates = [f for f in candidates if self.iskwfile(f, ctx.flags)]
+            candidates = self.iskwfile(candidates, ctx)
         if not candidates:
             return
         commit = self.restrict and not lookup
@@ -417,8 +416,8 @@
     if not opts.get('unknown') or opts.get('all'):
         files = sorted(modified + added + clean)
     wctx = repo[None]
-    kwfiles = [f for f in files if kwt.iskwfile(f, wctx.flags)]
-    kwunknown = [f for f in unknown if kwt.iskwfile(f, wctx.flags)]
+    kwfiles = kwt.iskwfile(files, wctx)
+    kwunknown = kwt.iskwfile(unknown, wctx)
     if not opts.get('ignore') or opts.get('all'):
         showfiles = kwfiles, kwunknown
     else:


More information about the Mercurial-devel mailing list