Mercurial > hg
comparison mercurial/store.py @ 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 | 222c8ec7a274 |
children | 3a90fb3addc1 |
comparison
equal
deleted
inserted
replaced
14165:78bdfc756908 | 14166:9cbff8a39a2a |
---|---|
368 class fncachestore(basicstore): | 368 class fncachestore(basicstore): |
369 def __init__(self, path, openertype, encode): | 369 def __init__(self, path, openertype, encode): |
370 self.encode = encode | 370 self.encode = encode |
371 self.path = path + '/store' | 371 self.path = path + '/store' |
372 self.createmode = _calcmode(self.path) | 372 self.createmode = _calcmode(self.path) |
373 op = openertype(self.path) | 373 |
374 storeself = self | |
375 | |
376 class fncacheopener(openertype): | |
377 def __call__(self, path, mode='r', *args, **kw): | |
378 if mode not in ('r', 'rb') and path.startswith('data/'): | |
379 fnc.add(path) | |
380 return openertype.__call__(self, storeself.encode(path), mode, | |
381 *args, **kw) | |
382 | |
383 op = fncacheopener(self.path) | |
374 op.createmode = self.createmode | 384 op.createmode = self.createmode |
375 fnc = fncache(op) | 385 fnc = fncache(op) |
376 self.fncache = fnc | 386 self.fncache = fnc |
377 | 387 self.opener = op |
378 def fncacheopener(path, mode='r', *args, **kw): | |
379 if mode not in ('r', 'rb') and path.startswith('data/'): | |
380 fnc.add(path) | |
381 return op(self.encode(path), mode, *args, **kw) | |
382 self.opener = fncacheopener | |
383 | 388 |
384 def join(self, f): | 389 def join(self, f): |
385 return self.path + '/' + self.encode(f) | 390 return self.path + '/' + self.encode(f) |
386 | 391 |
387 def datafiles(self): | 392 def datafiles(self): |