revset: use try-except instead of if-else because of perf
authorPulkit Goyal <7895pulkit@gmail.com>
Mon, 22 May 2017 02:03:43 +0530
changeset 32439 e72c5263ccaf
parent 32438 14482f8e6ce6
child 32440 c8fb2a82b5f9
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.
mercurial/revset.py
--- 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