Show More
@@ -336,7 +336,8 b' def _splittopdir(f):' | |||||
336 | return '', f |
|
336 | return '', f | |
337 |
|
337 | |||
338 | class treemanifest(object): |
|
338 | class treemanifest(object): | |
339 | def __init__(self, text=''): |
|
339 | def __init__(self, dir='', text=''): | |
|
340 | self._dir = dir | |||
340 | self._dirs = {} |
|
341 | self._dirs = {} | |
341 | # Using _lazymanifest here is a little slower than plain old dicts |
|
342 | # Using _lazymanifest here is a little slower than plain old dicts | |
342 | self._files = {} |
|
343 | self._files = {} | |
@@ -347,27 +348,33 b' class treemanifest(object):' | |||||
347 | if fl: |
|
348 | if fl: | |
348 | self.setflag(f, fl) |
|
349 | self.setflag(f, fl) | |
349 |
|
350 | |||
|
351 | def _subpath(self, path): | |||
|
352 | return self._dir + path | |||
|
353 | ||||
350 | def __len__(self): |
|
354 | def __len__(self): | |
351 | size = len(self._files) |
|
355 | size = len(self._files) | |
352 | for m in self._dirs.values(): |
|
356 | for m in self._dirs.values(): | |
353 | size += m.__len__() |
|
357 | size += m.__len__() | |
354 | return size |
|
358 | return size | |
355 |
|
359 | |||
|
360 | def __str__(self): | |||
|
361 | return '<treemanifest dir=%s>' % self._dir | |||
|
362 | ||||
356 | def iteritems(self): |
|
363 | def iteritems(self): | |
357 | for p, n in sorted(self._dirs.items() + self._files.items()): |
|
364 | for p, n in sorted(self._dirs.items() + self._files.items()): | |
358 | if p in self._files: |
|
365 | if p in self._files: | |
359 | yield p, n |
|
366 | yield self._subpath(p), n | |
360 | else: |
|
367 | else: | |
361 |
for |
|
368 | for f, sn in n.iteritems(): | |
362 |
yield |
|
369 | yield f, sn | |
363 |
|
370 | |||
364 | def iterkeys(self): |
|
371 | def iterkeys(self): | |
365 | for p in sorted(self._dirs.keys() + self._files.keys()): |
|
372 | for p in sorted(self._dirs.keys() + self._files.keys()): | |
366 | if p in self._files: |
|
373 | if p in self._files: | |
367 | yield p |
|
374 | yield self._subpath(p) | |
368 | else: |
|
375 | else: | |
369 | for f in self._dirs[p].iterkeys(): |
|
376 | for f in self._dirs[p].iterkeys(): | |
370 |
yield |
|
377 | yield f | |
371 |
|
378 | |||
372 | def keys(self): |
|
379 | def keys(self): | |
373 | return list(self.iterkeys()) |
|
380 | return list(self.iterkeys()) | |
@@ -437,7 +444,7 b' class treemanifest(object):' | |||||
437 | dir, subpath = _splittopdir(f) |
|
444 | dir, subpath = _splittopdir(f) | |
438 | if dir: |
|
445 | if dir: | |
439 | if dir not in self._dirs: |
|
446 | if dir not in self._dirs: | |
440 | self._dirs[dir] = treemanifest() |
|
447 | self._dirs[dir] = treemanifest(self._subpath(dir)) | |
441 | self._dirs[dir].__setitem__(subpath, n) |
|
448 | self._dirs[dir].__setitem__(subpath, n) | |
442 | else: |
|
449 | else: | |
443 | self._files[f] = n |
|
450 | self._files[f] = n | |
@@ -447,13 +454,13 b' class treemanifest(object):' | |||||
447 | dir, subpath = _splittopdir(f) |
|
454 | dir, subpath = _splittopdir(f) | |
448 | if dir: |
|
455 | if dir: | |
449 | if dir not in self._dirs: |
|
456 | if dir not in self._dirs: | |
450 | self._dirs[dir] = treemanifest() |
|
457 | self._dirs[dir] = treemanifest(self._subpath(dir)) | |
451 | self._dirs[dir].setflag(subpath, flags) |
|
458 | self._dirs[dir].setflag(subpath, flags) | |
452 | else: |
|
459 | else: | |
453 | self._flags[f] = flags |
|
460 | self._flags[f] = flags | |
454 |
|
461 | |||
455 | def copy(self): |
|
462 | def copy(self): | |
456 | copy = treemanifest() |
|
463 | copy = treemanifest(self._dir) | |
457 | for d in self._dirs: |
|
464 | for d in self._dirs: | |
458 | copy._dirs[d] = self._dirs[d].copy() |
|
465 | copy._dirs[d] = self._dirs[d].copy() | |
459 | copy._files = dict.copy(self._files) |
|
466 | copy._files = dict.copy(self._files) | |
@@ -567,7 +574,7 b' class manifest(revlog.revlog):' | |||||
567 |
|
574 | |||
568 | def _newmanifest(self, data=''): |
|
575 | def _newmanifest(self, data=''): | |
569 | if self._usetreemanifest: |
|
576 | if self._usetreemanifest: | |
570 | return treemanifest(data) |
|
577 | return treemanifest('', data) | |
571 | return manifestdict(data) |
|
578 | return manifestdict(data) | |
572 |
|
579 | |||
573 | def readdelta(self, node): |
|
580 | def readdelta(self, node): |
General Comments 0
You need to be logged in to leave comments.
Login now