2

We have situation where make label with 4 files (lets say that all project consists from 10 files, so another 6 files are not placed in our new label).

When do action Get Specific Version and for Version Type place Label and after that choose our new label, all files from local folder that are not included in new label (in our example, another 6 files) are being deleted!!! This is very weird situation, so could you explain scenario where I want to get specific version of files that are marked in new label, but to keep existing version for all other files and keep them in local folder, so I want just to update files that are in my new label and do nothing with files that are not in lablel???

I suppose that there is some setting in TFS that probably can prevent deleting these files!

TnX in advance!

Nemanja

Nemanja Vujacic
  • 925
  • 5
  • 14
  • 25
  • It seems you are performing Get Specific Version on Parent Folder, Instead click the files which are labelled and then do Get Specific Version. – Jehan33 Mar 10 '11 at 15:18
  • Exactly, is it possible to Get Specific Version of project (Parent Folder) and don't care which files are placed in label that want to get? For example, if I have 50 files in different subfolders, may I just click at parent folder and get all these files while keeping existing local files that are not changed? – Nemanja Vujacic Mar 10 '11 at 15:24
  • Want to know how you are creating Label. From Apply Label option either you can choose a folder or file to Label but not select multiple and perform apply label. If you have 50 files in different subfolders then either you apply label to parent folder which consists the different subfolders or you will choose one subfolder/file and create a label, then edit the label and add or remove the files/folders as required. How you are doing this? – Jehan33 Mar 10 '11 at 17:02
  • If you're using right click at file or folder than you can apply label on only one item, but when I want to apply it at multiple files at once, than going to Label window (File->Source Control->Label->Find Label and double click at chosen label) where is placed Add Item button that I use to add multiple files. – Nemanja Vujacic Mar 11 '11 at 08:10
  • Just had this happen to me.. very annoying! I am using "Pandora Recovery" to try and restore the files, because I have no other backup. – mellamokb Jun 17 '14 at 20:02

1 Answers1

6

This is working as designed. Be very careful with Labels in TFS, they're a bit different from the labels you might be used to in other types of source control. In TFS labels are very mutable, and can easily be moved on just a single file. They're powerful, but dangerous.

As mentioned, you can do the get by label for individual files and you'll be fine. However, when you do a specific get by label on a folder, you are asking TFS to restore everything in that folder to the same version that is indicated on the label. If a file in that folder is not labeled, it is not going to match any version label, and is going to be deleted.

Keep in mind that a single file/version in TFS can have multiple labels, so one way you could get around this is to label all files in that directory with a new label, then move this new label to the same revision as the other label.

Consider three files in $/Project/Folder... two are labeled with LABEL_A, and one is not labeled at all. You would do something like this.

tf label /server:http://tfs:8080 LABEL_B $/Project/Folder /recursive

This will label all of the files with LABEL_B. Now you need to move LABEL_B to the correct version of the LABEL_A files:

tf label /server:http://tfs:8080 LABEL_B $/Project/Folder /recursive /version:LLABEL_A

Note that there are two L's after the /version:... this tells TFS to move that label from one version of the file to another version.

Once that is done, get specific based on LABEL_B, and you should be good to go.

Robaticus
  • 22,857
  • 5
  • 54
  • 63
  • Thank you for this detailed answer! Could you please explain again second command? Does it mean that it will apply LABEL_B to version of file that has been marked with LABEL_A? I suppose that first command apply LABEL_B at latest versions of all files, but what I can do in cases when want to label some other (older) version of file (if I had check-ins that don't want to label yet, i.e. that are not for production version, but I'm making label for production version)? Let's consider situation where each file have 3 different changesets and I want to take different version for each. – Nemanja Vujacic Mar 11 '11 at 08:01
  • @Nemanja - you will need to be as specific as possible with your path and version commands. If you want to apply (or move) the label to a specific changeset version of a file, use `/version:C999999` where the 9's are replaced with the number of your changeset. When dealing with labeling files, I always try to apply it to the broadest set of files first, then move that label to other versions of files as appropriate. – Robaticus Mar 11 '11 at 13:04