Is there an easy way to create a patch in one branch and then apply it to another branch in TFS 2010?

I have two branches of a service pack that go from one main section to TFS 2010. I want to "transfer a set of changes from one branch of a service pack to another, without pushing it through the main branch and without doing a groundless merge.

There is a conflicting set of changes in the main branch, which I do not want to merge with the set of changes from the first branch of the service pack. I want the second branch of the service pack to receive this change in unmodified form.

An imperfect merge will create a connection between the two branches. I do not want this link to appear in the merge dialog.

Is there an easy way to create a patch in one branch and then apply it to another branch? Something like in Subversion.

PS I'm not going to change the branch structure to accommodate this scenario. The general structure is more complex than what I described, and it contains a number of releases, service packs, sub-repetitions, etc. This follows the well-known branching guide.

+4
source share
4 answers

So you have something like this:

------------------------------------> MAIN \ \ \ \ AB 

You can make branch B from B:

 ------------------------------------> MAIN \ \ \ \ AB \ \ B' 

Then make an unreasonable merge from A->B' . Then merge B'->B Go ahead and destroy B' . Although I have never done this, it should work.

+3
source

One approach:

  • Move both branches (A and B) to separate folders on your PC.
  • Find the changes in A that you want to merge into B (look at the version control history for the branch, find the set of changes and double-click them to view the chnaged files) and check them in the destination branch, (Alternatives: check all files - TFS will discard unchanged files when registering. Or disconnect the network cable and then run VS and it will disconnect. After merging, use File> Source Control> Go online to return to the Internet and check any changed files)
  • Use the merge tool (I would recommend Beyond Compare, Araxis, but nothing but the terrible ones that come with VS should do) to merge from each file in branch A into the eqiuivalent file in branch B
  • Build and Test Branch B
  • registration

This avoids the use of TFS for any merge, so he will not know that it is a merge. Just think that you wrote a lot of code in branch B pretty quickly :-)

Another approach:

  • Combine the change set in your main branch with A. During the merge, include both code variants and add #if commands around the new and old blocks of code so that they coexist side by side and the service pack is “included” in the main trunk with a simple definition. By default, this definition should not be defined, so the binary output from the main branch code does not change. i.e.

     #if SERVICE_PACK_A ...ServicePackA code... #else ...original Main branch code... #endif 
  • Now merge the change down into branch B

+2
source

My answer is similar to Jason Williams. If you want to stay “inside” TFS, you will only have 2 options. Perform an unreasonable merger or merge from A to Main, and then from Main to B.

Since you do not want to do any of these, you need to merge the "outside" of TFS.

Tools you need: Team Explorer, Team Foundation Power Tools, a tool for combining third-party participants. I like Sourcegear DiffMerge (because it's free), but Araxis, Beyond Compare and Winmerge will work just as well. (aside, you can configure TFS to use a third-party merge tool (Thanks again to Jason!))

  • Get the latest on both branches of the service pack
  • Check the target branch
  • Use the merge tool to compare folders between two local folders
  • Combine the corresponding changes from A to B
  • At the command prompt, run tfpt uu against the local copy of B, this will cancel the verification of any files that have not been changed as part of the merge. (To do this, install the TFS Power tools.)
  • Check Pending Changes in B

This is not great, but I think this is the only way to do what you are trying to achieve.

+1
source

Source: https://habr.com/ru/post/1390533/


All Articles