[PATCH 5 of 5] store: move encode lambda logic into fncachestore
Adrian Buehlmann
adrian at cadifra.com
Sun Sep 16 05:27:12 CDT 2012
# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1347788462 -7200
# Node ID e7302c90c06661a5465194506f004696dacc26ca
# Parent c85ed3454355eaf305ebc7e0ce0a9ac4587ee6b4
store: move encode lambda logic into fncachestore
and define two named functions at module scope.
This again also speeds up perffncacheencode a little bit.
diff --git a/mercurial/store.py b/mercurial/store.py
--- a/mercurial/store.py
+++ b/mercurial/store.py
@@ -396,8 +396,18 @@
self.fncache.add(path)
return self.opener(self.encode(path), mode, *args, **kw)
+def _plainhybridencode(f):
+ return _hybridencode(f, False)
+
+def _dothybridencode(f):
+ return _hybridencode(f, True)
+
class fncachestore(basicstore):
- def __init__(self, path, openertype, encode):
+ def __init__(self, path, openertype, dotencode):
+ if dotencode:
+ encode = _dothybridencode
+ else:
+ encode = _plainhybridencode
self.encode = encode
self.path = path + '/store'
self.pathsep = self.path + '/'
@@ -444,8 +454,6 @@
def store(requirements, path, openertype):
if 'store' in requirements:
if 'fncache' in requirements:
- de = 'dotencode' in requirements
- encode = lambda f: _hybridencode(f, de)
- return fncachestore(path, openertype, encode)
+ return fncachestore(path, openertype, 'dotencode' in requirements)
return encodedstore(path, openertype)
return basicstore(path, openertype)
More information about the Mercurial-devel
mailing list