ProcessCommandUndoChangeSetItem

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

Moderator: SourceGear

Post Reply
jgoemat
Posts: 8
Joined: Mon Nov 23, 2015 4:05 am

ProcessCommandUndoChangeSetItem

Post by jgoemat » Tue Nov 24, 2015 4:14 pm

I'm writing tests as I learn to use vault and to understand exactly what the api calls do and I can't get this one to work reliably. Here I create two folders which puts them into a Pending Change Set in the client:

Code: Select all

ServerOperations.ProcessCommandCreateFolder("$/VaultWrapper.Tests");
ServerOperations.ProcessCommandCreateFolder("$/Test2/New1");
Image

So far so good. Now I want to try removing those pending changes, but I get an error:

Code: Select all

ChangeSetItemColl result;
var changeSet = ServerOperations.ProcessCommandListChangeSet(null);
for (int i = 0; i < changeSet.Count; i++)
{
    var item = changeSet[i];
    ServerOperations.ProcessCommandUndoChangeSetItem(i);
}
The error I get is (on the FIRST item, index 0):
"Invalid ChangeSetItem ID: 0. Please use the LISTCHANGESET command to retrieve a valid ID."

I saw this topic as I was using a path before and changed it to null as you can see above. It says the index is a global index into all pending changes, so I'm wondering also if calling it for 0 would mean the next item would be 0 the next time? Should I go through the list in reverse?

Also I deleted the pending changes in the vault GUI, then I committed the folders after creating them in code and deleted the folders using the vault GUI to try again. Now I'm getting "Object reference not set to an instance of an object." trying to create the folder again...

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

Re: ProcessCommandUndoChangeSetItem

Post by jclausius » Wed Nov 25, 2015 9:16 am

Yes. Call Undo with either 0 as the index or do them in reverse order.

In regards to the null reference, the API ships with the command line client code. You may want to open up the command line client, set the debug parameters for your CREATEFOLDER command and step through the command line client code to see if that has the same problem. This way you can get a better understanding of where the problem may lie.
Jeff Clausius
SourceGear

Post Reply