Mercurial > hg
changeset 14166:9cbff8a39a2a
store: use a subclass, not a function for fncacheopener
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Mon, 02 May 2011 09:11:35 +0200 |
parents | 78bdfc756908 |
children | 0e4753807c93 |
files | mercurial/store.py |
diffstat | 1 files changed, 12 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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)