TFS 2010: Remove changesets to be merged - tfs

In TFS 2010, when I want to merge files from one branch to another, I get a list of changesets that are yet to be merged to the target branch. The problem is a lot of these changesets have already been manually merged. So I am getting a lot of 'There were no changes to merge.' messages.
So I need to remove those changesets ( which have already been merged, i.e. no changes to merge) from the total list of changesets that are to be merged with the target branch. Please suggest a way to do this as I am new to TFS.

You should always be meeting the latest, or everything up to a specific changeset.
http://nakedalm.com/avoid-pick-n-mix-branching-anti-pattern/
Picking and choosing changesets to merge is not a good way to manage your code.
To unblock your merge you will need to discard the merger candidates that are no longer relevant.
tf merge /discard

Related

TFS Create branches from Main - selected changeset

I have an issue; we have a Main branch, and we have few changesets (that belong to 3 different features).
I created three DEV branches By Date (and selected a date that is prior any of the changesets).
I cherry picked the changesets from Main, and merged them to appropriate DEV branches.
I RolledBack all these changesets from Main so that, the main becomes clean.
Now I want to merge one of DEV branch to Main and deploy for testing,
The problem is; it doesn't pick all the changesets, and even for the ones that it picks, it doesn't pick all the modified files.
How can I merge from DEV to Main? Please help.
Thanks
When TFS does a merge, it bases the merge on prior merge history, not on the actual contents of the source and target files.
You could try the /force option with the tf merge command. The /force flag ignores merge history that indicates a particular changeset was previously merged from source to target (perhaps incorrectly), and merges the changeset again. You can do a /force merge for a single changeset or for a range of changesets. For just changeset #123456 the command would be:
tf merge /force $/Source/File.cs;C123456~123456 $/Target/file.cs
Check the following blog for more details:
https://blogs.msdn.microsoft.com/billheys/2011/03/16/my-source-and-target-files-are-different-but-merge-tells-me-there-are-no-changes-to-merge/

Ignoring 2 changesets

