Skip to content

Instantly share code, notes, and snippets.

@retronym
Created November 14, 2012 13:32
Show Gist options
  • Save retronym/4072080 to your computer and use it in GitHub Desktop.
Save retronym/4072080 to your computer and use it in GitHub Desktop.
Backport process

Avoiding backporting

If possible, target commits at the 2.10.x branch rather than master. This can be done if the change is:

  • Binary compatible (for scala-library)
  • Source compatible (for unofficial compiler API used by SBT, IDE)
  • Well isolated, doesn't involve sweeping structural changes
  • Well tested. (but this must be true, otherwise it wouldn't be on master, right?!)

If such changes were targeted against master and now must be applied to 2.10.x, here's how to do it.

Tools of the trade

Install git-what-branch

git clone git://github.com/retronym/git-what-branch.git && cd git-what-branch && sudo make install

Configure your remote to fetch pull requests

~/code/scala git config -e
[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	fetch = +refs/pull/*/head:refs/remotes/origin/*
	url = git@github.com:scala/scala.git

Install libscala

Backport process

Identify the change to backport.

Find the corresponding merge to master and inspect the pull request.

git what-branch --reference master 2b4e7183fd
2b4e7183fd used the following minimal temporal path:
  merged to v2.10.0-M7-246-g930c85d @Thu Sep  6 19:30:58 2012
    Merge pull request #1187 from retronym/ticket/3577
  v2.10.0-M7-246-g930c85d is on master

git log-branch v2.10.0-M7-246-g930c85d

commit 00e46b3dbcea2b72fd3941b7ffc2efba382871e9
Author: Jason Zaugg <jzaugg@gmail.com>
Date:   Fri Aug 24 01:16:47 2012 +0200

    Mention BoundedWildcardType in "a standard type pattern match".

commit 2b4e7183fd24113cca5e868456668fd05c848168
Author: Jason Zaugg <jzaugg@gmail.com>
Date:   Fri Aug 24 01:05:07 2012 +0200

    Make RefChecks#validateVariance aware of BoundedWildcardType.
    ...

Read the comments on the pull request, and on any referenced JIRA tickets.

Create a branch for the pull request containing a squashed commit.

~/code/scala git cherry-pick-branch v2.10.0-M7-246-g930c85d 
Switched to a new branch 'backport/1187'
[backport/1187 baa1975] SI-3577 Make varianceInType aware of BoundedWildcardType. (cherry picked from commit 21105654c40ed0c462142bcbb6c8eced77f8b07a)
 2 files changed, 31 insertions(+)
 create mode 100644 test/files/pos/t3577.scala
[backport/1187 8cde366] Make RefChecks#validateVariance aware of BoundedWildcardType.
 1 file changed, 9 insertions(+), 7 deletions(-)
[backport/1187 63995b4] Mention BoundedWildcardType in "a standard type pattern match". (cherry picked from commit 00e46b3dbcea2b72fd3941b7ffc2efba382871e9)
 1 file changed, 2 insertions(+)
HEAD is now at 4c0b9b2 Merge pull request #1583 from dragos/issue/fix-6616
Updating 4c0b9b2..63995b4
Fast-forward
Squash commit -- not updating HEAD
 src/compiler/scala/tools/nsc/typechecker/RefChecks.scala |   16 +++++++++-------
 src/compiler/scala/tools/nsc/typechecker/Variances.scala |    2 ++
 src/reflect/scala/reflect/internal/Types.scala           |    2 ++
 test/files/pos/t3577.scala                               |   29 +++++++++++++++++++++++++++++
 4 files changed, 42 insertions(+), 7 deletions(-)
 create mode 100644 test/files/pos/t3577.scala
[backport/1187 3177edb] Squashed commit of the following:
 4 files changed, 42 insertions(+), 7 deletions(-)
 create mode 100644 test/files/pos/t3577.scala
backport/1187 ~/code/scala git log --graph
* commit 3177edb5a830f3922b1d7b1d6f79ef20648ff9e2
| Author: Jason Zaugg <jzaugg@gmail.com>
| Date:   Wed Nov 14 14:40:59 2012 +0100
| 
|     Squashed commit of the following:
|     
|     commit 63995b4e4a93f9796149a3f7fea7d67e244211c5
|     Author: Jason Zaugg <jzaugg@gmail.com>
|     Date:   Fri Aug 24 01:16:47 2012 +0200
|     
|         Mention BoundedWildcardType in "a standard type pattern match".
|         (cherry picked from commit 00e46b3dbcea2b72fd3941b7ffc2efba382871e9)
|     
|     commit 8cde3664f57f357d18cfe2fbad4df842b9f8b7e2
|     Author: Jason Zaugg <jzaugg@gmail.com>
|     Date:   Fri Aug 24 01:05:07 2012 +0200
|     
|         Make RefChecks#validateVariance aware of BoundedWildcardType.

Review the change

git diff HEAD~1

Test the change

ant dist-opt # Or leave it to the pull request validator if you are short on cycles

Submit your pull request

git push -u retronym backport/1187
git browse # requires `hub`
# Pull Request targetting 2.10.x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment