Attempting to use API to create a new major version for our product - which requires 3000 operations, mostly copy-branches and shares as appropriate.
When we attempt
ServerOperations.ProcessCommandBranch(fromItem, newpath)
Where:
a) fromItem is the full vault item path (not working folder path)
b) newPath is the target vault folder path (OR full target vault item spec -- e tried it both ways)
c) it has been determed we need a copy-branch (its a .sln file in this case...don't want to share that across versions...)
d) the item does not yet exist in the target location
we get a VaultClientIntegrationLib.UsageException : {"$/sourc-item-exists, but this command may not be used to branch individual files."}
How can this be accomplished using the API?
ProcessCommandBranch for a single file
Moderator: SourceGear
Re: ProcessCommandBranch for a single file
There isn't a convenience method that will operate on a single file in this case.
The following code should get you started. file is the VaultClientFile object. branchFolderPath is a full repository path, i.e. <repository destination folder> + "/" + file.Name.
Let me know if you have any problems with this.
The following code should get you started. file is the VaultClientFile object. branchFolderPath is a full repository path, i.e. <repository destination folder> + "/" + file.Name.
Code: Select all
ChangeSetItemColl items = new ChangeSetItemColl();
ChangeSetItem item = new ChangeSetItem_CopyBranch(VaultDateTime.Now, branchComment, "To " + branchFolderPath, file.FullPath, branchFolderPath, file.ObjVerID, bBranchWithOrigModTime);
items.Add( item );
ServerOperations.client.ClientInstance.InternalChangeSet_Append(items);
long nRevID = 0;
bool bSuccess = client.ClientInstance.Commit(items, false, false, ref nRevID);
Re: ProcessCommandBranch for a single file
Worked perfectly, thanks