revset: refactor parents() into a single return point
authorPierre-Yves David <pierre-yves.david@fb.com>
Wed, 17 Sep 2014 19:44:03 -0700
changeset 22496 35af9361a049
parent 22495 668b26d32bf6
child 22497 8ea3f47bcaff
revset: refactor parents() into a single return point Both paths are doing similar thing in the end. We refactor the function so that the `ps` set is commonly used at the end. This will end excluding `nullrev` from this set in a future patch
mercurial/revset.py
--- a/mercurial/revset.py	Wed Sep 17 04:40:30 2014 -0700
+++ b/mercurial/revset.py	Wed Sep 17 19:44:03 2014 -0700
@@ -1231,13 +1231,12 @@
     The set of all parents for all changesets in set, or the working directory.
     """
     if x is None:
-        ps = tuple(p.rev() for p in repo[x].parents())
-        return subset & ps
-
-    ps = set()
-    cl = repo.changelog
-    for r in getset(repo, spanset(repo), x):
-        ps.update(cl.parentrevs(r))
+        ps = set(p.rev() for p in repo[x].parents())
+    else:
+        ps = set()
+        cl = repo.changelog
+        for r in getset(repo, spanset(repo), x):
+            ps.update(cl.parentrevs(r))
     return baseset(ps) & subset
 
 def parentspec(repo, subset, x, n):