Filtering files in a VaultHistoryQueryRequest

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

joel
Posts: 38
Joined: Mon Feb 02, 2004 5:18 pm

Filtering files in a VaultHistoryQueryRequest

Post by joel » Wed Jun 23, 2004 2:31 pm

Is there a way to filter out only files/folders from a VaultHistoryQueryRequest (other than filtering by the HistoryActionTypes)?

Thanks,
Joel

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

Post by jclausius » Wed Jun 23, 2004 2:57 pm

From the Vault Help - History Query Filter section -

"Filenames
The Filenames tab includes the following selections. Check the appropriate filter for the search. Valid wild card characters are * and ? . To search for any string of zero or more characters use *. To search for any single character use ?.

· Do not filter by filename

· Include by file extension – Include only files with the specified file extension. File types can be separated by spaces, commas or semicolons. If a period is not entered before the string, it will be added. You can use the wildcard character ‘*’, but it only applies to the file extension, and not to any other part of the file (so, for example, *.txt will not retrieve any .txt files, but both .t*t and t*t will).

· Include by name substring – Include only files whose names match the input substring. The ‘*’ wildcard character can be used in the substring You cannot enter multiple substrings to query against.

The default is Do not filter by filename."

It is ambiguous what you mean by "filter out only files/folders". Do you wish to *exclude* the items or *include* only those items? If include, then see text above.
Jeff Clausius
SourceGear

joel
Posts: 38
Joined: Mon Feb 02, 2004 5:18 pm

Post by joel » Wed Jun 23, 2004 3:01 pm

Actually, I meant through the API is there a way to include only files or folders? I'm writing some code to try and identify branched files that haven't been merged yet into their parent trunks (or any trunks, for that matter).

Thanks,
Joel
jclausius wrote:From the Vault Help - History Query Filter section -

"Filenames
The Filenames tab includes the following selections. Check the appropriate filter for the search. Valid wild card characters are * and ? . To search for any string of zero or more characters use *. To search for any single character use ?.

· Do not filter by filename

· Include by file extension – Include only files with the specified file extension. File types can be separated by spaces, commas or semicolons. If a period is not entered before the string, it will be added. You can use the wildcard character ‘*’, but it only applies to the file extension, and not to any other part of the file (so, for example, *.txt will not retrieve any .txt files, but both .t*t and t*t will).

· Include by name substring – Include only files whose names match the input substring. The ‘*’ wildcard character can be used in the substring You cannot enter multiple substrings to query against.

The default is Do not filter by filename."

It is ambiguous what you mean by "filter out only files/folders". Do you wish to *exclude* the items or *include* the items? If include, then see text above.

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

Post by jclausius » Wed Jun 23, 2004 3:10 pm

First Set VaultHistoryQueryRequest.SubstringType to one of the following types in VaultLib.VaultQueryRequestSubstrings.

Next set VaultHistoryQueryRequest.Substrings to a string array (string[]) of the names you would like to filter.

HTH
Jeff Clausius
SourceGear

joel
Posts: 38
Joined: Mon Feb 02, 2004 5:18 pm

Post by joel » Fri Jun 25, 2004 1:04 pm

Actually, that doesn't work if the folder name itself has a "." in it. Then, even though I'm searching by file extension ".*", it picks up those folders. Is there yet another way to filter by object type perhaps?

Thanks,
Joel
jclausius wrote:First Set VaultHistoryQueryRequest.SubstringType to one of the following types in VaultLib.VaultQueryRequestSubstrings.

Next set VaultHistoryQueryRequest.Substrings to a string array (string[]) of the names you would like to filter.

HTH

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

Post by jclausius » Fri Jun 25, 2004 1:23 pm

I think there is a small misnomer in the name of the members. The strings themselves are not "OBJECT" filters (only get files), but are in actuality object name filters.

For example, you could do something like *.?* which would retrieve all objects which contain a period followed by at least one character. However, if a directory is named dir.old, that would show up in the query.

In the general case *.doc, *.txt, *.cpp, *.asm work because most objects matching that case are files. However, if a folder was named Foo.cs, this might show up in a history query filtering on *.cs.

To answer your very first post, it appears the only way to filter out history for a folder only or file only is to examine the object properties of the results. I thought the name filter would work, but obviously it is not fool-proof.

HTH
Jeff Clausius
SourceGear

joel
Posts: 38
Joined: Mon Feb 02, 2004 5:18 pm

Post by joel » Fri Jun 25, 2004 1:35 pm

Not a problem, but could you point me to which property gives the item's type (folder or file)? I see the Type property for history objects, but not an accompanying enum.

Thanks,
Joel
jclausius wrote:I think there is a small misnomer in the name of the members. The strings themselves are not "OBJECT" filters (only get files), but are in actuality object name filters.

For example, you could do something like *.?* which would retrieve all objects which contain a period followed by at least one character. However, if a directory is named dir.old, that would show up in the query.

