store: use a subclass, not a function for fncacheopener
authorDan Villiom Podlaski Christiansen <danchr@gmail.com>
Mon, 02 May 2011 09:11:35 +0200
changeset 14166 9cbff8a39a2a
parent 14165 78bdfc756908
child 14167 0e4753807c93
store: use a subclass, not a function for fncacheopener
mercurial/store.py
--- a/mercurial/store.py	Mon Apr 18 02:42:52 2011 +0200
+++ b/mercurial/store.py	Mon May 02 09:11:35 2011 +0200
@@ -370,16 +370,21 @@
         self.encode = encode
         self.path = path + '/store'
         self.createmode = _calcmode(self.path)
-        op = openertype(self.path)
+
+        storeself = self
+
+        class fncacheopener(openertype):
+            def __call__(self, path, mode='r', *args, **kw):
+                if mode not in ('r', 'rb') and path.startswith('data/'):
+                    fnc.add(path)
+                return openertype.__call__(self, storeself.encode(path), mode,
+                                           *args, **kw)
+
+        op = fncacheopener(self.path)
         op.createmode = self.createmode
         fnc = fncache(op)
         self.fncache = fnc
-
-        def fncacheopener(path, mode='r', *args, **kw):
-            if mode not in ('r', 'rb') and path.startswith('data/'):
-                fnc.add(path)
-            return op(self.encode(path), mode, *args, **kw)
-        self.opener = fncacheopener
+        self.opener = op
 
     def join(self, f):
         return self.path + '/' + self.encode(f)