Merging all changesets associated with a WorkItem in Team Foundation Server - tfs

We're trailing the use of the built in bug tracking, and have written some integration into our helpdesk software that allows for escalation via workitems.
One thing I haven't found out how to do, is to merge all changes associated with a work item (say to go from dev branch to main) - I appreciate you can double click on a changeset in the merge dialog to view if it is associated with a workitem, and also that I can select individual changesets, and groups of adjacent changesets; but there doesn't appear to be any way to merge changes by workitem?

It is correct that you can't merge based on work items. It is probably not a good idea to do that anyway. It would be very difficult to make sure you get all the necessary changes needed for the main branch to build correctly. I would look into how you do your branching and a good starting point would be: Microsoft Team Foundation Server Branching Guidance
In TFS 2005 and 2008 the check in history will not be transferred between branches. You will get this in TFS 2010.

Merge changesets by workitem - https://tfsprod.codeplex.com/
Check out the ExtendedMerge feature.
Enjoy! :)

Related

Downloading all Changesets Except one in TFS

Recently, one of the junior developers made a check-in to a large MVC SOA C# application, to both the client and service side, which makes the project unbuildable. Their check-in added spurious dependencies as well as removed required files, with something like 900 files in the project affected.
In order to keep the project moving forward, I was instructed by management to simply obtain the project from the changeset prior to this check-in in TFS and and then apply all changesets after the bad check-in going forward, since we though a release would be urgently needed.
As the weeks have passed, however, this approach is getting untenable. Is there a way to do one of these two things in TFS?
Either
remove a changeset from TFS without removing the changesets that come after it?
or
Automatically get all of the changesets in TFS for a solution except for one specific changeset.
remove a changeset from TFS without removing the changesets that come after it?
According to the document Roll back changesets:
A changeset is a permanent part of the history of your
version-controlled items and cannot be undone or removed. However,
you can roll back the effects of one or more changesets.
So, we could not remove one specify changeset. Just like James said, we could roll back the bad changeset. But it will also remove the changesets that come after it. As workaround, you can check the Changeset details for that specify changeset. Then ask that the junior developers remove his code, then check in the delete changeset.
Automatically get all of the changesets in TFS for a solution except
for one specific changeset.
There is way to find and view a TFS changeset by comment text:
tf history $/ -r | ? { $_.comment -like '*findme*' }
Check the this thread for some more details.
But there is no such out of box method to exclude one specific changeset in the text, we need to write our scripts like, batch, powershell to except it from the text.
Hope this helps.

TFS 2010 - Create a new project from an existing one in TFS

I need to create a new project from an existing one in TFS. This is for source control only. I do not need to copy any work items.
so now i need to create NewTeamProject in NewProjectCollection and use the source branch of OldTeamProject in OldProjectCollection.
Kindly advise to go ahead with this.. Thanks a lot for your help in advance..
Manual Split
Create a new team project in your existing collection
Pick the branch from team project option in the creation wizard
Follow the split a team project collection guidance
However, I have a feeling that this will not bring all the history along with it, and it's not a particularly nice option, especially when it comes to the collection splitting.
TFS Integration Tools
Another way is to use the tfs integration platform, which basically replays all the checkins on a new team project, which can be in your new collection. You will lose the original date/time of the checkin, due to the way this program works but will still be able to see what each checkin changed.
TFS Integration Tools
Tfs integration tools blog posts and references
There is one risky way to get your timestamps correct, by manually updating the database

Can a branch be made from a previous changeset?

I need to create a branch at a specific Changeset in TFS. Is this doable?
For example, I have changeset 1528 that was the last check in on my project. But I want to branch from changeset 1487. Can this be done?
If so, how?
Note: I am using TFS 2008
Yes. When a branch is created you can choose the historical point in time when it takes effect (date, changeset, etc).
See Visual Studio TFS Branching and Merging Guide for some great information on recommended branching practices.
Or How to: Branch Files and Folders (MSDN) for more explicit instructions on getting this dialog up to create a branch.
Visual Studio 2010 and later added support for this functionality:

How do I merge a Work Item from 1 branch to another in TFS 2008

