##// END OF EJS Templates
store: eliminate one level of lambda functions on _hybridencode
Adrian Buehlmann -
r17590:eb088468 default
parent child Browse files
Show More
@@ -166,7 +166,7 b' def _auxencode(path, dotencode):'
166 166 _maxstorepathlen = 120
167 167 _dirprefixlen = 8
168 168 _maxshortdirslen = 8 * (_dirprefixlen + 1) - 4
169 def _hybridencode(path, auxencode):
169 def _hybridencode(path, dotencode):
170 170 '''encodes path with a length limit
171 171
172 172 Encodes all paths that begin with 'data/', according to the following.
@@ -197,11 +197,13 b' def _hybridencode(path, auxencode):'
197 197 The string 'data/' at the beginning is replaced with 'dh/', if the hashed
198 198 encoding was used.
199 199 '''
200 res = '/'.join(auxencode(encodefilename(path).split('/')))
200 ef = encodefilename(path).split('/')
201 res = '/'.join(_auxencode(ef, dotencode))
201 202 if len(res) > _maxstorepathlen:
202 203 path = encodedir(path)
203 204 digest = _sha(path).hexdigest()
204 parts = auxencode(lowerencode(path).split('/')[1:])
205 le = lowerencode(path).split('/')[1:]
206 parts = _auxencode(le, dotencode)
205 207 basename = parts[-1]
206 208 _root, ext = os.path.splitext(basename)
207 209 sdirs = []
@@ -442,8 +444,8 b' class fncachestore(basicstore):'
442 444 def store(requirements, path, openertype):
443 445 if 'store' in requirements:
444 446 if 'fncache' in requirements:
445 auxencode = lambda f: _auxencode(f, 'dotencode' in requirements)
446 encode = lambda f: _hybridencode(f, auxencode)
447 de = 'dotencode' in requirements
448 encode = lambda f: _hybridencode(f, de)
447 449 return fncachestore(path, openertype, encode)
448 450 return encodedstore(path, openertype)
449 451 return basicstore(path, openertype)
@@ -1,7 +1,6 b''
1 1 from mercurial import store
2 2
3 auxencode = lambda f: store._auxencode(f, True)
4 hybridencode = lambda f: store._hybridencode(f, auxencode)
3 hybridencode = lambda f: store._hybridencode(f, True)
5 4
6 5 enc = hybridencode # used for 'dotencode' repo format
7 6
General Comments 0
You need to be logged in to leave comments. Login now