localrepo: refactor filter computation
authorNicolas Dumazet <nicdumz.commits@gmail.com>
Sat, 24 Jul 2010 00:28:20 +0900
changeset 11698 9df481f8036d
parent 11686 fc360de66217
child 11699 da0b9109186d
localrepo: refactor filter computation Separate loading part from access part to be able to tell with: repo._loadfilter(name) bool(name in repo.filterpats) if there is a 'name' filter available.
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Mon Jul 26 23:26:15 2010 +0200
+++ b/mercurial/localrepo.py	Sat Jul 24 00:28:20 2010 +0900
@@ -510,7 +510,7 @@
     def _link(self, f):
         return os.path.islink(self.wjoin(f))
 
-    def _filter(self, filter, filename, data):
+    def _loadfilter(self, filter):
         if filter not in self.filterpats:
             l = []
             for pat, cmd in self.ui.configitems(filter):
@@ -533,6 +533,9 @@
                 l.append((mf, fn, params))
             self.filterpats[filter] = l
 
+    def _filter(self, filter, filename, data):
+        self._loadfilter(filter)
+
         for mf, fn, cmd in self.filterpats[filter]:
             if mf(filename):
                 self.ui.debug("filtering %s through %s\n" % (filename, cmd))