Performing a Rollback on a File

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

Moderator: SourceGear

Post Reply
durgindaniel
Posts: 1
Joined: Tue Apr 15, 2014 1:01 pm

Performing a Rollback on a File

Post by durgindaniel » 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

jclausius
Posts: 3702
Joined: Tue Dec 16, 2003 1:17 pm
Location: SourceGear
Contact:

Re: Performing a Rollback on a File

Post by jclausius » 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

Post Reply