Script to aid porting of patches between JDK 9 and JDK 8u

The reorganization of the JDK source code in 8051619 changes the location of every source file in the corba, jaxp, jaxws, jdk, langtools, and nashorn repositories, in JDK 9. Backporting a change that affects a source file in one of these repositories will require an update to the exported changeset / patch, to refer to the old source location. The reverse if also true, when forwarding porting a change from JDK 8u to JDK 9, the exported changeset / patch will need to be updated to refer to the new source location. To help with this, a script has been developed that will update the source location of the exported changeset / patch.

The script can be found in the top-level repository at, common/bin/unshuffle_patch.sh.


    $ bash common/bin/unshuffle_patch.sh --help
    Usage: common/bin/unshuffle_patch.sh [-h|--help] [-v|--verbose] <repo> <input_patch> <output_patch>
    where:
    <repo>            is one of: corba, jaxp, jaxws, jdk, langtools, nashorn
                      [Note: patches from other repos do not need updating]
    <input_patch>     is the input patch file, that needs shuffling/unshuffling
    <output_patch>    is the updated patch file
    

To help correctly identify the set of rules that determine the old / new source locations, the script requires that the repository, from which the patch was exported, be given as an argument. Providing an incorrect value will produce a, possibly, bad updated patch.

The -v|--verbose optional option can be specified to give a better understand of what the script is doing.

Example: Backport a change from JDK 9 to JDK 8u


    ## Determine the revision number of the changeset that will be backported
    $ cd jdk9/jdk
    $ hg log -l 1
    changeset: 10519:7067ad29e46f
    tag: tip
    user: igerasim
    date: Thu Aug 07 15:07:33 2014 +0400
    summary: 8054221: StringJoiner imlementation optimization

    ## Export, using extended git format
    $ hg export -r 10519 --git > 8054221.patch

    ## Run the script to update the patch
    $ bash ../common/bin/unshuffle_patch.sh jdk 8054221.patch 8054221_updated.patch

    ## Verify the updated patch
    $ diff 8054221.patch 8054221_updated.patch
    10,12c10,12
    < diff --git a/src/java.base/share/classes/java/util/StringJoiner.java b/src/java.base/share/classes/java/util/StringJoiner.java
    < --- a/src/java.base/share/classes/java/util/StringJoiner.java
    < +++ b/src/java.base/share/classes/java/util/StringJoiner.java
    ---
    > diff --git a/src/share/classes/java/util/StringJoiner.java b/src/share/classes/java/util/StringJoiner.java
    > --- a/src/share/classes/java/util/StringJoiner.java
    > +++ b/src/share/classes/java/util/StringJoiner.java

    ## Import into JDK 8u
    $ cd jdk8u-dev/jdk
    $ hg import 8054221_updated.patch
    applying 8054221_updated.patch