API to get past file version does not have correct timestamp
Moderator: SourceGear
API to get past file version does not have correct timestamp
Hello,
To get a specific older version of a file with the API I am doing the following:
-----------------------------------------------------------------
svFile = g_svCI.TreeCache.Repository.Root.FindFileRecursive(FullPath)
svFileClone = svFile.Clone(svFile.Parent)
svFileClone.Version = OlderVersionNumber
svFileClone.ObjVerID = GetObjVersionID(svFile, OlderVersionNumber)
g_svCI.Get(svFileClone, False, VaultClientOperationsLib.MakeWritableType.MakeAllFilesWritable, VaultClientOperationsLib.SetFileTimeType.CheckIn, VaultClientOperationsLib.MergeType.Unspecified, OP)
-----------------------------------------------------------------
Notice that when I do the Get, I specify the file timestamp as SetFileTimeType.CheckIn.
The problem is that the TXDate of my svFile object is that of the latest checkin, and this is the timestamp I get, even though I get an older version of the file.
The only way I have figured out around this is to do a history query on the file, and lookup the checkin date for the version number I am interested in, and then set the transaction date for my svFileClone object.
Is there a better or more efficient way to do this?
Thank you.
To get a specific older version of a file with the API I am doing the following:
-----------------------------------------------------------------
svFile = g_svCI.TreeCache.Repository.Root.FindFileRecursive(FullPath)
svFileClone = svFile.Clone(svFile.Parent)
svFileClone.Version = OlderVersionNumber
svFileClone.ObjVerID = GetObjVersionID(svFile, OlderVersionNumber)
g_svCI.Get(svFileClone, False, VaultClientOperationsLib.MakeWritableType.MakeAllFilesWritable, VaultClientOperationsLib.SetFileTimeType.CheckIn, VaultClientOperationsLib.MergeType.Unspecified, OP)
-----------------------------------------------------------------
Notice that when I do the Get, I specify the file timestamp as SetFileTimeType.CheckIn.
The problem is that the TXDate of my svFile object is that of the latest checkin, and this is the timestamp I get, even though I get an older version of the file.
The only way I have figured out around this is to do a history query on the file, and lookup the checkin date for the version number I am interested in, and then set the transaction date for my svFileClone object.
Is there a better or more efficient way to do this?
Thank you.
I'm using the Get method instead of GetByDisplay version because I want to make use of the cache, so the command line client code won't work for me.
My way works as long as I make the history query to get the check-in date.
Is there any faster way to lookup a check-in date for a specific version of a file?
My way works as long as I make the history query to get the check-in date.
Is there any faster way to lookup a check-in date for a specific version of a file?
I can't think of a faster way to do it. Get() wasn't really designed to get a historical version, and probably assumes the file date is the latest checkin.
I'm pretty sure that GetByDisplayVersion uses the cache. If it doesn't, it should. The GetToNonWorkingFolder functions are the ones that don't use the cache. Were you running into performance problems using GetByDisplayVersion?
I'm pretty sure that GetByDisplayVersion uses the cache. If it doesn't, it should. The GetToNonWorkingFolder functions are the ones that don't use the cache. Were you running into performance problems using GetByDisplayVersion?
I would prefer to use GetByDisplayVersion, and I tried this originally, but it didn't use the cache. Check out the support thread I created back then:
http://support.sourcegear.com/viewtopic.php?t=4675
http://support.sourcegear.com/viewtopic.php?t=4675
Ah - I see. I guess I am wrong. I'm glad to get that out of the way for the next hour or so
It looks like at some point you are saving off historical versions of the file (by ObjVerID). Is the date always available then? That way you wouldn't have to hit the server again just to get the tx date.
Another idea, although probably a dead end: Is your default user option for SetTime set to checkin date or current date? If you set it to checkin date, does that affect the Get() call?
It looks like at some point you are saving off historical versions of the file (by ObjVerID). Is the date always available then? That way you wouldn't have to hit the server again just to get the tx date.
Another idea, although probably a dead end: Is your default user option for SetTime set to checkin date or current date? If you set it to checkin date, does that affect the Get() call?
I have to query for the ObjVerID as well, so it's not like I have the date left over from a just prior action. But, maybe I can combine getting the Date and ObjVersionID which will help a bit.
As for your point #2, I'll have to look into it.
I have noticed that whenever a file is placed in the cache, it has the current date, not the check-in date, maybe this is related.
As for your point #2, I'll have to look into it.
I have noticed that whenever a file is placed in the cache, it has the current date, not the check-in date, maybe this is related.