How to get just a changeset

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

Moderator: SourceGear

Posts: 8
Joined: Mon Nov 23, 2015 4:05 am
PostPosted: Fri Nov 27, 2015 1:40 pm
robe070 wrote:I don't actually need to find the file. I know its there at Version 1 because the history told me. I just need to be able to construct a VaultClientFile object for this version of the file. Then I would expect it to be able to return me the actual file from the Server. Its highly unlikely the file is in the cache, because its a very old version of the tree. I have to get it from the server.

I've got all the txn details from the history. Can that be used to construct a VaultClientFile? There isn't a constructor that can do it that I can see. And the elements I think I need to set are read-only.

Those APIs you listed. How do I specify to search for a Version of a File? They all seem to work on the latest view of the repository. This is the critical thing. FindFileRecursive will not find the file. But if I find something existing and set the Version correctly it will retrieve it as the contents of that folder. But I actually only know the verson at $ and the version of the file. I do not know the version of the parent folders so I can't use them.

What if the folder has also been removed in the latest view?

If I can just construct a VaultClientFile object for this file.

First here is what might be an easy way, but I haven't tried it. You can get the repository as of a certain txid and find the VaultClientFile from there:

Code: Select all
var rep = ServerOperations.client.ClientInstance.GetRepositoryAt(txid);
var clientFile = rep.Root.FindFileRecursive(id);

I'm writing something to efficiently pull changes and using the flat folder (where files are '<ID>.<VERSION>' and going through versions of a certain current vault folder. So I can get the current folder and the branch structure of that folder as of a certain version, then you can create a VaultClientFolder as of that version:

Code: Select all
VaultClientFolder vcFolder = RepositoryUtil.FindVaultTreeObjectAtReposOrLocalPath(vaultPath) as VaultClientFolder;
VaultFolderDelta delta = ServerOperations.ProcessCommandGetBranchStructure(repId, vaultPath, vcFolder.ID, version, false);
vcFolder = new VaultClientFolder(delta, vcFolder.Parent);

vaultPath is as of the current version of the repository, so you need to know a current folder that once contained the file. Say your file was "$/Test/Sub/MyFile.txt" in txid 1, but the MyFile.txt was deleted in txid 2 and the Sub directory was moved to '$/NewFolder/Sub' at txid 3. You can either use '$/NewFolder/Sub' as the path or '$/Test'. You cannot use '$/NewFolder' because when you look at the history of 'NewFolder', it never contained the file 'MyFile.txt'.

Posts: 8418
Joined: Wed Jun 21, 2006 8:24 pm
Location: SourceGear
PostPosted: Tue Dec 01, 2015 9:46 am
Thanks for the additional information.

At this point we have a feature in the client called Create Folder Changes Archive, which will get the files that changed since a certain date. That might help here.
Beth Kieler
SourceGear Technical Support

Return to Questions (API)

Who is online

Users browsing this forum: No registered users and 3 guests