# HG changeset patch # User Laurent Charignon # Date 2015-08-07 05:10:31 # Node ID 6f4a280298c13c56cf0f982f1082b69f6aaa765a # Parent ff89383a97db7063d6685a6b65832dc5b871657c changelog: add way to call the reachableroots C implementation This patch is part of a series of patches to speed up the computation of revset.reachableroots by introducing a C implementation. The main motivation is to speed up smartlog on big repositories. At the end of the series, on our big repositories the computation of reachableroots is 10-50x faster and smartlog on is 2x-5x faster. This patch allows us to call the new C implementation of reachableroots from python by creating an entry point in the changelog class. diff --git a/mercurial/changelog.py b/mercurial/changelog.py --- a/mercurial/changelog.py +++ b/mercurial/changelog.py @@ -18,6 +18,7 @@ from . import ( encoding, error, revlog, + revset, util, ) @@ -184,6 +185,16 @@ class changelog(revlog.revlog): self.rev(self.node(0)) return self._nodecache + def reachableroots(self, minroot, heads, roots, includepath=False): + reachable = self.index.reachableroots(minroot, heads, roots, + includepath) + if reachable is None: + # The C code hasn't been able to initialize a list, something went + # really wrong, let's rely on the pure implementation in that case + raise AttributeError() + else: + return revset.baseset(sorted(reachable)) + def headrevs(self): if self.filteredrevs: try: