diff -r da178b816812 -r 06b64fabf91c mercurial/copies.py --- a/mercurial/copies.py Fri Nov 20 10:34:26 2020 -0800 +++ b/mercurial/copies.py Mon Nov 02 11:03:56 2020 +0100 @@ -230,6 +230,24 @@ return revinfo +def cached_is_ancestor(is_ancestor): + """return a cached version of is_ancestor""" + cache = {} + + def _is_ancestor(anc, desc): + if anc > desc: + return False + elif anc == desc: + return True + key = (anc, desc) + ret = cache.get(key) + if ret is None: + ret = cache[key] = is_ancestor(anc, desc) + return ret + + return _is_ancestor + + def _changesetforwardcopies(a, b, match): if a.rev() in (node.nullrev, b.rev()): return {} @@ -238,7 +256,7 @@ children = {} cl = repo.changelog - isancestor = cl.isancestorrev # XXX we should had chaching to this. + isancestor = cached_is_ancestor(cl.isancestorrev) missingrevs = cl.findmissingrevs(common=[a.rev()], heads=[b.rev()]) mrset = set(missingrevs) roots = set()