How Do I Determine an Item's Index for UndoChangeSetItem?

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

Moderator: SourceGear

Post Reply
splatteredbits
Posts: 18
Joined: Fri Mar 06, 2009 12:27 pm

How Do I Determine an Item's Index for UndoChangeSetItem?

Post by splatteredbits » Wed Oct 21, 2009 11:11 am

I'm trying to create a revert command: I want to be able to undo all pending additions, deletions, and modifications at any point in my repository tree without affecting any changes outside that part of the tree.

For example, if my tree looks like this:

Code: Select all

$
  Current
    Production
      Database
      Web
I would like to revert any pending changes at $/Current/Production/Database, but leave all other changes in place.

The closest command I found to accomplish this is ProcessCommandUndoChangeSetItem(int changeSetItemId). I'm having trouble figuring out what to use for the value of the changeSetItemId.

I've called ProcessCommandListChangeSet on the path I want to revert, but the collection of items I get back don't have any properties that seem to map to the change set item ID.

It appears this ID is an index (zero-based) into the list of all pending changes in a repository. So, I tried calling ProcessCommandListChangeSet(new [] { "$" }), but that took 10 or 15 minutes to complete.

What is the best way to accomplish what I want?

shannon

Re: How Do I Determine an Item's Index for UndoChangeSetItem?

Post by shannon » Wed Oct 21, 2009 1:01 pm

Try calling ProcessCommandListChangeSet(null) instead of passing in $. Passing null will short circuit to return the whole list.

You're correct, ProcessCommandUndoChangeSetItem is expecting an index -- you'll need to locate the index of the item you want to undo from the ChangeSetItemColl.

Post Reply