Mercurial > hg
comparison mercurial/store.py @ 17591:9a5c2ecd1158
store: move encode lambda logic into fncachestore
and define two named functions at module scope.
This again also speeds up perffncacheencode a little bit.
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Sun, 16 Sep 2012 11:41:02 +0200 |
parents | eb0884680f5c |
children | 64c6a0d4d4bd |
comparison
equal
deleted
inserted
replaced
17590:eb0884680f5c | 17591:9a5c2ecd1158 |
---|---|
394 def __call__(self, path, mode='r', *args, **kw): | 394 def __call__(self, path, mode='r', *args, **kw): |
395 if mode not in ('r', 'rb') and path.startswith('data/'): | 395 if mode not in ('r', 'rb') and path.startswith('data/'): |
396 self.fncache.add(path) | 396 self.fncache.add(path) |
397 return self.opener(self.encode(path), mode, *args, **kw) | 397 return self.opener(self.encode(path), mode, *args, **kw) |
398 | 398 |
399 def _plainhybridencode(f): | |
400 return _hybridencode(f, False) | |
401 | |
402 def _dothybridencode(f): | |
403 return _hybridencode(f, True) | |
404 | |
399 class fncachestore(basicstore): | 405 class fncachestore(basicstore): |
400 def __init__(self, path, openertype, encode): | 406 def __init__(self, path, openertype, dotencode): |
407 if dotencode: | |
408 encode = _dothybridencode | |
409 else: | |
410 encode = _plainhybridencode | |
401 self.encode = encode | 411 self.encode = encode |
402 self.path = path + '/store' | 412 self.path = path + '/store' |
403 self.pathsep = self.path + '/' | 413 self.pathsep = self.path + '/' |
404 self.createmode = _calcmode(self.path) | 414 self.createmode = _calcmode(self.path) |
405 op = openertype(self.path) | 415 op = openertype(self.path) |
442 self.fncache.write() | 452 self.fncache.write() |
443 | 453 |
444 def store(requirements, path, openertype): | 454 def store(requirements, path, openertype): |
445 if 'store' in requirements: | 455 if 'store' in requirements: |
446 if 'fncache' in requirements: | 456 if 'fncache' in requirements: |
447 de = 'dotencode' in requirements | 457 return fncachestore(path, openertype, 'dotencode' in requirements) |
448 encode = lambda f: _hybridencode(f, de) | |
449 return fncachestore(path, openertype, encode) | |
450 return encodedstore(path, openertype) | 458 return encodedstore(path, openertype) |
451 return basicstore(path, openertype) | 459 return basicstore(path, openertype) |