We are planning to move from StarTeam to TFS for source control and are in the midst of refining our ALM procedures. Maybe I am misunderstanding something about how labels work in TFS, but it appears that you can apply a label to files by Changeset. I am trying to create a label on only the files/versions in the specific changeset.
I have attempted to do this like so:
1) Main Menu -> Source Control -> Apply Label
2) 'New Label' dialog appears
3) Leave path as is (Dev Branch)
4) Select 'Changeset' from 'Version' dropdown, enter my changeset #
5) Click Create.
... which results in the entire branch getting labeled. The changeset may be 1 - 100s of files, so individually labeling files is not practical.
We do this all the time in starteam: label changesets related to features, then move a build label up onto the labeled changeset. Am I missing something fundamental? (Thanks for any guidance)
Note the name... you are labeling by changeset not labeling a changeset.
Labeling in TFS is like marking a point in time. So when you label by changeset you are basically saying this is what my source control looked like at this point in time.
It sounds more like you area saying you want to be able to find a set of changes (changeset) not everything at the point in time that changeset was made.
You could pick a branching strategy that would allow you to branch by feature. The downside of this is that it will involve a lot of merging.
Another options would be to link the changesets for any specific feature to a work item and then you will have a list of changesets that you will want to merge up once you have completed that feature. In 2008 this can be a little troublesome because merging changesets that are not sequential can be more time consuming than necessary. (meaning there are changesets in between on that branch not that the changeset numbers are sequential)
Fortunately, you can try out different branching strategies and as long as you think it through it isn't to tough to switch if you don't like how you were doing it.
In TFS2010 I tested adding lables to a changeset and I am seeing the same behavior you reported.
When reviewing a changeset it will only contain the files that were checked in.
When reviewing a label that was created on the same changeset it will contain all of the files in the branch, with each file showing the changeset version of the last check-in.
I don't know why it works this way.
Related
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.
My case is the following. My team uses TFS 2012 for source control. My teammate has created a branch from a particular changeset (not the last for that moment) of another branch. What I need is to figure out from which exact changeset the branch was created, and which branch was used.
I tried to find it in "View History" of Source Control Explorer in VS. If to compare with svn, there is a property in the revision of creating a branch that stores the initial revision and initial location from which the branch was created. In TFS, changeset details look loke they do not contain such information.
Yes, there is. discens is right, you might use Track Changeset functionality. By the way, a similar question has already been answered on SO, here it is. The answer contains a link to a blogpost which contains many details, including API and a custom command-line tool.
However, the way is not so obvious. To clarify this, here is a brief step-by-step instruction of how to achieve the result in Source Control Explorer:
Locate your child branch in Source Control Explorer
Right-click on it to get context menu, select View History.
Locate the first changeset of the branch in the History viewer, right-click on it to get context menu, select Track Changeset.
You will see the scheme of branches and the structure of their inheritance. On this step, you are finding out the parent.
There is a checkbox near every detected branch, but the parent one of your child is normally unchecked. Check it first. The child branch has to be checked unconditionally, so the two checkboxes to be selected are the parent and the child.
Don't forget to locate your child branch in Path filter input field using Browse... button.
Press Visualize button at the bottom. You will see the picture with rectangles repesenting these two branches. The parent branch rectangle should include sorted list of changesets in this branch. The list can be huge, but the source changeset (from which your child has been originally created) should be the last.
???? PROFIT!!!!
You can see a sample screenshot of the final steps in the blogpost.
You can use Track Changeset feature which I believe will show you the history of a branch and what changesets it contains.
You can get to this feature from the Source Control Explorer
Is it possible to view history and compare with shelvesets? We are investigating the possibility of using shelvesets instead of check-ins. From our initial investigation it seems we cannot view history like we do for check-ins.
We are using Visual Studio 2010/TFS 2010.
From http://msdn.microsoft.com/en-us/library/ms181403(v=vs.90).aspx
Section: The Difference Between Changesets and Shelvesets:
Unlike a changeset, a shelveset is a non-versioned entity. If you or another user unshelve the items of which a shelveset consists, edit several files, and reshelve the shelveset, Team Foundation does not create a new version of the items for future comparison and maintains no record of who revised the items, when, or in what manner. The original shelveset is completely replaced.
So, no, you can't review history. I am unsure on methods of comparing shelvesets. You should also read that entire section (The Difference Between Changesets and Shelvesets) as each item in it is a strong argument to not use shelvesets in the place of changesets.
I also cannot think of any reason why using shelvesets instead of changesets would be desirable, maybe you can list the reasons why you all were exploring this path. Just think about not being able to track changes, that alone should be a deal breaker (of course, shelvesets not even being versioned should just about do it)..
Like it says on the link posted by dugas, shelvesets are built more for...well, shelving things. For example, on the project I am working on right now, I did a shelveset for some refactoring changes I was in the middle of because something unrelated broke and I needed the code back to the original non error-filled version. I also use it for when I'm in the middle of attempting something and want to have a backup but I don't want to check in code just yet.
There's no versioning on shelvesets, but it is possible to compare code in a workspace, to the code in a shelveset, without pulling the shelveset files.
Pull the versions of files you want to compare the shelveset contents to, into a workspace
open the solution in that workspace
File >> Source Control >> Unshelve Pending Changes...
find the desired shelveset and bring up its details
On each file in the Shelveset Details window, you can right-click and select Compare >> With Workspace Version...
TFS will pull the shelveset file to a temporary location, show the diff, and then (?) clean up the temp file after you're done.
You'll be comparing the shelveset file contents, to the contents of the files on the local disk in this workspace. If changes were made to both files, the compare won't be able to tell and will indicate all those changes. However, you can compare the selveset version to its original (Compare >> With Unmodified Version..), to see all the changes that were made just to the shelveset file. You can also find out the changeset that was the base for the shelveset file (Properties..), and see what changes were added to the workspace version since that common base changeset.
There's no tree compare though, and this may require the TFS power tools to work.
P.S> I don't recomment trying to use shelvesets in place of checkins like this. If there's one thing I've learned over the years, it's not to fight Microsoft's designed-in workflows -- you do things their way, or you find a different tool. Microsoft doesn't intend you to use shelvesets this way (they want you to use changesets and a branch), and if you try, you'll constantly be fighting Microsoft's designed-in workflow.
You can use shelvesets for peer code-review before committing them to the repository ... and also for parking commits before going through a gated build process.
They are not suitable for anything other than "quick shelving" of work - use branching if you want to have multiple parallel work streams.
When I do Track Changeset in tfs 2010, then in branch visualisation, I only get to see that selected changeset. However in examples all over the web, I have seen multiple changesets being shown in the hierarchy and Timeline views. Any idea?
What I have got is a main branch and from that I created a dev branch. Then i perform two changsets on dev branch. Now when i do View History on dev branch and select any one of the changeset and perform Track Changeset, then it only shows me that changeset, which is a bit odd because in the timeline view i should be able to see multiple changesets in a time range. Any idea?
Nabeel
nabeelfarid,
You likely have figured this out by now but this may be of use to others. The activity you are performing is called "Track Changeset" and thus by it's default nature and its name it is tracking a single changeset. It does also seem intuitive to me that in a timeline view I could see changesets that were merge candidates versus a single tracked changeset but that is not how it functions. It is only showing the tracking of a single changeset.
There are instances where instead of seeing a single changeset in the branches the tracked changeset has been merged into that instead you will see multiple changesets show up in one or more branches and usually with an * by them. This happens when the changeset that is being tracked has some of the files in the changeset merged into a target in one merge and checkin operation and some or all of the remaining files of the changeset merged into the target under a second (or more) merge and check-in operation.
Take a quick look at this blog post from John Bowen. He has a nice example that shows a a tracked changeset merged into a parent target branch as multiple changesets made up each of a subset of the files in the tracked changeset. He also shows how that might then look if they were forward integrated from that parent into a different child also by way of multiple changesets.
Visualizing Changes Across TFS Branches
If your changesets on dev have not been merged back to your main branch then there is nothing to track. Only as a consequence of merge operation will your dev changes gain a relationship with another changeset (which in your case will be a changeset committed to the main branch).
That is the purpose of the changeset tracking, to help you visualize the propogation of your change across branches. This is useful if you need to verify whether a specific branch has received your changes made on another branch.
(One thing to be aware of is when selecting Track Changeset, in the subsequent Select Branches dialog select all the branches you want to see in the visualization. It may be the case that just the branch associated with your starting changeset is selected and again you will not see the associated changesets on other branches).
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.