holdenk commented on code in PR #60471:
URL: https://github.com/apache/spark/pull/60471#discussion_r4584872107
##########
dev/merge_spark_pr.py:
##########
@@ -3568,6 +4158,47 @@ def main():
__test__ = {
+ "abort_entrypoint": """
+ After [a]bort at the checkout-retry prompt no git runs again, by any route
out: the CLI
+ handler, or a fail() in main()'s finally blocks such as declining the JIRA
prompt. An
+ ordinary exit still cleans up.
+
+ >>> import ast, doctest
+ >>> from pathlib import Path
+ >>> from contextlib import redirect_stdout
+ >>> from io import StringIO
+ >>> from unittest.mock import patch
+ >>> entrypoint = ast.parse(Path(__file__).read_text()).body[-1]
Review Comment:
Fixed in 7ebc62246db: `read_bytes()`, as suggested. Checked under `LC_ALL=C
PYTHONCOERCECLOCALE=0 python3 -X utf8=0`: with `read_text()` three
`abort_entrypoint` examples fail, with `read_bytes()` the whole self-test
passes. A doctest cannot fail on a UTF-8 locale either way, so this one only
shows up under a locale that cannot decode the file.
---
<sub>🤖 Posted by an AI agent (Claude Code · skill `none`) on behalf of
@holdenk.</sub>
<!-- agent-attribution v1: agent=claude-code; skill=none; operator=holdenk
-->
##########
dev/merge_spark_pr.py:
##########
@@ -3568,6 +4158,47 @@ def main():
__test__ = {
+ "abort_entrypoint": """
+ After [a]bort at the checkout-retry prompt no git runs again, by any route
out: the CLI
+ handler, or a fail() in main()'s finally blocks such as declining the JIRA
prompt. An
+ ordinary exit still cleans up.
+
+ >>> import ast, doctest
+ >>> from pathlib import Path
+ >>> from contextlib import redirect_stdout
+ >>> from io import StringIO
+ >>> from unittest.mock import patch
+ >>> entrypoint = ast.parse(Path(__file__).read_text()).body[-1]
+ >>> code = compile(ast.Module(body=[entrypoint], type_ignores=[]),
__file__, "exec")
+ >>> refused = subprocess.CalledProcessError(1, "git checkout")
+ >>> def abort_then_fail():
+ ... try:
+ ... _restore_original_head()
+ ... finally:
+ ... fail("Okay, exiting")
+ >>> def ordinary_exit():
+ ... raise SystemExit(-1)
+ >>> for entry in (_restore_original_head, abort_then_fail, ordinary_exit):
+ ... with (
+ ... patch.object(doctest, "testmod", return_value=(0, 0)),
+ ... patch.dict(clean_up.__globals__, original_head="master",
+ ... preserve_local_state=False),
+ ... patch.object(git, "run", side_effect=refused) as run,
+ ... patch("builtins.input", side_effect=["a"]),
redirect_stdout(StringIO()),
+ ... ):
+ ... try:
+ ... exec(code, dict(globals(), __name__="__main__",
main=entry))
+ ... except BaseException as e:
+ ... ended = getattr(e, "code", type(e).__name__)
+ ... cmds = [c.args[0] if isinstance(c.args[0], str) else "
".join(c.args[0])
+ ... for c in run.call_args_list]
+ ... print(entry.__name__, [cmd.split()[1] for cmd in cmds], ended)
+ _restore_original_head ['checkout'] -1
+ abort_then_fail ['checkout'] -1
+ ordinary_exit ['checkout'] CalledProcessError
+ >>> preserve_local_state
Review Comment:
Fixed in 7ebc62246db: the closing check reads
`clean_up.__globals__["preserve_local_state"]`. I also added the guard you
described: the entry point exits before `main()` if the flag is still set after
`testmod()`, so a leak from a later example such as `continue_maybe`'s is
caught too, and the doctest replays the entry point with the flag set to show
it stops before `main()`.
Mutation checks: leaking the flag before the closing check fails the fixed
doctest and still passes the old bare-name one; dropping the guard fails its
doctest.
---
<sub>🤖 Posted by an AI agent (Claude Code · skill `none`) on behalf of
@holdenk.</sub>
<!-- agent-attribution v1: agent=claude-code; skill=none; operator=holdenk
-->
##########
dev/merge_spark_pr.py:
##########
@@ -1368,6 +1924,27 @@ def cherry_pick(pr_num, merge_hash, default_branch,
branch_names, target_ref, al
and record each backport commit for the merge comment. The list is empty
(or, for the
Upstream-First two-branch path, holds only what landed) when the committer
declines to
resolve a conflict, so the caller simply offers the next branch and still
resolves JIRA.
+ `record` gets each pair as it lands, so one survives a later pick that
ends the run:
Review Comment:
Fixed in 7ebc62246db: the docstring and the `[b]oth` comment now say
`main()` learns of picks only through `record`, name both skip conditions
(declined conflict, declined pre-push check) as recording nothing, and say the
returned list repeats the recorded pairs and nothing reads it.
---
<sub>🤖 Posted by an AI agent (Claude Code · skill `none`) on behalf of
@holdenk.</sub>
<!-- agent-attribution v1: agent=claude-code; skill=none; operator=holdenk
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]