Mercurial > kallithea
changeset 4342:efc911d7b217
graph: refactor first known ancestor calculation
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Tue, 10 Dec 2013 19:30:37 +0100 |
parents | ab89f7ce2c0b |
children | b20330417f57 |
files | kallithea/lib/graphmod.py |
diffstat | 1 files changed, 8 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/graphmod.py Tue Dec 10 19:30:37 2013 +0100 +++ b/kallithea/lib/graphmod.py Tue Dec 10 19:30:37 2013 +0100 @@ -28,14 +28,14 @@ pending = set([head]) seen = set() ancestors = set() - minrev = max(nullrev, minrev) while pending: r = pending.pop() - if r >= minrev and r not in seen: - if r in knownrevs: - ancestors.add(r) - else: - pending.update(parentrev_func(r)) + if r < minrev: + pass + elif r in knownrevs: + ancestors.add(r) + elif r not in seen: + pending.update(parentrev_func(r)) seen.add(r) return ancestors @@ -65,7 +65,7 @@ def parentrev_func(rev): return [x.revision for x in repo[rev].parents] - minrev = min(revs) + minrev = revs[-1] # assuming sorted reverse knownrevs = set(revs) acache = {} for rev in revs: @@ -76,10 +76,7 @@ ancestors = acache.get(p) if ancestors is None: ancestors = acache[p] = _first_known_ancestors(parentrev_func, minrev, knownrevs, p) - if ancestors: # some indirect known ancestors found - use them and ignore unknown ancestors - dagparents.update(ancestors) - else: # no known ancestors - use the real but unknown parent - dagparents.add(p) + dagparents.update(ancestors) yield (rev, sorted(dagparents))