How to access of prior version of a file?

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

Moderator: SourceGear

Post Reply
stanyork
Posts: 21
Joined: Thu Apr 30, 2009 5:09 pm

How to access of prior version of a file?

Post by stanyork » Thu Apr 30, 2009 5:19 pm

We need to be able to access a prior version of a file based on its version number. In the VSS API, we had the current VSSItem and given the version number we could get any prior version using code like this:

Code: Select all

SourceSafeTypeLib.VSSItem theFile 
int theVersionNumber

return theFile.Version( theVersionNumber )  // return type is SourceSafeTypeLib.VSSItem 
The returned VSSITEM could then be used to GET that version or perform other operations.

Any hint as to what the equivalent would be is greatly appreciated!

(Yes, our VSS API code has lots of error handling for all the senarios where the above code fails because the history/version entry is a branch or a whatever that isn't really real.... but that isn't relevant right now)

shannon

Re: How to access of prior version of a file?

Post by shannon » Thu Apr 30, 2009 6:01 pm

What version of the api are you working with?

stanyork
Posts: 21
Joined: Thu Apr 30, 2009 5:09 pm

Re: How to access of prior version of a file?

Post by stanyork » Fri May 01, 2009 6:22 am

VaultClientIntegrationLib.dll is 4.1.4.18402

shannon

Re: How to access of prior version of a file?

Post by shannon » Fri May 01, 2009 7:21 am

Take a look at GetOperations.ProcessCommandGetVersion(string objectPath, int version, GetOptions getOptions) which uses a working folder
or GetOperations.ProcessCommandGetVersionToLocationOutsideWorkingFolder(string objectPath, int version, GetOptions getOptions, string destPath) to get to a non-working folder.

stanyork
Posts: 21
Joined: Thu Apr 30, 2009 5:09 pm

Re: How to access of prior version of a file?

Post by stanyork » Fri May 01, 2009 7:35 am

I agree, the suggested methods will GET the file out of source control....but how do I obtain the object in memory that gives me information about the particular version (date, who, etc).

I am looking for the equivalent of VSSITEM for a historical version.

So, your VaultClientFile has
  • GetFileProperties method that returns a VaultFileProperties, and VaultFileProperties has a .LatestVersion property
  • Version property that returns a version number -- implying that the VaultClientFile.Version may not equal VaultFileProperties.LatestVersion
So I may be asking: how do I get a VaultClientFile object for some arbitrary prior version of a file.

shannon

Re: How to access of prior version of a file?

Post by shannon » Fri May 01, 2009 7:51 am

Sorry, I misunderstood what you wanted. Ok, I talked with a coworker and I don't think we have an equivalent of this VSSITEM. You'll probably need to perform a history query and look through the results to get the information you're looking for.

ServerOperations.ProcessCommandHistory might be a place to start.

Post Reply