Mercurial > hg
comparison mercurial/store.py @ 17584:61cd71dc3797
store: refactor splitting off of "data/" in _hybridencode()
encodefilename() already calls encodedir(). Note that encodedir() skips the
encoding if the path doesn't start with "data/".
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Sat, 15 Sep 2012 21:43:14 +0200 |
parents | 81a033bb29bc |
children | 8ed2783f338f |
comparison
equal
deleted
inserted
replaced
17581:54c832922e85 | 17584:61cd71dc3797 |
---|---|
198 The string 'data/' at the beginning is replaced with 'dh/', if the hashed | 198 The string 'data/' at the beginning is replaced with 'dh/', if the hashed |
199 encoding was used. | 199 encoding was used. |
200 ''' | 200 ''' |
201 if not path.startswith('data/'): | 201 if not path.startswith('data/'): |
202 return path | 202 return path |
203 # escape directories ending with .i and .d | 203 res = '/'.join(auxencode(encodefilename(path))) |
204 path = encodedir(path) | |
205 ndpath = path[len('data/'):] | |
206 res = 'data/' + '/'.join(auxencode(encodefilename(ndpath))) | |
207 if len(res) > _maxstorepathlen: | 204 if len(res) > _maxstorepathlen: |
205 path = encodedir(path) | |
208 digest = _sha(path).hexdigest() | 206 digest = _sha(path).hexdigest() |
209 parts = auxencode(lowerencode(ndpath)) | 207 parts = auxencode(lowerencode(path))[1:] |
210 _root, ext = os.path.splitext(parts[-1]) | 208 _root, ext = os.path.splitext(parts[-1]) |
211 basename = parts[-1] | 209 basename = parts[-1] |
212 sdirs = [] | 210 sdirs = [] |
213 for p in parts[:-1]: | 211 for p in parts[:-1]: |
214 d = p[:_dirprefixlen] | 212 d = p[:_dirprefixlen] |