diff -r bde66eb4051d -r f37da59a36d9 mercurial/hbisect.py --- a/mercurial/hbisect.py Wed Oct 30 19:19:57 2019 -0400 +++ b/mercurial/hbisect.py Thu Nov 14 10:47:04 2019 +0100 @@ -11,6 +11,7 @@ from __future__ import absolute_import import collections +import contextlib from .i18n import _ from .node import ( @@ -180,6 +181,15 @@ raise error.Abort(_(b'cannot bisect (no known bad revisions)')) +@contextlib.contextmanager +def restore_state(repo, state, node): + try: + yield + finally: + state[b'current'] = [node] + save_state(repo, state) + + def get(repo, status): """ Return a list of revision(s) that match the given status: