GetRepositoryAt not working?

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

Moderator: SourceGear

Post Reply
jgoemat
Posts: 8
Joined: Mon Nov 23, 2015 4:05 am

GetRepositoryAt not working?

Post by jgoemat » Mon Nov 30, 2015 1:05 pm

I'm trying to use Client.GetRepositoryAt(txid) to get the way the repository looked at a certain version but it isn't working for my repository. I created a new repository and moved some folders around to get 5 versions and it seemed to work fine for it:

Code: Select all

var rep = ServerOperations.client.ClientInstance.GetRepositoryAt(37365); // version 1
Console.WriteLine("Version (should be 1): {0}", rep.Root.Version);

rep = ServerOperations.client.ClientInstance.GetRepositoryAt(37369); // version 5
Console.WriteLine("Version (should be 5): {0}", rep.Root.Version);
This prints 1 and 5 correctly for the test repository. When I run it on my work repository however with transactions from the history, it always returns the last updated version of root. Here are the last version and txid for the history of '$':

Version 14944 TxId 14998
Version 15256 TxId 15310
Version 18047 TxId 18101
Version 1 TxId 18500
Version 18446 TxId 18500
Version 18447 TxId 18501
Version 22888 TxId 22942
Version 24262 TxId 24316
Version 24400 TxId 24454
Version 25131 TxId 25185
Version 25197 TxId 25251
Version 25275 TxId 25329
Version 25701 TxId 25755
Version 27279 TxId 27333

No matter what I pass as TxId, I always get back root version 27332:

Code: Select all

foreach (long txId in new long[] { 1424, 12685, 18047, 18446, 25755, 27333})
{
    var rep = ServerOperations.client.ClientInstance.GetRepositoryAt(txId);
    Console.WriteLine("TxID: {0} is Version {1}", txId, rep.Root.Version);
}

TxID: 1424 is Version 27332
TxID: 12685 is Version 27332
TxID: 18047 is Version 27332
TxID: 18446 is Version 27332
TxID: 25755 is Version 27332
TxID: 27333 is Version 27332

TxID 18500 seems to be adding a file to the root. Is that screwing it up somehow or am I doing something else wrong?

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

Re: GetRepositoryAt not working?

Post by jclausius » Mon Nov 30, 2015 3:28 pm

GetRepositoryAt() is an internal API call used by merge branches, so it is not necessarily documented on what needs to be done nor what happens if called without creating conditions of the GUI client. With that caveat, I'll see if I can help.

It appears as if the Client Instance must have a VALID repository before calling GetRepositoryAt() and that repository must own the transaction IDs you are trying to get. Have you verified that you're calling SetActiveRepositoryID() with the correct repository ID and the repository ID "owns" the transactions you are requesting?
Jeff Clausius
SourceGear

jgoemat
Posts: 8
Joined: Mon Nov 23, 2015 4:05 am

Re: GetRepositoryAt not working?

Post by jgoemat » Tue Dec 01, 2015 11:34 am

Thanks, I didn't know that needed to be called since all other operations were using the correct repository and Client.ActiveRepositoryID was the correct value, but after calling SetActiveRepositoryID() with the same value it worked.

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

Re: GetRepositoryAt not working?

Post by jclausius » Tue Dec 01, 2015 1:28 pm

I'm happy the work around helped out.
Jeff Clausius
SourceGear

Post Reply