Is there a way to rename a TFS label? - tfs

Our code is branched in TFS along project lines, and each has its own separate build process
We label each project with the build number, e.g. Build_1, etc however I made the dumb mistake of forgetting that TFS labels must be unique and forgot to label my project with the name of the project.
To explain, I have labelled the P5624 folder four times with Build_1, Build_2, Build_3 & Build_4 when I should have used labels like P5624-Build_1, etc.
So, I am looking for a way to rename the labels. I couldn't find anything directly related on SO, and the microsoft Help on the TF Label command (link here) doesn't give any indication that it can be done.
We don't do any automated builds or have anything that relies on a label name, so even if your solution is a "do it at your own risk" then I would still be happy to hear it.

Renaming Labels is not supported by TFS. You can only create a new Label based on the old Label you want to remove.
If your are using Visual Studio, here are the steps how to do it
Right click the folder at Source Control Explorer to open
ContextMenu and select 'Apply Label'
Change the Version-Combobox at the bottom to Label and find the old Label "P5624"
Name the new label "P5624-Build_1" and create it
Delete the old label if it isn't needed more.

Related

Why in TFS I cannot apply a label on files listed in Changeset Details window?

As in subject:
Go to "Find Changeset" option.
Find a changeset.
Double-click on changeset to open Changeset Details window.
It gives a list of all files that have been checked in within given changeset.
Why I cannot apply a label on those files from that level where I have them all in one place? Especially, that very often they are part of different solutions and projects, so normally I would have to create a label for one file and then search and add one by one to the existing one.
It is so inefficient!
Is it some bug or lack of functionality? If the second - it is hard to believe MS guys forgot about such handy function.
How do you deal guys with such situation?
EDIT - to clarify my reasoning:
If I use jessehouwing's method - yes, it works and it's simple.
But then when I search in the future for that label and want to see what code was included, it gives me a list of all solutions - even those totally unrelated (IWP and PDPRO are the unwanted ones):
If I use it my way - it gives me that:
I think it looks cleaner and gives directly the information of what solutions and files underneath where included at the time when I put stuff into Production environment and applied corresponding PROD label.
The feature you're looking for doesn't exist. generally a single file or group of files at a label doesn't make a lot of sense. While it's possible to "scope" labels in TFVC, it's only possible through the commandline.
generally you'd create a label at the repo or branch level at the specified changeset. That will include all files, including the ones you just checked in. Creatign such label is relatively easy from the source control explorer, though you need to copy the changeset number:
It's unclear to me why you'd only want the changed files to be included in the label, maybe you can elaborate a little more on that requirement.
Update: What you desire isn't possible from inside VS and isn't simple from the commandline either. I suppose that with a bit of Powershell Magic against the TFS Client Object Model you can do this from the commandline and it should also be possible to build this as a Visual Studio Extension (or maybe suggest it to the author of the TFS Source Control Explorer Extensions.

TeamCity, TFS, and Labeling

We are using TeamCity for continuous integration and TFS as our VCS. I am able to apply a label to a build using the VCS Labeling build feature. This works exactly as we expect it to but with one minor glitch that we can’t seem to figure out.
In the TFS source control explorer, I go to the top level of the project. From there I can select view history. On the view history I select the Labels tab. Here I see something like this.
Name | User | Date |Changeset | Comment
MyLabel |username|datetime|12345 |TeamCity automatic label
This is all well and good except that the Changeset number is always the very first one that was ever done for this branch. Is there a way to configure the changeset setting? As a bonus, setting the comment would also be great.
Thanks
This is not a glitch, but rather how TFS labels works.
The change set shown on the label is the change set of when the root folder within the label was last modified.
The reason for this is because labels are not a point in time snapshot of files as they are mutable.

Using TFS Labels like SourceSafe Labels

We have a fairly standard release procedure using Visual Source Safe for labeling a build before it is released. This allows us to do a get from that label if there are any problems and use it to branch if changes are necessary.
We have several different projects and always label using the builds version number.
e.g. "V1.0"
After moving some projects to TFS we have noticed that if you try to label using the same version number as another solution e.g. Solution A and Solution B both release "V1.5" then TFS will not let you do this as the Label name is treated globally. After reading a few blogs on the subject which discusses how TFS labels are not a point in time but a collection of files I am thinking that we will have to start including the project name in the label to get around this e.g. label as "Project A V1.5" and "Project B V1.5". Does this sound like the right approach?
If you haven't read Brian Harry's Why TFS labels aren't like SourceSafe labels, please do.
Basically the answer to your question is YES!

Can you retrive a specific marked version for an entire SOLUTION?

I'm extremely new to TS and it's not apparent to me. It's seems to me that it must be in there. Could someone please point out how to go about marking a whole solution with a version number or label and then retrieving that specific version back from the repository?
Thx
Applying the label isn't the easiest thing to find. You can get to it by right clicking on the folder containing your solution file in the Source Control Explorer window (which you can get to by double-clicking on the Source Control node in Team Explorer). When you apply the label, apply it to the folder containing the things you want included in the label. Then ensure that the next screen shows you the contents of that folder (i.e. all the files you want to label)
In TFS a label is a bit like a tag. It is actually something that can be edited and you can have files of different versions included in it if you really needed to.
There is also the concept of "Changesets" in TFS. A changeset is a number that always increments on a particular server (or Project Collection in TFS2010). The number represents a unique point in time for that server instance.
To get the files from a particular version, in Solution Explorer right click on your solution and do "Get Specific Version..." In the Version group box you can change the type from the default Latest Version to specifing the Changeset, Date or Label if you want to get a version from an older point in time.
Hope that helps.
Martin.

How do I figure out which changeset a label in TFS was applied to?

We're using Team Foundation Server and we are using Labels to create points in our version history where specific versions (either internal or external) were produced.
Right now we were wondering if a particular changeset was done before or after a specific label (and thus included in that version or not), but we must be looking in the wrong place. This information is usually provided in the bug-tracking system but this time this field was left open so we thought we could use TFS to figure it out.
The version history for a file doesn't include labels applied. To find labels, the place I know to look is to use the "Get Specific Version" dialog, set type to Label and use the Label selection dialog to see which labels we've made, but this dialog doesn't tell me the changeset before/after the label was applied.
Is the only way to figure out if a particular change was part of that release or not to create a new workspace, map up the directory with the files to a temporary directory on disk, use the Get Specific Version dialog to extract that release and do a file-diff?
Please tell me how stupid I am and point me in the right direction.
Run in your local workspace
tf history . /stopafter:1 /noprompt /r /version:Lmylabel
to get
Changeset User Date Comment
--------- ------------- ---------- --------------------------------------------
88888 brian_low 11/11/2012 did some work
Have you tried opening Source Control Explorer, File -> Source Control -> Labels -> Find Label? [EDIT: that may have been in a beta version, and I don't have TFS here atm...]
Also, are you using SideKicks? The Labels SideKick allows you to find a label and see the related changesets.
A label in TFS does not represent a specific point in time - and a label can actually be edited after the event. See the following posts for more information:
Buck Hodges: Finding Changes between two labels in TFS VC
Brian Harry: Why TFS Label are not like VSS Labels.
For this reason, I tend to use Changesets in TFS when recording the point in time for a particular release (in fact we label our binaries and installers with the actual changeset number that they were built from just to make it easier to track). (A changeset does represent a unique point in time for the state of the repository).
Hope this helps,
Martin.
Faced this issue for the first time today. From now on I am including the changeset-number in the label-comment. Not very elegant workaround, but meets my needs.

Resources