@@ -557,60 +557,83 @@ dismissing your previous review that requested changes.
557557Note that pushing new changes after the auto-merge flow was enabled
558558does **NOT ** stop it.
559559
560+
561+ .. _branch-merge :
562+
560563Backporting merged changes
561564--------------------------
562565
563- A pull request may need to be backported into one of the maintenance branches
564- after it has been accepted and merged into ``main ``. It is usually indicated
565- by the label ``needs backport to X.Y `` on the pull request itself.
566+ After a pull request has been merged into ``main ``, it may need to be backported
567+ to one or more :ref: `maintenance <maintbranch >` or :ref: `security <secbranch >`
568+ branches. This is indicated by the :samp: `needs backport to { X.Y } ` labels on
569+ the pull request.
566570
567- Use the utility script
568- `cherry_picker.py <https://github.com/python/cherry-picker >`__
569- to backport the commit.
571+ ``miss-islington `` will automatically attempt to create backport PRs for the
572+ versions indicated by these labels. If ``miss-islington `` cannot create a
573+ backport PR due to conflicts, you can use the :pypi: `cherry-picker ` tool to
574+ create the backport and resolve the conflicts manually.
570575
571- The commit hash for backporting is the squashed commit that was merged to
572- the ``main `` branch. On the merged pull request, scroll to the bottom of the
573- page. Find the event that says something like:
576+ You need the commit hash of the squashed commit that was merged into
577+ the ``main `` branch. ``miss-islington `` should post a comment when it is unable
578+ to create the backport automatically, including the full command and commit hash.
579+ If that comment is not posted, look for an event on the merged
580+ pull request similar to:
574581
575582.. code-block :: text
576583
577584 <core_developer> merged commit <commit_sha1> into python:main <sometime> ago.
578585
579- By following the link to ``<commit_sha1> ``, you will get the full commit hash.
586+ By following the link to ``<commit_sha1> ``, you can get the full commit hash.
580587
581- Alternatively, the commit hash can also be obtained by the following Git
588+ Alternatively, the commit hash can also be obtained with the following Git
582589commands::
583590
584591 $ git fetch upstream
585- $ git rev-parse ":/gh-12345"
592+ $ git rev-parse ":/gh-<PR number>"
593+
594+ These commands print the hash of the commit whose message contains ``gh-<PR number> ``.
586595
587- The above commands will print out the hash of the commit containing
588- ``"gh-12345" `` as part of the commit message.
596+ You can then use the commit hash and the :pypi: `cherry-picker ` tool to create
597+ the backport. In the following command, ``<branch> `` is the target maintenance
598+ branch (for example, ``3.12 ``):
599+
600+ .. code-block :: text
589601
590- When formatting the commit message for a backport commit: leave the original
591- one as is and delete the number of the backport pull request.
602+ $ cherry_picker <commit_sha1> <branch>
592603
593- ✅ Example of good backport commit message:
604+ Then, follow the instructions provided. You will have to identify the files
605+ with conflicts, fix them, and build and run applicable tests if necessary.
606+ When you are finished, ``git add `` all modified files and run
607+ ``cherry_picker --continue `` to push the backport.
608+
609+ The tool usually generates the commit message automatically. If it does not, use
610+ the following format: Keep the original commit message unchanged, except for
611+ removing the backport pull request number (``(#XXXXX) ``). At the end of the
612+ message, append a ``(cherry picked from commit <commit_sha1>) `` line.
613+
614+ The format of a correct backport commit message is:
594615
595616.. code-block :: text
596617 :class: good
597618
598- gh-12345: Improve the spam module (GH-777 )
619+ [<branch>] gh-XXXXX: <original commit title> (GH-XXXXX )
599620
600- * Add method A to the spam module
601- * Update the documentation of the spam module
621+ <original commit body>
602622
603- (cherry picked from commit 62adc55 )
623+ (cherry picked from commit <commit_sha1> )
604624
605- ❌ Example of bad backport commit message:
625+ An example of a bad backport commit message:
606626
607627.. code-block :: text
608628 :class: bad
609629
610- gh-12345: Improve the spam module (GH-777) (#888)
630+ gh-XXXXX: Custom title (GH-XXXXX) (#XXXXX)
631+
632+ * Custom message
633+
634+ After the backport PR is opened, ``miss-islington `` will link it to the original
635+ PR and remove the corresponding backport label.
611636
612- * Add method A to the spam module
613- * Update the documentation of the spam module
614637
615638Editing a pull request prior to merging
616639---------------------------------------
0 commit comments