diff mercurial/changelog.py @ 22484:2b5940f64750

obsolete: use C code for headrevs calculation Previously, if there were filtered revs the repository could not use the C fast path for computing the head revs in the changelog. This slowed down many operations in large repositories. This adds the ability to filter revs to the C fast path. This speeds up histedit on repositories with filtered revs by 30% (13s to 9s). This could be improved further by sorting the filtered revs and walking the sorted list while we walk the changelog, but even this initial version that just calls __contains__ is still massively faster. The new C api is compatible for both new and old python clients, and the new python client can call both new and old C apis.
author Durham Goode <durham@fb.com>
date Tue, 16 Sep 2014 16:03:21 -0700
parents 667df8f478d1
children f00813325c5a
line wrap: on
line diff
--- a/mercurial/changelog.py	Tue Sep 16 23:47:34 2014 -0700
+++ b/mercurial/changelog.py	Tue Sep 16 16:03:21 2014 -0700
@@ -171,8 +171,13 @@
 
     def headrevs(self):
         if self.filteredrevs:
-            # XXX we should fix and use the C version
-            return self._headrevs()
+            try:
+                return self.index.headrevs(self.filteredrevs)
+            # AttributeError covers non-c-extension environments.
+            # TypeError allows us work with old c extensions.
+            except (AttributeError, TypeError):
+                return self._headrevs()
+
         return super(changelog, self).headrevs()
 
     def strip(self, *args, **kwargs):