bisect: abstract a separate for updating state

Summary: we will update this function in the following diffs, abstract it to a separate function will avoid making the main function too complex

Reviewed By: muirdm

Differential Revision: D46643577

fbshipit-source-id: 227e0b60fe2efa1d6d00fa409ea95a30cc972747
This commit is contained in:
Zhaolong Zhu 2023-06-14 11:07:02 -07:00 committed by Facebook GitHub Bot
parent cbee0a7aaf
commit 9772bf3c76

View File

@ -1001,16 +1001,7 @@ def bisect(
# update state
if good or bad or skip:
if rev:
nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])]
else:
nodes = [repo.lookup(".")]
if good:
state["good"] += nodes
elif bad:
state["bad"] += nodes
elif skip:
state["skip"] += nodes
_update_state(repo, state, rev, good, bad, skip)
hbisect.save_state(repo, state)
if not (state["good"] and state["bad"]):
return
@ -1182,6 +1173,19 @@ the sparse profile from the known %s changeset %s\n"
return mayupdate(repo, node)
def _update_state(repo, state, rev, good, bad, skip):
if rev:
nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])]
else:
nodes = [repo.lookup(".")]
if good:
state["good"] += nodes
elif bad:
state["bad"] += nodes
elif skip:
state["skip"] += nodes
@command(
"bookmark|bo|book",
[