I can't seem to find an easy way of doing this.
We have a trunk, which has a particular set of Changesets checked into a Work Item in TFS. I want to exclusively merge the changesets in this Work Item into another branch.
Surely this can't be difficult?
TFS absolutely does support cherry-picking. However, the range of changesets you cherry-pick must be contiguous. If you need to merge a set of changesets that has "gaps" in it, you'll need to run Merge multiple times. If the merge operations end up touching the same files, you will probably need to Checkin between merges.
You should be able to do this in a normal merge by simply selecting the changesets you want.
Open Source Control Explorer window in VS
Right click on the trunk (the folder that the original branch was made from)
Select Merge
Select the target branch to merge to from the dropdown list (if it doesn't appear then you probably selected the wrong source directory)
Pick the "Selected Changesets" option
Hit Next
Select the changesets you want to merge
I'm not sure if there's a way to do it from the workitem itself.
You may want to look into this tool:
http://wicreator.codeplex.com/Wiki/View.aspx?title=MergeByWI
This can be quite difficult, because afaik tfs does not support what is sometimes called "cherrypicking", i.e. merging a few otherwise unrelated changesets into a branch. Tfs expects that you merge the whole branch up to a certain version, without leaving any changessets out. I'm afraid what you're asking isn't directly possible.
You could do it manually, but for a large number of changesets it will be painful. The "links" tab in the workitem contains all changesets ids that were associated with the work item - that could give you some help.

Can I see TFS file history with labels?

We currently are using both Visual Source Safe and Team Foundation Server at work (VSS for old projects, TFS for current or new projects).
We have always used Labels in source control for each build. In VSS if you chose to see a file history you could include labels. In TFS I cannot find an option to include the lables in the history window.
Since one of the most common questions that I get asked by support or management is 'What version did we fix/add/remove/change xxxx?', I have always relied on our build labels showing up in the history.
Can I get Labels to show up in a file history?
In the 2008 version of TFS, you don't see labels in the standard history of files and folders. If you really want to know why - see Brian Harry's blog post "Why TFS Labels are not like VSS Labels".
To find labels in Visual Studio, go to File, Source Control, Label, Find Label... From that you can see what versions of files were included in that label.
The team have definitely heard that this is not ideal, and the next version of TFS (Team Foundation Server 2010, codenamed "Rosario") will include improvements to the History view to make labels easier to find - see http://go.microsoft.com/?linkid=7807943 for the spec of improvements to the History view in TFS 2010.
BTW - I actually moved to changeset based build numbering with TFS which makes labelling less necessary. See http://www.woodwardweb.com/vsts/changeset_based.html for more details.
Hope that helps,
Martin.
This very issue has been killing us.
The best solution I've found is with the use of a third party tool called Team Foundation SideKicks available for free here http://www.attrice.info/cm/tfs/.
Under the "History Sidekick" there is a label tab. You can highlight any folder or file and it will show you every label that was dropped on that folder or file and at what changeset.
Unfortunately you can not see a full view of a folder or file's history with labels included.
Under the "Label Sidekick" you can highlight any specific label at it can tell you what folders/files and changesets are in the label. This functionality is pretty much the same as what is available from within Visual Studio and is not as helpful.
One caveat is the need for a TFS server 2008 or above. Using the tool with TFS server 2005 is painfully slow and basically unusable.
-ephi
[due to the complexity of TFS-style labels this is a quite difficult problem when applied to folders; based on a comment above I'm going to assume searching for labels on a file is sufficient]
Unfortunately this is one of the very few edge cases of the TFS client API that is not exposed anywhere in tf.exe or VS2008. You'll have to call the API directly. Please see http://msdn.microsoft.com/en-us/library/bb138967.aspx - the "versionFilterItem" parameter does what you're looking for.
TFS 2010 has a very useful "Labels" view (rather than "Changesets") in the history of any branch. Unfortunately, it only shows labels in the branch you have chosen, rather than labels in all child branches/folders.
I started to play with trying to create my own SQL to do this and run it directly against the TFS database(s) themselves. This SQL was run against TFS 2008. This little snippet will show ALL the labels and changesets for ALL the branches ordered with the most recently created branch/modified label first. The next step in developing this would be to somehow traverse the changesets and the labels to only bring back areas I'm interested in (like 'Main' or some particluar branch). I imagine if I created SQL that would do all of this, it would be dog slow, and wouldn't have the full GUI I want to dive into the history for a particular file, see labels with that, etc. Sigh.
select DisplayName, cs.CreationDate, Comment, 'CheckIn'
from TfsVersionControl.dbo.tbl_Identity i, TfsVersionControl.dbo.tbl_ChangeSet cs
where cs.ownerid = i.IdentityId
union
select DisplayName, LastModified, Comment, 'Label'
from TfsVersionControl.dbo.tbl_Identity i, TfsVersionControl.dbo.tbl_Label l
where l.ownerid = i.IdentityId
order by 2 desc
I've used TFS branch history for this before. It's not the greatest UI in the world and only lets you show history per file but it gets the job done.

Resources