comparison mercurial/context.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 c3b920980f22
children a54ddfae8907
comparison
equal deleted inserted replaced
18982:43cb150e74f9 18986:2f7186400a07
754 pl.append(re) 754 pl.append(re)
755 acache[vertex] = pl 755 acache[vertex] = pl
756 return pl 756 return pl
757 757
758 a, b = (self._path, self._filenode), (fc2._path, fc2._filenode) 758 a, b = (self._path, self._filenode), (fc2._path, fc2._filenode)
759 v = ancestor.ancestor(a, b, parents) 759 v = ancestor.genericancestor(a, b, parents)
760 if v: 760 if v:
761 f, n = v 761 f, n = v
762 return filectx(self._repo, f, fileid=n, filelog=flcache[f]) 762 return filectx(self._repo, f, fileid=n, filelog=flcache[f])
763 763
764 return None 764 return None