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