Retrieving deleted file history

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

Moderator: SourceGear

Post Reply
Aestros
Posts: 17
Joined: Mon Jun 16, 2008 7:54 am

Retrieving deleted file history

Post by Aestros » Mon Jun 16, 2008 7:58 am

I'm working with the API and I've encountered a problem. I need to get every version of a project from vault. Everything works fine for the moment except for deleted files.

The only way to retrieve history of a deleted file is to force an undelete on it and this makes a new log in the file history. So my question is, can we get the history of a deleted file without undeleting it ?

shannon

Post by shannon » Mon Jun 16, 2008 11:45 am

There isn't a way to get the history for a deleted file.

However, getting each version of a folder should cover all the versions of the files within that folder.

Aestros
Posts: 17
Joined: Mon Jun 16, 2008 7:54 am

Post by Aestros » Mon Jun 16, 2008 11:57 am

Thanks for the tips. It seems to work if I get the folder instead of the file directly.

Aestros
Posts: 17
Joined: Mon Jun 16, 2008 7:54 am

Post by Aestros » Mon Jul 07, 2008 2:28 pm

One more question about undelete operation.

I've tried to find a way to "undelete" files with the API but I wasn't able to find a function to do it.
Can you help me out ?

Thanks !

shannon

Post by shannon » Mon Jul 07, 2008 2:49 pm

You'll just need to create changeset items and commit them:

Code: Select all

				VaultClientOperationsLib.ChangeSetItemColl items = new ChangeSetItemColl();
				foreach (VaultDeletedObject d in deletedObjects)
				{
					VaultClientOperationsLib.ChangeSetItem item = null;

					if (d != null)
					{
						item = new ChangeSetItem_Undelete(VaultDateTime.Now, String.Empty, String.Empty, d.ID, d.FullPath, d.DeletionID);
					}				

					items.Add(item);
				}
				ret = _clientInstance.Commit(items);
And you get a list of deleted items from a folder this way:

Code: Select all

ClientInstance.ListDeletedObjects(_vFolder.FullPath, false);

Aestros
Posts: 17
Joined: Mon Jun 16, 2008 7:54 am

Post by Aestros » Mon Jul 07, 2008 2:54 pm

Was already able to get all the deleted objects :).
The "ChangeSetItemColl" routine was what I was looking.

Thanks a lot again for the fast answer

shannon

Post by shannon » Mon Jul 07, 2008 2:58 pm

Great, just wanted to cover all the bases :-)

Aestros
Posts: 17
Joined: Mon Jun 16, 2008 7:54 am

Post by Aestros » Tue Jul 08, 2008 11:34 am

One more thing.
Your routine work very well, it's easy to undelete every files with this, but, the comment are not showing up in Vault Client even if I change the 1st string.Empty and add a comment parameter in the .commit call. Is this an expected behavior ? Because I know you can't add comment directly from your Client application when undeleting objects but your API function support it.

Original code

Code: Select all

VaultClientOperationsLib.ChangeSetItemColl items = new ChangeSetItemColl(); 
            foreach (VaultDeletedObject d in deletedObjects) 
            { 
               VaultClientOperationsLib.ChangeSetItem item = null; 

               if (d != null) 
               { 
                  item = new ChangeSetItem_Undelete(VaultDateTime.Now, String.Empty, String.Empty, d.ID, d.FullPath, d.DeletionID); 
               }             

               items.Add(item); 
            } 
            ret = _clientInstance.Commit(items); 
Changed line #1 :

Code: Select all

item = new ChangeSetItem_Undelete(VaultDateTime.Now,"Automated Undelete", String.Empty, d.ID, d.FullPath, d.DeletionID); 
Changed line #2 :

Code: Select all

ret = _clientInstance.Commit(items,"Automated Undelete"); 

shannon

Post by shannon » Tue Jul 08, 2008 11:58 am

Try setting the comment this way:

ClientInstance.InternalChangeSet_SetComment("comment");

I think you're wanting to set the change set comment, not an item comment.

Aestros
Posts: 17
Joined: Mon Jun 16, 2008 7:54 am

Post by Aestros » Tue Jul 08, 2008 12:29 pm

Nice !

It's working for the "Change Set Comment" as you said.
Thanks ! :)

Post Reply