Tuesday, September 25, 2007

Get files from a Label

This post may be helpful for the people who are looking to get the content of a given label in a Workspace.

I looked for the code snippet on the internet unsuccessfully, to finally ask for help on the TFS Forum.

   

  VersionControlLabel[] labels = sourcecontrol.QueryLabels(labelname, “$/”, tfs.AuthenticatedUserName, false, null, null, false);

   

  if (labels.Length>0)

  {

    LabelVersionSpec lvs = new LabelVersionSpec(labels[0].Name);

    workspace.Get(lvs, GetOptions.None);

  }


As you can see, it’s really simple once you know about the LabelVersionSpec class and that you can use it with the Workspace::Get(VersionSpec, GetOptions) method.

There are several classes that derive from the VersionSpec one:

·         ChangeSetVersionSpec, to get the content of a given changeset into your workspace.

·         DateVersionSpec, to get the content that were checked in until the given date.

·         LabelVersionSpec, to get from a label.

·         LatestVersionSpec, to get the latest version.

·         WorkspaceVersionSpec, to get the content of another Workspace.

Posted by Loïc Baumann at 20:36:22
Comments

3 Responses to “Get files from a Label”

  1. i love your blog, great !

  2. Fantastic, Great Improvement, Keeping Working Hard, Wow.

  3. I admire your work,can you teach me how to write such a nice article

Leave a Reply