ProcessCommandBranch for a single file

Post your questions regarding using the Vault and Fortress API in your programs.

Moderator: SourceGear

Post Reply
stanyork
Posts: 21
Joined: Thu Apr 30, 2009 5:09 pm

ProcessCommandBranch for a single file

Post by stanyork » Mon Dec 28, 2009 5:52 pm

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?

shannon

Re: ProcessCommandBranch for a single file

Post by shannon » Tue Dec 29, 2009 8:46 am

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.

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);

Let me know if you have any problems with this.

stanyork
Posts: 21
Joined: Thu Apr 30, 2009 5:09 pm

Re: ProcessCommandBranch for a single file

Post by stanyork » Tue Dec 29, 2009 11:30 am

Worked perfectly, thanks

shannon

Re: ProcessCommandBranch for a single file

Post by shannon » Tue Dec 29, 2009 11:42 am

Glad to hear it.

Post Reply