[PATCH 2 of 6] revset: refactor parents() into a single return point
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Thu Sep 18 21:40:55 UTC 2014
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1411008243 25200
# Wed Sep 17 19:44:03 2014 -0700
# Node ID fd7037c893a0471fee398c230b4b7a247ae5a561
# Parent a49c721cc8d57a107cb883ee1dc3406183a70e1a
revset: refactor parents() into a single return point
Both path are doing similar thing at 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
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1229,17 +1229,16 @@ def p2(repo, subset, x):
def parents(repo, subset, x):
"""``parents([set])``
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):
"""``set^0``
The set.
More information about the Mercurial-devel
mailing list