equal
deleted
inserted
replaced
182 return path |
182 return path |
183 |
183 |
184 _maxstorepathlen = 120 |
184 _maxstorepathlen = 120 |
185 _dirprefixlen = 8 |
185 _dirprefixlen = 8 |
186 _maxshortdirslen = 8 * (_dirprefixlen + 1) - 4 |
186 _maxshortdirslen = 8 * (_dirprefixlen + 1) - 4 |
|
187 |
|
188 def _hashencode(path, dotencode): |
|
189 digest = _sha(path).hexdigest() |
|
190 le = lowerencode(path).split('/')[1:] |
|
191 parts = _auxencode(le, dotencode) |
|
192 basename = parts[-1] |
|
193 _root, ext = os.path.splitext(basename) |
|
194 sdirs = [] |
|
195 sdirslen = 0 |
|
196 for p in parts[:-1]: |
|
197 d = p[:_dirprefixlen] |
|
198 if d[-1] in '. ': |
|
199 # Windows can't access dirs ending in period or space |
|
200 d = d[:-1] + '_' |
|
201 if sdirslen == 0: |
|
202 t = len(d) |
|
203 else: |
|
204 t = sdirslen + 1 + len(d) |
|
205 if t > _maxshortdirslen: |
|
206 break |
|
207 sdirs.append(d) |
|
208 sdirslen = t |
|
209 dirs = '/'.join(sdirs) |
|
210 if len(dirs) > 0: |
|
211 dirs += '/' |
|
212 res = 'dh/' + dirs + digest + ext |
|
213 spaceleft = _maxstorepathlen - len(res) |
|
214 if spaceleft > 0: |
|
215 filler = basename[:spaceleft] |
|
216 res = 'dh/' + dirs + filler + digest + ext |
|
217 return res |
|
218 |
187 def _hybridencode(path, dotencode): |
219 def _hybridencode(path, dotencode): |
188 '''encodes path with a length limit |
220 '''encodes path with a length limit |
189 |
221 |
190 Encodes all paths that begin with 'data/', according to the following. |
222 Encodes all paths that begin with 'data/', according to the following. |
191 |
223 |
217 ''' |
249 ''' |
218 path = encodedir(path) |
250 path = encodedir(path) |
219 ef = _encodefname(path).split('/') |
251 ef = _encodefname(path).split('/') |
220 res = '/'.join(_auxencode(ef, dotencode)) |
252 res = '/'.join(_auxencode(ef, dotencode)) |
221 if len(res) > _maxstorepathlen: |
253 if len(res) > _maxstorepathlen: |
222 digest = _sha(path).hexdigest() |
254 res = _hashencode(path, dotencode) |
223 le = lowerencode(path).split('/')[1:] |
|
224 parts = _auxencode(le, dotencode) |
|
225 basename = parts[-1] |
|
226 _root, ext = os.path.splitext(basename) |
|
227 sdirs = [] |
|
228 sdirslen = 0 |
|
229 for p in parts[:-1]: |
|
230 d = p[:_dirprefixlen] |
|
231 if d[-1] in '. ': |
|
232 # Windows can't access dirs ending in period or space |
|
233 d = d[:-1] + '_' |
|
234 if sdirslen == 0: |
|
235 t = len(d) |
|
236 else: |
|
237 t = sdirslen + 1 + len(d) |
|
238 if t > _maxshortdirslen: |
|
239 break |
|
240 sdirs.append(d) |
|
241 sdirslen = t |
|
242 dirs = '/'.join(sdirs) |
|
243 if len(dirs) > 0: |
|
244 dirs += '/' |
|
245 res = 'dh/' + dirs + digest + ext |
|
246 spaceleft = _maxstorepathlen - len(res) |
|
247 if spaceleft > 0: |
|
248 filler = basename[:spaceleft] |
|
249 res = 'dh/' + dirs + filler + digest + ext |
|
250 return res |
255 return res |
251 |
256 |
252 def _calcmode(path): |
257 def _calcmode(path): |
253 try: |
258 try: |
254 # files in .hg/ will be created using this mode |
259 # files in .hg/ will be created using this mode |