0

I want to retrieve a list of all branches of a TFS workspace which are mapped locally. I already got a solution where I retrieve all branches of a VersionControlServer-Object, but that`s not what I want to get here. It should be a list specific for my workspace.

 var branchObjects = m_VersionControlServer.QueryRootBranchObjects(RecursionType.Full);
 List<string> branches = new List<string>();

 foreach (var branch in branchObjects)
 {
     var branchName = branch.Properties.RootItem.Item;
     branches.Add(branchName);
 }

Do u got any ideas how to check which of the branches where mapped at the local workspace? An instance of the specific workspace-class is available.

Baflora
  • 119
  • 9

2 Answers2

0

You can achieve this with the TFS tf command line tool

tf workspaces /owner:* /computer:* /collection:https://tfs.yourdomain.com/DefaultCollection /format:xml

If you don't have tf.exe, refer to this page How to get tf.exe (TFS command line client)?

spikey_richie
  • 440
  • 5
  • 20
0

Assuming you know the local path of your workspace you can use:

var workspace = versionControlServer.TryGetWorkspace(...path...)

Or you can use the Workstation class to query local workspaces on your machine.

Then from the workspace you can get the workspaces from the QueryWorkspaceInfo method and from there the mappings WorkspaceInfo.Mappings property. And from there you can check whether your branchroots (which you've already got figured out) are mapped in any of the workspaces on the server. If you want to be able to look up server path, you'll need to call the WorkspacnInfo.GetWorkspace method and from there use the Workspace.Folders property.

jessehouwing
  • 106,458
  • 22
  • 256
  • 341