diff mercurial/commands.py @ 43665:f37da59a36d9

bisect: replace try:/finally: by a "restore_state" context manager This should help pytype to not consider "bgood" variable as NameError. See https://phab.mercurial-scm.org/D7384 for context. Differential Revision: https://phab.mercurial-scm.org/D7430
author Denis Laxalde <denis.laxalde@logilab.fr>
date Thu, 14 Nov 2019 10:47:04 +0100
parents 1e1bad31b427
children 71dbd6f6fcb8
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Oct 30 19:19:57 2019 -0400
+++ b/mercurial/commands.py	Thu Nov 14 10:47:04 2019 +0100
@@ -1073,7 +1073,7 @@
                 raise error.Abort(_(b'current bisect revision is a merge'))
         if rev:
             node = repo[scmutil.revsingle(repo, rev, node)].node()
-        try:
+        with hbisect.restore_state(repo, state, node):
             while changesets:
                 # update state
                 state[b'current'] = [node]
@@ -1105,9 +1105,6 @@
                 # update to next check
                 node = nodes[0]
                 mayupdate(repo, node, show_stats=False)
-        finally:
-            state[b'current'] = [node]
-            hbisect.save_state(repo, state)
         hbisect.printresult(ui, repo, state, displayer, nodes, bgood)
         return