Challenge with history listing

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

Moderator: SourceGear

Post Reply
jbrown
Posts: 9
Joined: Mon Jun 30, 2008 11:31 am

Challenge with history listing

Post by jbrown » Mon Jun 30, 2008 11:35 am

I'm attempting to retrieve a list of all items checked in as of a date range and am not getting back all results.

ServerOperations.client.LoginOptions.URL = "http://devsrv";
ServerOperations.client.LoginOptions.User = "user";
ServerOperations.client.LoginOptions.Password = "pass";
ServerOperations.client.LoginOptions.Repository = "dev-rep";
ServerOperations.client.AutoCommit = true;
ServerOperations.client.Verbose = true;
ServerOperations.client.LoginOptions.AccessLevel = VaultClientNetLib.VaultConnection.AccessLevelType.Admin;

ServerOperations.Login();

string filePath = "$/filepath";


StringWriter sw = new StringWriter();
System.Xml.XmlTextWriter xml = new XmlTextWriter(sw);
xml.Formatting = System.Xml.Formatting.Indented;


//Query the file history so we can view the check in.
bool bRecursive = false;
int beginVersion = -1;
int endVersion = -1;
string excludedList = "add,create,label";
string startDate = "06/01/2008";
string endDate = "06/30/2008";
VaultHistoryItem[] items = ServerOperations.ProcessCommandHistory(filePath, bRecursive, DateSortOption.desc, null, excludedList, startDate, endDate, null, null, beginVersion, endVersion, 30);
// output the history items
xml.WriteStartElement("root");



xml.WriteStartElement("History");
XmlHelper.XmlOutput(xml, items);
xml.WriteEndElement();

xml.Close();
Console.Out.WriteLine(sw.ToString());

I've checked in new items today and do not see them in the list. Any ideas would be appreciated.

shannon

Post by shannon » Mon Jun 30, 2008 12:05 pm

You are telling it to only return 30 rows (the last parameter). It is returning the first 30 results it finds.

jbrown
Posts: 9
Joined: Mon Jun 30, 2008 11:31 am

Post by jbrown » Mon Jun 30, 2008 12:15 pm

right...

I checked in 5 files last week, 3 today.

Only getting 5 back in the list.

shannon

Post by shannon » Mon Jun 30, 2008 2:06 pm

Most likely, since you aren't giving it a time, it's defaulting to the very beginning of 6/30. Try passing it the current time as part of the date string.

jbrown
Posts: 9
Joined: Mon Jun 30, 2008 11:31 am

Post by jbrown » Tue Jul 01, 2008 6:32 am

No juice. I've attached an .xls file for your review. The tabbed worksheets are named for their source - one from the Vault client, one from the API.

Thanks for your help.
Attachments
vault-history.xls
Outputs from Vault Client and API
(14 KiB) Downloaded 604 times

shannon

Post by shannon » Tue Jul 01, 2008 7:26 am

The tab labeled vault-history is a non-recursive history. The vault-history-from-client tab is a recursive history. Is this the problem?

jbrown
Posts: 9
Joined: Mon Jun 30, 2008 11:31 am

Post by jbrown » Tue Jul 01, 2008 9:57 am

Excellent. Now how do I pass only the latest version to prevent duplicate files in the list?

shannon

Post by shannon » Tue Jul 01, 2008 10:27 am

Can you clarify what you're trying to do exactly?

In the example you are passing a file path, from the excel file I think you actually passed a folder.

Is this what you mean: you want to pass a folder and get back only one entry per file or folder, that entry being the one with the latest version? Or did you want to do them file by file, one history call each?

jbrown
Posts: 9
Joined: Mon Jun 30, 2008 11:31 am

Post by jbrown » Tue Jul 01, 2008 10:35 am

Ultimately what I'm trying to get is all the checkins to the repository within a date range so we can build weekly releases.

The recursion brought back what I was looking for in that I can now see all the files in the root and subdirectories (hadn't realized this until you mentioned the recursion). This now matches the History filter on the Vault client when recursion is selected. Perfect....except:

Now I only want the most recent version of each file checked in within a date range; and thought using the ProcessCommandHistory could give me what I was looking for.

Thanks very much for your help so far.

shannon

Post by shannon » Tue Jul 01, 2008 12:24 pm

The easiest thing to do would be to loop over the items that are returned and pull out the ones that meet your criteria (latest version for each unique path).

jbrown
Posts: 9
Joined: Mon Jun 30, 2008 11:31 am

Post by jbrown » Tue Jul 01, 2008 2:40 pm

What purpose do the beginVersion and endVersion parameters have in the ProcessCommandHistory then?

shannon

Post by shannon » Tue Jul 01, 2008 2:54 pm

Those will apply to the version of the folder or file you pass as the root object, but not recursive items when you're using a folder as the root object with recursion.

jbrown
Posts: 9
Joined: Mon Jun 30, 2008 11:31 am

Post by jbrown » Tue Jul 01, 2008 2:58 pm

Thanks for the insight on that.

How does the Deploy Wizard do it? I'm really looking for a customized version of it to return a list of the checked in files based on the date range (as mentioned).

Any ideas?

shannon

Post by shannon » Wed Jul 02, 2008 8:20 am

Deploy just does a get. It only gets the most recent version of each file.

Post Reply