python / cherry-picker

πŸπŸ’β› Utility script for backporting/cherry-picking CPython changes from master into one of the maintenance branches.
Apache License 2.0
46 stars 38 forks source link

Unexpected run state encountered #65

Open vsajip opened 1 year ago

vsajip commented 1 year ago

When trying to backport this PR, miss-islington failed and advised running cherry_picker from the CLI. When running

cherry_picker 067597522a9002f3b8aff7f46033f10acb2381e4 3.11

It failed with this traceback:

~/projects/cpython/3.11 [3.11|βœ”] $ Doc/venv/bin/cherry_picker 067597522a9002f3b8aff7f46033f10acb2381e4 3.11
🐍 πŸ’ ⛏
Now backporting '067597522a9002f3b8aff7f46033f10acb2381e4' into '3.11'
[backport-0675975-3.11 5beb16b77f] gh-92897: Ensure `venv --copies` respects source build property of the creating interpreter (GH-92899)
 Author: Jeremy Kloth <jeremy.kloth@gmail.com>
 Date: Tue Jul 5 10:08:20 2022 -0500
 5 files changed, 76 insertions(+), 40 deletions(-)

Backport PR URL:
https://github.com/python/cpython/compare/3.11...vsajip:backport-0675975-3.11?expand=1
Traceback (most recent call last):
  File "/disk2/vinay/projects/cpython/3.11/Doc/venv/bin/cherry_picker", line 8, in <module>
    sys.exit(cherry_pick_cli())
             ^^^^^^^^^^^^^^^^^
  File "/disk2/vinay/projects/cpython/3.11/Doc/venv/lib/python3.12/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/disk2/vinay/projects/cpython/3.11/Doc/venv/lib/python3.12/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/disk2/vinay/projects/cpython/3.11/Doc/venv/lib/python3.12/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/disk2/vinay/projects/cpython/3.11/Doc/venv/lib/python3.12/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/disk2/vinay/projects/cpython/3.11/Doc/venv/lib/python3.12/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/disk2/vinay/projects/cpython/3.11/Doc/venv/lib/python3.12/site-packages/cherry_picker/cherry_picker.py", line 645, in cherry_pick_cli
    cherry_picker.backport()
    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/disk2/vinay/projects/cpython/3.11/Doc/venv/lib/python3.12/site-packages/cherry_picker/cherry_picker.py", line 400, in backport
    self.cleanup_branch(cherry_pick_branch)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/disk2/vinay/projects/cpython/3.11/Doc/venv/lib/python3.12/site-packages/cherry_picker/cherry_picker.py", line 361, in cleanup_branch
    self.checkout_default_branch()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/disk2/vinay/projects/cpython/3.11/Doc/venv/lib/python3.12/site-packages/cherry_picker/cherry_picker.py", line 226, in checkout_default_branch
    self.run_cmd(cmd)
    ^^^^^^^^^^^^^^^^^
  File "/disk2/vinay/projects/cpython/3.11/Doc/venv/lib/python3.12/site-packages/cherry_picker/cherry_picker.py", line 181, in run_cmd
    output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vinay/.local/lib/python3.12/subprocess.py", line 454, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vinay/.local/lib/python3.12/subprocess.py", line 558, in run
    raise CalledProcessError(retcode, process.args,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
subprocess.CalledProcessError: Command '('git', 'checkout', 'main')' returned non-zero exit status 128.

Now I was in the 3.11 branch so I'm not sure it should be doing a git checkout main. But anyway, the PR was created (in that it opened the "Create pull request" page in the browser, which I clicked to confirm - the PR is here. But if I now try to do the same thing for 3.10, I get

~/projects/cpython/3.10 [3.10|βœ”] $ Doc/venv/bin/cherry_picker 067597522a9002f3b8aff7f46033f10acb2381e4 3.10
🐍 πŸ’ ⛏
Usage: cherry_picker [OPTIONS] [COMMIT_SHA1] [BRANCHES]...
Try 'cherry_picker -h' for help.

Error: Run state cherry-picker.state=CHECKING_OUT_DEFAULT_BRANCH in Git config is not known.
Perhaps it has been set by a newer version of cherry-picker. Try upgrading.
Valid states are: BACKPORT_PAUSED, UNSET. If this looks suspicious, raise an issue at https://github.com/python/cherry-picker/issues/new.
As the last resort you can reset the runtime state stored in Git config using the following command: `git config --local --remove-section cherry-picker`

I did git config --local --remove-section cherry-picker and tried again, but now I get

~/projects/cpython/3.10 [3.10|βœ”] $ git config --local --remove-section cherry-picker
~/projects/cpython/3.10 [3.10|βœ”] $ Doc/venv/bin/cherry_picker 067597522a9002f3b8aff7f46033f10acb2381e4 3.10
🐍 πŸ’ ⛏
Traceback (most recent call last):
  File "/disk2/vinay/projects/cpython/3.10/Doc/venv/bin/cherry_picker", line 8, in <module>
    sys.exit(cherry_pick_cli())
             ^^^^^^^^^^^^^^^^^
  File "/disk2/vinay/projects/cpython/3.10/Doc/venv/lib/python3.12/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/disk2/vinay/projects/cpython/3.10/Doc/venv/lib/python3.12/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/disk2/vinay/projects/cpython/3.10/Doc/venv/lib/python3.12/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/disk2/vinay/projects/cpython/3.10/Doc/venv/lib/python3.12/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/disk2/vinay/projects/cpython/3.10/Doc/venv/lib/python3.12/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/disk2/vinay/projects/cpython/3.10/Doc/venv/lib/python3.12/site-packages/cherry_picker/cherry_picker.py", line 645, in cherry_pick_cli
    cherry_picker.backport()
    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/disk2/vinay/projects/cpython/3.10/Doc/venv/lib/python3.12/site-packages/cherry_picker/cherry_picker.py", line 375, in backport
    self.fetch_upstream()
    ^^^^^^^^^^^^^^^^^^^^^
  File "/disk2/vinay/projects/cpython/3.10/Doc/venv/lib/python3.12/site-packages/cherry_picker/cherry_picker.py", line 173, in fetch_upstream
    self.run_cmd(cmd)
    ^^^^^^^^^^^^^^^^^
  File "/disk2/vinay/projects/cpython/3.10/Doc/venv/lib/python3.12/site-packages/cherry_picker/cherry_picker.py", line 181, in run_cmd
    output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vinay/.local/lib/python3.12/subprocess.py", line 454, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vinay/.local/lib/python3.12/subprocess.py", line 558, in run
    raise CalledProcessError(retcode, process.args,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
subprocess.CalledProcessError: Command '['git', 'fetch', 'upstream', '--no-tags']' returned non-zero exit status 1.
ezio-melotti commented 1 year ago

Now I was in the 3.11 branch so I'm not sure it should be doing a git checkout main

It looks like it successfully backported your PR, and while cleaning up and switching back to main (which is expected at this stage) an error occurred. That left miss-islington in an inconsistent state that you fixed with git config --local --remove-section cherry-picker.

I did git config --local --remove-section cherry-picker and tried again, but now I get

Not sure about this last traceback though. Maybe just network issues or GitHub being down? It seems you were eventually able to create the PR -- did the same command succeed when you ran it a second time?

vsajip commented 1 year ago

Yes, it did - perhaps it was a transient network issue. GitHub seemed generally fine - I was able to monitor the tests, close the issue once they completed etc. I just logged this issue to help fix whatever caused the inconsistent state to occur. You can close it if you don't need it for that purpose.

ezio-melotti commented 1 year ago

I ran into errors in the past that required a git config --local --remove-section cherry-picker. Perhaps miss-islington should clean up after herself in case of failure, even though the current design might be intentional in case people want to complete the backport and/or clean up things manually.