Mercurial > public > mercurial-scm > hg-stable
diff mercurial/revlog.py @ 18986:2f7186400a07
ancestor: a new algorithm that is faster for nodes near tip
Instead of walking all the way to the root of the DAG, we generate
a set of candidate GCA revs, then figure out which ones will win
the race to the root (usually without needing to traverse all the
way to the root).
In the common case of nodes that are close to each other in both
revision number and topology, this is usually a big win: it makes
"hg --time debugancestors" up to 9 times faster than the more general
ancestor function when measured on heads of the linux-2.6 hg repo.
Victory is not assured, however. The older function can still win
by a large margin if one node is much closer to the root than the
other, or by a much smaller amount if one is an ancestor of the
other.
For now, we've also got a small paranoid harness function that calls
both ancestor functions on every input and ensures that they give
equivalent answers.
Even without the checker function, the old ancestor function needs
to stay alive for the time being, as its generality is used by
context.filectx.merge.
author | Bryan O'Sullivan <bryano@fb.com> |
---|---|
date | Tue, 16 Apr 2013 10:08:18 -0700 |
parents | b280f3bfc8a0 |
children | 3605d4e7e618 |
line wrap: on
line diff
--- a/mercurial/revlog.py Mon Apr 15 01:59:11 2013 +0200 +++ b/mercurial/revlog.py Tue Apr 16 10:08:18 2013 -0700 @@ -711,10 +711,7 @@ if self.descendant(start, end): return self.node(start) - def parents(rev): - return [p for p in self.parentrevs(rev) if p != nullrev] - - c = ancestor.ancestor(a, b, parents) + c = ancestor.ancestor(a, b, self.parentrevs) if c is None: return nullid