Merge specific changes between streams

When merging changes between streams, you can select changes related to specific requests, a process called cherrypicking. For example, you have delivered multiple sets of changes to a stream but want to merge one specific set into a different stream. This topic provides examples of picking changes during the merge.

Cherrypick a set of changes

In this example, there are two streams, RELEASE and MAINTENANCE. The MAINTENANCE stream was branched off the RELEASE stream from changeset 5.

Your team has made multiple deliveries to the RELEASE stream which has created changesets 6, 7, 8, and 9. The modifications in each changeset are related to a different request:

  • Request CR_1 is related to item3;rel#4.

  • Request CR_2 is related to item1;rel#2 and item2;rel#4.

  • Request CR_3 is related to item1;rel#3 and item3;rel#5.

    cherrypick-example-1.png

In the MAINTENANCE stream you want to:

  • Merge the changes that were delivered in changeset 8 to the RELEASE stream (related to CR_3).

  • Ignore the previous changes delivered to the RELEASE stream (changesets 6 and 7).

Cherrypicking CR_3 during a merge from request operation only includes the changes applied when changeset 8 was created:

  • The difference between item1;rel#2 and item1;rel#3.

  • The difference between item3;rel#4 and item3;rel#5.

The changes to item2 are not applied as it is not affected by CR_3.

The merge operation creates changeset 2 in the MAINTENANCE stream.

cherrypick-example-2.png

Tip:  

  • If you perform a regular merge from request using CR_3, and do not specify the Cherrypick option, the entire contents of these files are merged:

  • item1;rel#3 (including changes in item1;rel#2)

  • item3;rel#5 (including changes in item3;rel#4)

  • To apply all the changes made before changeset 8 of the RELEASE stream was created, merge from a stream version (not a request).

Back to top

Cherrypick multiple changes

In this example, there are two streams, RELEASE and MAINTENANCE. The MAINTENANCE stream was branched off the RELEASE stream from version 6.

Your team has made multiple deliveries to the RELEASE stream, creating changesets 7, 8, 9, and 10. The changes in changesets 8 and 10 are both related to the same request, CR_4.

cherrypick-2a.png

In the MAINTENANCE stream you want to:

  • Merge the changes related to CR_4 in the RELEASE stream (changesets 8 and 10).

  • Ignore the other changes delivered to the RELEASE stream (changesets 7 and 9).

You can cherrypick the changes delivered in changeset 8 and 10 by selecting request CR_4 during a merge operation.

cherrypick-2b.png

Tip: You can select multiple requests when cherrypicking.

Back to top

Cherrypick multiple non-consecutive changes

The following file contains multiple changes:

  • Two of the changes are related to the same request (CR_42).

  • The other changes are related to different requests.

    cherrypick-multiple-non-sequential-changes.png

Each delivery has created a new revision of the file and a new changeset:

cherrypick-changesets.png

  • Changeset 2 contains revision r2016#2.

  • Changeset 4 contains revision r2016#4.

  • Both changesets are related to the same request (CR_42).

  • Changeset 3 contains r2016#3but is related to a different request (TASK_20).

  • The changesets related to CR_42 are not consecutive.

You need to:

  • Merge the two changes related to CR_42 into a target file in another stream.

  • Ignore the other changes.

You can cherrypick the required lines of code by specifically selecting request CR_42 during a merge from request operation.

If you interactively review and do not automatically merge non-conflicting file content, the change tree on the Review Changes page of the Merge wizard looks similar to this:

cherrypick-review1.png

The default resolution for both revisions is Unresolved. Revision r2016#2 of the file was made before r2016#4. The changes applied by revision r2016#3 need to be excluded. Two merge operations are required, one for each delivery that was related to request CR_42:

  1. Merge revision r2016#2 into the target file.

  2. Save the target file.

  3. Merge revision r2016#4 with the target file saved in the previous step.

Tip: To cherrypick one specific revision ignore the revisions that you do not want to merge.

If you automatically merge non-conflicting file conflicts, the change tree on the Review Changes page of the Merge wizard looks similar to this:

cherrypick-review2.png

The default resolution for both revisions is Merge. The changes have been merged successfully by the default merge tool into the target.

Back to top

See also: