changeset 32439:e72c5263ccaf

revset: use try-except instead of if-else because of perf For wdir(), we now raises an exception which will be raised when wdir() will be passed, so catching that exception is better checking for wdir() using if-else.
author Pulkit Goyal <7895pulkit@gmail.com>
date Mon, 22 May 2017 02:03:43 +0530
parents 14482f8e6ce6
children c8fb2a82b5f9
files mercurial/revset.py
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Mon May 22 01:38:00 2017 +0530
+++ b/mercurial/revset.py	Mon May 22 02:03:43 2017 +0530
@@ -1456,10 +1456,10 @@
         up = ps.update
         parentrevs = cl.parentrevs
         for r in getset(repo, fullreposet(repo), x):
-            if r == node.wdirrev:
+            try:
+                up(parentrevs(r))
+            except error.WdirUnsupported:
                 up(p.rev() for p in repo[r].parents())
-            else:
-                up(parentrevs(r))
     ps -= {node.nullrev}
     return subset & ps