Version control for TFS

Source: Internet
Author: User

In TFS, versioning is controlled in the workspace workspace.

First of all, we first workspace some basic methods of use.

CheckIn: Moving to Pending operations

CreateMapping: Create a local mapping address

Delete: Remove workspace

Getpendingchanges: Getting a Pending workspace

Merge: Merging work items

Pendadd: Queued files or a folder added to the version control repository

Pendbranch: Schedule A branch of a file or folder

Penddelete: Queues Delete files or folders from the version control repository

Pendedit: Edit checkout file from version control repository

Next, we'll look at how to create a local mapping address, get a pending workspace, queue a file, move to a pending operation, and so on.

//TFSURI
Uri tfsUri = new Uri("http://pc-20130113jkun:8080/tfs");
TfsTeamProjectCollection projectCollection = new TfsTeamProjectCollection(tfsUri);
//设置版本控制Server
VersionControlServer versionControl = projectCollection.GetService<VersionControlServer> ();

Set Workspace name
String workspacename = String.Format ("{0}-{1}", Environment.MachineName, "Test");
Workspace Workspace = Versioncontrol.getworkspace (workspacename, Versioncontrol.authorizeduser);
Setting Up server folders
var serverfolder = "$/calueng";
Setting up a local mapping file
var localfolder = Path.Combine ("c:\\temp\\", "Test");
Set as working directory folder
var workingfolder = new WorkingFolder (serverfolder, Localfolder);
Create a local mapping address for a workspace
Workspace. CreateMapping (WorkingFolder);
Get a workspace file and download all files
Workspace. Get ();
Create a Test folder
String NewFolder = path.combine (workspace. Folders[0]. Localitem, "Test folder");
Directory.CreateDirectory (NewFolder);
String NewFileName = Path.Combine (newfolder, "Test document 1.txt");
Create a test file
using (var StreamWriter = new StreamWriter (NewFileName))
{
Streamwriter.writeline ("This is the text of the test document");
}
Queue this file for moving into TFS management
Workspace. Pendadd (Path.getdirectoryname (NewFileName), true);
Create a collection of file items waiting to be added
var pendingadds = new list<pendingchange> (workspace. Getpendingchanges ());
To checkin a work item in a system
int changesetforadd = workspace. CheckIn (Pendingadds.toarray (), "Here is the memo message");
Console.WriteLine ("moved into work item {0}", Changesetforadd);
Console.ReadLine ();

SOURCE Download: Http://files.cnblogs.com/chengxingliang/TFSTest2.rar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.