Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apply a diff from one branch as a patch to another in Visual Studio TFS

We have a project in which we've been doing some work in a Branch for version 6.1. One of the changes made in the 6.1 branch (changeset 1800) was a bugfix, and someone decided it's urgent enough to merit a patch to our 6.0 production release.

Now, changes were made to the file in question both before changeset 1800 and after it. What they want is for JUST the patch to be applied to 6.0.

As per http://linux.die.net/man/1/patch, it seems that the best thing to do would be to create a diff file by comparing changeset 1800 to 1799, and then apply that diff file as a patch to 6.0. I don't even know where to begin doing this in TFS.

As a fallback plan, I can always just go through the differences in changeset 1800 by hand and copy them into the latest version of production to patch it, but I'd like to do this properly if possible.

Aside: I understand that by applying just a diff, you risk the fact that some of the code involved in the 1799>1800 diff relies on code that was only established between the current production version and changeset 1799, but that can easily be verified by quickly building and testing production after the diff patch is applied. We aren't worried about that.

like image 493
Alain Avatar asked May 23 '12 17:05

Alain


1 Answers

Ok, I'm not sure I totally understood, but here it is:

Changeset in TFS don't store the absolute content of a file, but the difference (lines added, deleted, changed).

If you want to report your bug fix from the version 6.1 to the 6.0 and this fix is included in the changeset 1800 (and nothing more than this fix), then simply merge the given changeset to the version 6.0. All the changes made before the changeset 1800 won't be merged in the 6.0, only what you did in this changeset will be merged.

When you do a merge you have two options:

  1. Merge all the changes from the source branch to the destination one
  2. Merge a selected changeset from the source to the destination one.

Use the second one and specify the changeset 1800 and you'll be fine.

Some pictures:

enter image description here

enter image description here

ONLY the changeset selected will be merged.

like image 190
Nock Avatar answered Nov 08 '22 08:11

Nock