mercurial/revset.py
changeset 26006 1ffd97cbf9a2
parent 26002 fd92bfbbe02d
child 26053 b68c9d232db6
--- a/mercurial/revset.py	Thu Aug 06 22:10:31 2015 -0700
+++ b/mercurial/revset.py	Thu Aug 06 22:11:20 2015 -0700
@@ -87,7 +87,7 @@
 
     return generatorset(iterate(), iterasc=True)
 
-def reachableroots(repo, roots, heads, includepath=False):
+def reachablerootspure(repo, minroot, roots, heads, includepath):
     """return (heads(::<roots> and ::<heads>))
 
     If includepath is True, return (<roots>::<heads>)."""
@@ -97,10 +97,6 @@
     visit = list(heads)
     reachable = set()
     seen = {}
-    # XXX this should be 'parentset.min()' assuming 'parentset' is a smartset
-    # (and if it is not, it should.)
-    minroot = min(roots)
-    roots = set(roots)
     # prefetch all the things! (because python is slow)
     reached = reachable.add
     dovisit = visit.append
@@ -128,6 +124,22 @@
                 reached(rev)
     return baseset(sorted(reachable))
 
+def reachableroots(repo, roots, heads, includepath=False):
+    """return (heads(::<roots> and ::<heads>))
+
+    If includepath is True, return (<roots>::<heads>)."""
+    if not roots:
+        return baseset()
+    # XXX this should be 'parentset.min()' assuming 'parentset' is a smartset
+    # (and if it is not, it should.)
+    minroot = min(roots)
+    roots = set(roots)
+    heads = list(heads)
+    try:
+        return repo.changelog.reachableroots(minroot, heads, roots, includepath)
+    except AttributeError:
+        return reachablerootspure(repo, minroot, roots, heads, includepath)
+
 elements = {
     # token-type: binding-strength, primary, prefix, infix, suffix
     "(": (21, None, ("group", 1, ")"), ("func", 1, ")"), None),