VaultLib API - Get files by label

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

Moderator: SourceGear

Post Reply
Xomen
Posts: 6
Joined: Mon Nov 20, 2006 6:06 pm

VaultLib API - Get files by label

Post by Xomen » Fri Jan 05, 2007 6:24 pm

Kindly Vault People,

I'm trying to write a nAnt task which generates some differential information based on two different labels. I can get the label information without any trouble using the GetByLabel_GetStructure call and iterating over the folder that comes back. I call this twice, on the first (older) label and then the last (newer) one.

I run into trouble when I try to get files from one of the labels (the older one). I tried calling:

ClientInstance.GetLabeledFileToNonWorkingFolder(vcfile, startLabel, null, ref outpath);

Where "vcfile" is the VaultClientFile pulled from the results of the first call to GetByLabel_GetStructure. I keep getting an "invalid path" error when I make the GetLabeledFileToNonWorkingFolder call.

However, if I re-get the VaultClientInfo from the tree cache, it works:

VaultClientFile refile = ClientInstance.TreeCache.Repository.Root.FindFileRecursive(vcfile.ID);
refile.ObjVerID = 0;
refile.Version = oldVersion;

GetLabeledFileToNonWorkingFolder likes "refile", but not "vcfile". Why? I'm wary of performing this extra step if it's not necessary.

Also, since I have a list of VaultClientFiles, with the correct versions set, is there any way I can call ClientInstance.GetByDisplayVersionToNonWorkingFolder with a file array? I tried this, but had trouble getting the call to work.

I guessing that something here is in the wrong state, but I don't know what the right steps are to get it back in order.

Xomen
Posts: 6
Joined: Mon Nov 20, 2006 6:06 pm

Post by Xomen » Fri Jan 05, 2007 7:10 pm

Me again. I'm also noticing that it's difficult to get a file which has been deleted subsequent to the labeling-- the FindFileRecursive (using the ID) fails. Since I can't seem to use the VaultClientFile from the GetByLabel_GetStructure, how do I get that old version?

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

Post by jclausius » Mon Jan 08, 2007 10:13 am

All gets require the ItemPath be set to a valid file found in the current repository. My guess is the item's path is null, empty, or invalid.
Jeff Clausius
SourceGear

Xomen
Posts: 6
Joined: Mon Nov 20, 2006 6:06 pm

ItemPath

Post by Xomen » Mon Jan 08, 2007 2:16 pm

Do you mean the vcfile.FullPath? They are indeed different. vcfile's path is relative to the label root (project/file.cs), whereas the refile path contains the full path ($/department/project/file.cs).

So this means that I have to call FindFileRecursive in order to get a VaultClientFile which has a correct path? That seems doable, except in the case where a file has been deleted after the project was labeled. In that case, when I call ClientInstance.Respository.Root.FindFileRecursive I get a null back.

How do you retrieve the labeled version?

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

Post by jclausius » Mon Jan 08, 2007 4:30 pm

:oops: I mis-spoke. I don't think you need the repository's path, but the label's path.

The best bet is to take a look at the Vault Command Line source code in the Vault CLC API. Check out the VaultCmdLineClient::ProcessCommandGetLabel() method as it has the steps used in retrieving a label's file info.

HTH
Jeff Clausius
SourceGear

Post Reply