I've had the following TFS issue:
I've created the new branch from MAIN branch. During the time some changesets (let specify them from CS-1 to CS-2) have happened on the new branch. In one moment I had modification on MAIN branch and this modification has been merged on the new branch (new changeset on branch: CS-3).
After that, new branch was having several changes (which produced changesets from CS-4 to CS-5). Also, I did a rollback of CS-3 and as result the new changeset CS-6 has been created on the new branch.
Now, the question is: Which changesets should be contained in merge from the new branch back to the MAIN? Logically, it should be: [CS-1 – CS-2, CS-4 – CS-5 and CS-6]. But, the real result was: [CS-1 – CS-2, CS-4 – CS-5]
Does anybody have any idea: Why the rollback changeset (CS-6) is not contained in merge? It is obvious that rollback of changeset CS-6 is not treated equally as usual changeset.
In Source Control Explorer, select an item, open its shortcut menu, and choose Rollback. The items you select determine the scope that the rollback changes. In the Rollback dialog box, select Rollback changes from a single changeset.
Rollback entire changeset will give you a set of Pending Changes that when checked in will "undo" what was done in changeset 601.
First of all, very well explained question :). The option which you need to start using is the "
tf rollback /keepmergehistory
The following example explains the 2 different options that we can use while doing rollbacks, and why you got the specific behavior you mentioned above. I recreated the entire scenario you mentioned above, but I rolled back from command prompt using the
/keepmergehistory
This time when I tried to merge back from dev branch back to the Main branch, it did bring up the rolled-back change (CS6) back to the source/main branch.
Explanation from MSDN:
When you roll back a changeset that includes a branch or a merge change, you usually want future merges between the same source and the same target to include those changes. However, you can use the /keepmergehistory option if you want future merges between the same source and the same target to exclude changesets that were encompassed in a past merge operation.
For example, you can use this command in the following situation:
In On June 30, 2009, you perform a full merge of all items from $/BranchA/ to $/BranchB/:
c:\workspace> tf merge $/BranchA $/BranchB
You check in this merge as part of changeset 292.
In July, you make several changes $/BranchA/Util.cs. These changes are encompassed in changesets 297, 301, and 305.
On August 1, 2009, you merge $/BranchA/Util.cs to $/BranchB/Util.cs:
c:\workspace> tf merge $/BranchA/Util.cs $/BranchB/Util.cs
You check in the change as part of changeset 314. The result of this operation is that the edits that you made in changesets 297, 301, and 305 to $/BranchA/Util.cs are now also applied to $/BranchB/Util.cs.
A week later, you realize that the edits that you made to $/BranchA/Util.cs in July are not appropriate for $/BranchB/Util.cs. You can use the rollback command to negate these changes. When you use the rollback command to roll back a merge change or a branch change, you have a decision to make.
If you want the changes that you made in July to $/BranchA/Util.cs to be re-applied to $/BranchB/Util.cs in future merges, you should type the following command:
c:\workspace> tf rollback /changeset:314
If you want the changes that you made in July to $/BranchA/Util.cs to never be re-applied to $/BranchB/Util.cs in future merges, you should type the following command:
c:\workspace> tf rollback /changeset:314 /keepmergehistory
A few weeks later, you merge $/BranchA/ into $/BranchB/: c:\workspace> tf merge $/BranchA $/BranchB
If you omitted the /keepmergehistory option, the merge change will apply to $/BranchB/Util.cs all changesets that were applied to $/BranchA/Util.cs since changeset 292, including changesets 297, 301,
In other words, a future merge will undo the rollback change.
If you included the /keepmergehistory option, the merge operation will apply to $/BranchB/Util.cs all changesets that were applied to $/BranchA/Util.cs since changeset 292, excluding changesets 297, 301, and 305. In other words, a future merge will not undo the rollback change. Therefore, the content on BranchA might not match the content on BranchB.
MSDN SOURCE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With