I'm using TFS 2010. I have 2 changesets in child branch that I do not want to merge in the parent branch.
e.g
(1002) Rolled back changeset
(1001) Changeset checked in by mistake
I don't want these changesets from appearing in the merge menu when you attempt to merge into the parent branch.
If I have understood correctly that I can use the following TFS command to ignore these 2 particular changesets or will the rollback changeset interfere?
tf merge childbranch parentbranch /r /version:1001~1002 /discard
You can do a discard
merge.
This has to be done from the command line. Open up the Developer
command
prompt,
then navigate to a folder under either of your branches (i.e. navigate
to one of the affected
workspaces).
Then type:
tf merge /r /discard "$/Project/B1" "$/Project/B2" /v:C12345~C12345
This will take the changeset identified (in this case it was changeset
#12345), and update it as merged to the target branch (branch B2). The target files will be checked out, but they will not be changed - you
can simply check them in to complete the operation. After that the
changeset will no longer appear as a merge candidate. You can specify
a range of changesets to merge at the same time, but they should be
contiguous.
Note that after doing this a changeset will occasionally still show up
as a merge candidate - this is rather uncommon with the latest
versions of TFS, and it is virtually impossible to fix (unless you are
running your own local install of TFS and want to get your hands very
dirty in the database). If you end up with one of these marooned
changesets, just ignore it.
Source:
Finding merge candidates in TFS
Note: When the command has finished, you still need to check in the merge.
For more tutorials, you could also refer below blogs:
TFS: Discard changesets when merging to branches
DISCARDING CHANGESETS IN TFS

How can I resolve a partially merged changeset in TFS?

One of my projects in TFS keeps displaying changesets as unmerged between the branches after I have already merged and committed them. I used the Track Changeset feature and clicked the Visualize button to see if the change was merged. It shows that it was merged but has a different background color and an asterisk. I checked the help and it gives this explanation:
If a branch has received some (but not all) of the changes in a changeset, the branch is filled with a pattern, and an asterisk follows the changeset numbers within that branch. For example, the previous illustration shows that only some of the changes in changeset 38 were merged to the Test branch
Track Changes Help
I don't understand how it is that I only partially merged those changesets. Perhaps I did not have latest when I completed the merge but it is happening to a lot of the changesets and this only happens on this one branched project folder.
Is there a way to find out what did not get merged and merge it so that the changesets will quit showing up as a merge candidate?
A partial merge is recorded when only some changes from a changeset are merged into the target. There are two common scenarios in below which you can end up with partial merges:
Scenario 1:Undo some pending changes when you are checking the merged files
In this case, even though we already merged changeset Dev to Main, it is still a merge candidate. This is caused by the fact that the merge engine detected that there are still some changes in that changeset which were not propagated from Dev to Main.
Scenario 2: Performed the merge at feature level not from the top of the branch
For example: consider that you have two branches Main and Dev, each of them has two folders (Feature1 and Feature2) and each feature folder contains one file. We edit both files from the feature folders (Dev\Feature1\feature1.txt and Dev\Feature2\feature2.txt) and check-in the changes.
If you perform the merge operation at the Feature1 level.(Changset142→
Changeset143) You will notice in the Pending Changes window that only the edit done in the Feature1 folder will be merged. Complete the merge.
If you take a look at the merge history of the Feature1 folder you will see that all changes from changeset 142 have been merged into changeset 143.
However,if you take a look at the merge history of Main you will see that only parts of changeset 142 have been merged into changeset 143. This is normal as changeset 142 has some changes – the edit of the file in the Feature2 folder – which were not delivered.
In case of a partial merge, to figure out what changes have been merged and what changes from the changeset were left out. The only way to achieve this is to diff the contents of the changeset that was partially merged, and the contents of the changeset that was generated as the result of the merge. More detail info you can refer this blog: Partial Merges in TFS – A Guide
Update
You can do a discard
merge.
This has to be done from the command line. Open up the Developer
command
prompt,
then navigate to a folder under either of your branches (i.e. navigate
to one of the affected
workspaces).
Then type:
tf merge /r /discard "$/Project/B1" "$/Project/B2" /v:C12345~C12345
This will take the changeset identified (in this case it was changeset
#12345), and update it as merged to the target branch (branch B2). The target files will be checked out, but they will not be changed - you
can simply check them in to complete the operation. After that the
changeset will no longer appear as a merge candidate. You can specify
a range of changesets to merge at the same time, but they should be
contiguous.
Note that after doing this a changeset will occasionally still show up
as a merge candidate - this is rather uncommon with the latest
versions of TFS, and it is virtually impossible to fix (unless you are
running your own local install of TFS and want to get your hands very
dirty in the database). If you end up with one of these marooned
changesets, just ignore it.
Source:
Finding merge candidates in TFS

Is there a way to associate a new TFS changeset with an old changeset?

So I fixed a bug on our main branch some months back, let's say some old changeset 555. Recently, I manually copied these changes to a child branch for a recently approved hotfix, changeset 999. I would like to do a Track Changeset on 999 and see this it has been merged to main as 555. But, I've done this backwards according to the TFS rules, you can't merge down to a child branch.
Is there a way to tell TFS "accept my old changeset 555 as the merge of 999 to the main branch"?
This is analogous to the ClearCase version tree workflow, using the "don't perform merge, just draw arrow". Thus the Track Changeset for either 555 or 999 would show that they are related.
I'm not sure what you mean by
But, I've done this backwards according to the TFS rules, you can't merge down to a child branch.
There shouldn't be anything preventing you merging this change to a child branch, you might have some merge conflicts to resolve. However if that really isn't a possibility and you want to merge "999" in to the main branch without actually merging the code (i.e. adjust the merge history) then you can using the tf merge command line.
Open a visual studio command prompt and use the command
tf merge $/TeamProject/childBranch $/TeamProject/MainBranch /version:C999~C999 /recursive /discard
This will tell TFS to update its history to say that the merge occured even though it hasn't. You might want to use the /preview switch before you do the merge "for real" to make sure you are discarding the files you expect.

TFS 2010: Branching - Why do changesets say they haven't been merged when they were from before the Branch?

I made a branch and the first time I went to merge from the source to the branch there were a whole bunch of old changesets coming up that it says were not merged but they were present well before the branch and I confirm that they were there.
Example:
Say I branched from Source to Target when there were 9 changesets in Source.
Change 10 was made in Source.
I go to merge from Source to Target and TFS tells me change 6 and 7 and 10 need to be merged (even though 6 and 7 were there before I branched and I can confirm those changes are in the Target)
I am new to TFS and this happened when I first started to implement Branching and Merging.
The newest branch I made did not do this.
Right now we have a Trunk and then 1 Branch for the ongoing QA for the next release and another Branch for the Hotfixes to Production. It was the QA branch that had this issue but when I made the hotfix branch it was fine.
I have come across this a few times. I eventually just merged the "rogue" candidate change-sets from source to target. I examined the pending merge and determined that there were no changes. Committing the merge got rid of these candidate change-sets. I figured that I could roll back if it didn't work out.
EDIT: It appears that if you upgraded to TFS 2010, there is a bug that will cause extra merge candidates (see http://support.microsoft.com/kb/2135068)
"Any items on a branch that have been renamed multiple times or have had multiple other items occupy their namespace (through add/delete combinations) will have lost their relationships with the corresponding items on other branches."
As for a resolution, the support article says:
"To resolve the issue with extra merge candidates, the /discard option should be used. To do this, run a merge of the following format from a command line:
tf merge <source branch> <target branch> /r /discard:CXXX~CYYY
In this example, XXX and YYY represent the changeset IDs of the range of changes to discard. After this merge has been checked in, the unwanted candidates will no longer appear for future merges. Also be aware that, because of improvements in the merge algorithm in TFS 2010, items deleted in both the source and target branches will result in changes to be merged. In those cases, it is best not to discard the changesets so that the merge history is updated correctly. "
I've had this a few times too. I suspect the cause is some funnyness in the way TFS manages pending merges. If you try to merge these changes, and the Change type is just "merge" and not "merge, edit", then it is safe to merge them and be confident that no changes have occurred. If you don't merge them, TFS will keep trying to merge the non-changes indefinitely, possibly obscuring real changes eventually. I advise merging these non-changes ASAP.

Resources