Show More
@@ -466,39 +466,40 b' class filectx(object):' | |||
|
466 | 466 | else: |
|
467 | 467 | base = self |
|
468 | 468 | |
|
469 | # find all ancestors | |
|
469 | # This algorithm would prefer to be recursive, but Python is a | |
|
470 | # bit recursion-hostile. Instead we do an iterative | |
|
471 | # depth-first search. | |
|
472 | ||
|
473 | visit = [base] | |
|
474 | hist = {} | |
|
475 | pcache = {} | |
|
470 | 476 | needed = {base: 1} |
|
471 | visit = [base] | |
|
472 | files = [base._path] | |
|
473 | 477 | while visit: |
|
474 |
f = visit |
|
|
475 |
f |
|
|
476 | if p not in needed: | |
|
477 | needed[p] = 1 | |
|
478 | visit.append(p) | |
|
479 | if p._path not in files: | |
|
480 | files.append(p._path) | |
|
481 | else: | |
|
482 | # count how many times we'll use this | |
|
483 | needed[p] += 1 | |
|
478 | f = visit[-1] | |
|
479 | if f not in pcache: | |
|
480 | pcache[f] = parents(f) | |
|
484 | 481 | |
|
485 | # sort by revision (per file) which is a topological order | |
|
486 | visit = [] | |
|
487 |
for |
|
|
488 | visit.extend(n for n in needed if n._path == f) | |
|
482 | ready = True | |
|
483 | pl = pcache[f] | |
|
484 | for p in pl: | |
|
485 | if p not in hist: | |
|
486 | ready = False | |
|
487 | visit.append(p) | |
|
488 | needed[p] = needed.get(p, 0) + 1 | |
|
489 | if ready: | |
|
490 | visit.pop() | |
|
491 | curr = decorate(f.data(), f) | |
|
492 | for p in pl: | |
|
493 | curr = pair(hist[p], curr) | |
|
494 | if needed[p] == 1: | |
|
495 | del hist[p] | |
|
496 | else: | |
|
497 | needed[p] -= 1 | |
|
489 | 498 | |
|
490 |
hist = |
|
|
491 | for f in sorted(visit, key=lambda x: x.rev()): | |
|
492 | curr = decorate(f.data(), f) | |
|
493 | for p in parents(f): | |
|
494 | curr = pair(hist[p], curr) | |
|
495 | # trim the history of unneeded revs | |
|
496 | needed[p] -= 1 | |
|
497 | if not needed[p]: | |
|
498 | del hist[p] | |
|
499 | hist[f] = curr | |
|
499 | hist[f] = curr | |
|
500 | pcache[f] = [] | |
|
500 | 501 | |
|
501 |
return zip(hist[ |
|
|
502 | return zip(hist[base][0], hist[base][1].splitlines(True)) | |
|
502 | 503 | |
|
503 | 504 | def ancestor(self, fc2, actx=None): |
|
504 | 505 | """ |
General Comments 0
You need to be logged in to leave comments.
Login now