In the general case *.doc, *.txt, *.cpp, *.asm work because most objects matching that case are files. However, if a folder was named Foo.cs, this might show up in a history query filtering on *.cs.

To answer your very first post, it appears the only way to filter out history for a folder only or file only is to examine the object properties of the results. I thought the name filter would work, but obviously it is not fool-proof.

HTH

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

Post by jclausius » Fri Jun 25, 2004 2:40 pm

<snip>

Just a sec - what I had posted previously was incorrect. Will post correction soon.
Jeff Clausius
SourceGear

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

Post by jclausius » Fri Jun 25, 2004 9:31 pm

Sorry. This took a minute to track down. The defines are only available within the server side libraries, So I'm just posting them here, as you will undoubtably need them.

Here is the bitmask to use:

Code: Select all

// fs object types
public const ushort ObjPropFolderMask = 0x0001;
public const ushort ObjPropFileMask = 0x0002;
public const ushort ObjPropBranchMask = 0x0004;
public const ushort ObjPropSnapshotMask = 0x0008;
public const ushort ObjPropVirtualMask = 0x0010;
For example, when (historyresult.objprops & ObjPropFolderMask) == ObjPropFolderMask, then the query item is a folder.

And when (historyresult.objprops & ObjPropFileMask) == ObjPropFileMask, the query item is a file.

When historyresult.objprops == (ObjPropFolderMask | ObjPropBranchMask), the query item is a branched folder.

And finally when historyresult.objprops == ( ObjPropSnapshotMask | ObjPropFileMask ), the query item is a snapshot file.
Jeff Clausius
SourceGear

realtytrac
Posts: 34
Joined: Wed Jun 15, 2005 2:07 pm

follow up

Post by realtytrac » Tue Jun 28, 2005 11:57 am

where are you getting the historyresult.objprops from? Is that somewhere in the VaultHistoryQueryRequest object, or is it in the VaultHistoryItem object?

I want to find out after doing the query whether the item is a folder or file just like the original poster of this issue was seeking.


Haider

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

Post by jclausius » Tue Jun 28, 2005 12:08 pm

After you instruct the server to run a history query, the results are availble for pickup using GetHistoryQueryItems(). The VaultHistoryItem[] holds the results (and the object's properties).

Remember to be kind and call EndHistoryQuery() after the results have been retrieved.
Jeff Clausius
SourceGear

realtytrac
Posts: 34
Joined: Wed Jun 15, 2005 2:07 pm

Post by realtytrac » Tue Jun 28, 2005 12:38 pm

jclausius wrote:After you instruct the server to run a history query, the results are availble for pickup using GetHistoryQueryItems(). The VaultHistoryItem[] holds the results (and the object's properties).

Remember to be kind and call EndHistoryQuery() after the results have been retrieved.
Where is the GetHistoryQueryItems function? For which object? Also, i have not been able to find the "historyresult.objprops" that you were talking about. It is not a property of the VaultHistoryItem or the VaultHistoryQueryRequest. I want to do the comparison and check for folders vs. files as you have illustrated.

thanks

haider

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

Post by jclausius » Tue Jun 28, 2005 1:03 pm

Sorry, I was looking at things from the server side of things. I believe you can call HistoryBegin / HistoryFetch / HistoryEnd of the VaultConnection object.

Also, the member you will be looking at is the .Type of the VaultHistoryItem.
Jeff Clausius
SourceGear

mmoayyed
Posts: 26
Joined: Tue Feb 26, 2008 12:43 pm

Re: Filtering files in a VaultHistoryQueryRequest

Post by mmoayyed » Fri Jun 12, 2009 1:35 pm

I am using the Vault Client API Version 4.1.0.16216 and I dont seem to be able to filter out only folders. My goal is to retrieve all items in a number of given folders that have specific comment. The TopName property of the VaultHistoryQueryRequest is set to $ and the SubstringType is set to VaultQueryRequestSubstrings.FileFolderNames. However, when I specify a given folder name in a String array that gets assigned to the Substrings property, no rows are retrieved. If I specify *.* or the exact name of one of the files, the query works. I am 100% positive that the folder name exists, is valid and contains an item with the comment I am looking for.

Given the number of records my query returns, it would greatly speed things up if I could do this filter as part of a query and not afterwards in a loop or something like that.

Is this possible at all ?


Thanks

shannon

Re: Filtering files in a VaultHistoryQueryRequest

Post by shannon » Fri Jun 12, 2009 2:31 pm

It's not matching that string on any part of the path, just the object name. So, if one of the items in a given folder had the given folder name as part of it's name (i.e. Strings/ServiceStrings.cs), it would be returned (if it also matched your other criteria).

I would suggest running one query for each of the desired folders (setting TopName to the desired folder path), will that work for your purposes?

Post Reply