2
votes

I have a question about merging between branches in TFS 2013, specifically about merge discard, that I haven't been able to find an answer for in other threads.


Scenario: we have two branches, let's call them $North and $South - to emphasize they are not to be looked upon as source and target (i.e. merging can be done in both directions). $South was branched out from $North.

I check in changeset nr. 1000 to $North, and the changeset appears expectedly as a merge candidate:

> tf merge /candidate $North $South /recursive
Changeset User  Date  Comment
1000      Bob   ...   Updating build script

Then I do a merge discard because this changeset is not relevant to merge to the other branch, in fact it is not application code but rather configuration specific to the branch:

> tf merge /discard /version:C1000~C1000 $North $South /recursive
Resolved file1 as KeepYours
...

I check in the merge discard resulting in changeset nr. 1001. Now changeset 1000 has disappeared from the merge candidate list:

> tf merge /candidate $North $South /recursive
There are no changes to merge.

BUT, now I check the merge candidates in the reverse direction:

> tf merge /candidate $South $North /recursive
Changeset User  Date  Comment
1001*     Bob   ...   Merge discard on changeset 1000

I even tried to rollback the merge discard again, because I would rather have the change as merge candidate from $North to $South than in the other direction, but the result was just another merge candidate:

> tf merge /candidate $South $North /recursive
Changeset User  Date  Comment
1002*     Bob   ...   Rollback on merge discard on changeset 1000
1001*     Bob   ...   Merge discard on changeset 1000

Does anyone know if it is possible at all to completely discard a changeset, and also not having the discard itself appear as merge candidate in the other direction?

(Although I don't know if the contents of my initial changeset is relevant, I can add that my actual changeset 1000 was a change in $North that consisted of a delete on a folder that was also present in $South, and also a folder add.)

2
what's the version of tfs are you using? Tried on TFS 2015, branch a project and process two-way merge, but can't reproduce your issue. No matter $North to $South, or $South to $North, there is no changes to merge.Cece Dong - MSFT
Sorry, I forgot to mention. It's TFS 2013.user3774315
I did a new test, same procedure as described above, but with the simplest possible root changeset (a single file add). I could still reproduce the behaviour on TFS 2013, although the merge discard changeset did not appear with an asterisk (partial merge) in the candidate list.user3774315
I also tested doing another merge discard on the merge discard changeset (1001) from $South to $North, and that actually got rid of the merge discard changeset from the merge candidate list from $South to $North - without it appearing again on in the reverse merge candidate list. So problem almost solved, but unfortunately this did not work with my real changeset, which was a folder delete and folder add - and got marked with an asterisk as a partial merge after the merge discard.user3774315

2 Answers

0
votes

Weird scenario, when I tried on a single file yesterday, I couldn't reproduce your issue. When I try a new test today by adding a new folder, I couldn't reproduce your issue at the first attempt, but when I attempt a new merge, I could reproduce your issue. Obviously, we are not the only persons have this issue, check TFS Merge: Cannot discard a changeset, you may submit a feedback at http://connect.microsoft.com/VisualStudio for this random issue.

By the way, sometimes, combining /baseless /discard would force a file to be considered for the merge and then discarded by the discard switch.

0
votes

According to the description for "/discard" on MSDN:

/discard Does not perform the merge operation, but updates the merge history to track that the merge occurred. This discards a changeset from being used for a particular merge.

The history of the branch is still updated even though the merge isn't happened. You can check the history of your branch, there should be a changeset 1001 in it.