Performing a Rollback on a File

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

Moderator: SourceGear


Posts: 1
Joined: Tue Apr 15, 2014 1:01 pm
PostPosted: Thu May 22, 2014 12:40 pm
Hi,

How do I perform a rollback on a file through the API if I have the file and the version I want to revert to? I'm running Vault 6.1 Standard if it makes any difference.

Thank you

Posts: 3482
Joined: Tue Dec 16, 2003 1:17 pm
Location: SourceGear
PostPosted: Fri May 23, 2014 1:27 pm
If you have a Vault Object Version ID, try creating a VaultClientOperationsLib.ChangeSetItem_Rollback(), adding it to a Change Set, and then committing that to the repository.

For example (C#):

Code: Select all
using VaultClientOperationsLib;

long nTargetObjVerID = X; // where X = the Object Version ID of the file at $/some/path/to/file and version 2.

// create a change set
ChangeSetItemColl changeset = new ChangeSetItemColl();

// create a change set item for rollback
ChangeSetItem_Rollback rb = new ChangeSetItem_Rollback(VaultDateTime.Now, String.Empty, string.Empty, nTargetObjVerID, "$/some/path/to/file");

// add the item to the changeset
changeset.add(rb);

// commit the changeset... assumption is clientinstance has been allocated, login was successful and is set to the correct repository
try { clientinstance.Commit(changeset); }
catch (Exception e) { // TODO - log the exception and handle the exception }
Jeff Clausius
SourceGear

Return to Questions (API)

Who is online

Users browsing this forum: No registered users and 1 guest