Show More
@@ -466,39 +466,40 b' class filectx(object):' | |||||
466 | else: |
|
466 | else: | |
467 | base = self |
|
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 | needed = {base: 1} |
|
476 | needed = {base: 1} | |
471 | visit = [base] |
|
|||
472 | files = [base._path] |
|
|||
473 | while visit: |
|
477 | while visit: | |
474 |
f = visit |
|
478 | f = visit[-1] | |
475 |
f |
|
479 | if f not in pcache: | |
476 | if p not in needed: |
|
480 | pcache[f] = parents(f) | |
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 |
|
|||
484 |
|
481 | |||
485 | # sort by revision (per file) which is a topological order |
|
482 | ready = True | |
486 | visit = [] |
|
483 | pl = pcache[f] | |
487 |
for |
|
484 | for p in pl: | |
488 | visit.extend(n for n in needed if n._path == f) |
|
485 | if p not in hist: | |
489 |
|
486 | ready = False | ||
490 | hist = {} |
|
487 | visit.append(p) | |
491 | for f in sorted(visit, key=lambda x: x.rev()): |
|
488 | needed[p] = needed.get(p, 0) + 1 | |
|
489 | if ready: | |||
|
490 | visit.pop() | |||
492 | curr = decorate(f.data(), f) |
|
491 | curr = decorate(f.data(), f) | |
493 |
for p in p |
|
492 | for p in pl: | |
494 | curr = pair(hist[p], curr) |
|
493 | curr = pair(hist[p], curr) | |
495 |
|
|
494 | if needed[p] == 1: | |
|
495 | del hist[p] | |||
|
496 | else: | |||
496 | needed[p] -= 1 |
|
497 | needed[p] -= 1 | |
497 | if not needed[p]: |
|
498 | ||
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 | def ancestor(self, fc2, actx=None): |
|
504 | def ancestor(self, fc2, actx=None): | |
504 | """ |
|
505 | """ |
General Comments 0
You need to be logged in to leave comments.
Login now