store: eliminate one level of lambda functions on _hybridencode

This commit is contained in:
Adrian Buehlmann 2012-09-16 11:36:14 +02:00
parent bbb1196b99
commit e773964ca6
2 changed files with 8 additions and 7 deletions

View File

@ -166,7 +166,7 @@ def _auxencode(path, dotencode):
_maxstorepathlen = 120
_dirprefixlen = 8
_maxshortdirslen = 8 * (_dirprefixlen + 1) - 4
def _hybridencode(path, auxencode):
def _hybridencode(path, dotencode):
'''encodes path with a length limit
Encodes all paths that begin with 'data/', according to the following.
@ -197,11 +197,13 @@ def _hybridencode(path, auxencode):
The string 'data/' at the beginning is replaced with 'dh/', if the hashed
encoding was used.
'''
res = '/'.join(auxencode(encodefilename(path).split('/')))
ef = encodefilename(path).split('/')
res = '/'.join(_auxencode(ef, dotencode))
if len(res) > _maxstorepathlen:
path = encodedir(path)
digest = _sha(path).hexdigest()
parts = auxencode(lowerencode(path).split('/')[1:])
le = lowerencode(path).split('/')[1:]
parts = _auxencode(le, dotencode)
basename = parts[-1]
_root, ext = os.path.splitext(basename)
sdirs = []
@ -442,8 +444,8 @@ class fncachestore(basicstore):
def store(requirements, path, openertype):
if 'store' in requirements:
if 'fncache' in requirements:
auxencode = lambda f: _auxencode(f, 'dotencode' in requirements)
encode = lambda f: _hybridencode(f, auxencode)
de = 'dotencode' in requirements
encode = lambda f: _hybridencode(f, de)
return fncachestore(path, openertype, encode)
return encodedstore(path, openertype)
return basicstore(path, openertype)

View File

@ -1,7 +1,6 @@
from mercurial import store
auxencode = lambda f: store._auxencode(f, True)
hybridencode = lambda f: store._hybridencode(f, auxencode)
hybridencode = lambda f: store._hybridencode(f, True)
enc = hybridencode # used for 'dotencode' repo format