localrepo: load filter patterns outside of _filter
authorNicolas Dumazet <nicdumz.commits@gmail.com>
Sun, 10 Oct 2010 19:10:16 +0200
changeset 12707 2216ab103ea8
parent 12706 9ca08fbb750a
child 12708 8a08b12ae88e
localrepo: load filter patterns outside of _filter
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Sun Oct 10 19:07:58 2010 +0200
+++ b/mercurial/localrepo.py	Sun Oct 10 19:10:16 2010 +0200
@@ -588,8 +588,8 @@
             self.filterpats[filter] = l
         return self.filterpats[filter]
 
-    def _filter(self, filter, filename, data):
-        for mf, fn, cmd in self._loadfilter[filter]:
+    def _filter(self, filterpats, filename, data):
+        for mf, fn, cmd in filterpats:
             if mf(filename):
                 self.ui.debug("filtering %s through %s\n" % (filename, cmd))
                 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
@@ -605,10 +605,10 @@
             data = os.readlink(self.wjoin(filename))
         else:
             data = self.wopener(filename, 'r').read()
-        return self._filter("encode", filename, data)
+        return self._filter(self._loadfilter("encode"), filename, data)
 
     def wwrite(self, filename, data, flags):
-        data = self._filter("decode", filename, data)
+        data = self._filter(self._loadfilter("decode"), filename, data)
         try:
             os.unlink(self.wjoin(filename))
         except OSError:
@@ -621,7 +621,7 @@
                 util.set_flags(self.wjoin(filename), False, True)
 
     def wwritedata(self, filename, data):
-        return self._filter("decode", filename, data)
+        return self._filter(self._loadfilter("decode"), filename, data)
 
     def transaction(self, desc):
         tr = self._transref and self._transref() or None