##// END OF EJS Templates
bisect: replace try:/finally: by a "restore_state" context manager...
Denis Laxalde -
r44064:f37da59a default
parent child Browse files
Show More
@@ -1073,7 +1073,7 b' def bisect('
1073 1073 raise error.Abort(_(b'current bisect revision is a merge'))
1074 1074 if rev:
1075 1075 node = repo[scmutil.revsingle(repo, rev, node)].node()
1076 try:
1076 with hbisect.restore_state(repo, state, node):
1077 1077 while changesets:
1078 1078 # update state
1079 1079 state[b'current'] = [node]
@@ -1105,9 +1105,6 b' def bisect('
1105 1105 # update to next check
1106 1106 node = nodes[0]
1107 1107 mayupdate(repo, node, show_stats=False)
1108 finally:
1109 state[b'current'] = [node]
1110 hbisect.save_state(repo, state)
1111 1108 hbisect.printresult(ui, repo, state, displayer, nodes, bgood)
1112 1109 return
1113 1110
@@ -11,6 +11,7 b''
11 11 from __future__ import absolute_import
12 12
13 13 import collections
14 import contextlib
14 15
15 16 from .i18n import _
16 17 from .node import (
@@ -180,6 +181,15 b' def checkstate(state):'
180 181 raise error.Abort(_(b'cannot bisect (no known bad revisions)'))
181 182
182 183
184 @contextlib.contextmanager
185 def restore_state(repo, state, node):
186 try:
187 yield
188 finally:
189 state[b'current'] = [node]
190 save_state(repo, state)
191
192
183 193 def get(repo, status):
184 194 """
185 195 Return a list of revision(s) that match the given status:
General Comments 0
You need to be logged in to leave comments. Login now