# HG changeset patch
# User Patrick Mezard <patrick@mezard.eu>
# Date 2012-04-08 09:13:06
# Node ID c3fd35f88fbbf0c94aff8d81ffc830950b41fdaf
# Parent  f3df7d34791e7d6b03a274ff2064458c965fa629

revset: retrieve a bit less parents in roots()

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -814,8 +814,9 @@ def roots(repo, subset, x):
     Changesets in set with no parent changeset in set.
     """
     s = set(getset(repo, xrange(len(repo)), x))
+    subset = [r for r in subset if r in s]
     cs = _children(repo, subset, s)
-    return [r for r in subset if r in s and r not in cs]
+    return [r for r in subset if r not in cs]
 
 def secret(repo, subset, x):
     """``secret()``