changelog: add way to call the reachableroots C implementation
authorLaurent Charignon <lcharignon@fb.com>
Thu, 06 Aug 2015 22:10:31 -0700
changeset 26005 6f4a280298c1
parent 26004 ff89383a97db
child 26006 1ffd97cbf9a2
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.
mercurial/changelog.py
--- a/mercurial/changelog.py	Thu Aug 06 21:28:45 2015 -0700
+++ b/mercurial/changelog.py	Thu Aug 06 22:10:31 2015 -0700
@@ -18,6 +18,7 @@
     encoding,
     error,
     revlog,
+    revset,
     util,
 )
 
@@ -184,6 +185,16 @@
         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: