Checking files in

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

Moderator: SourceGear

Post Reply
EnergyLink
Posts: 4
Joined: Sun Sep 12, 2010 8:17 pm

Checking files in

Post by EnergyLink » Sun Sep 12, 2010 8:28 pm

Hi, I am trying to program a check in function using VaultClientIntegrationLib. I see by following the examples that you first need to get the change set collection using the InternalChangeSet_GetItems function, and then pick out the items you want to commit. I am having a problem with this though: although I have files checked out in my repository the InternalChangeSet_GetItems function returns an empty set. IsCheckedOutByMeOnThisMachine also returns false for the file that I have checked out. Neither of these functions seem to register a checked out file unless I have checked it out within the same session. Can you give me any pointers to what is going on?

Thank you
Matt

Beth
Posts: 8550
Joined: Wed Jun 21, 2006 8:24 pm
Location: SourceGear
Contact:

Re: Checking files in

Post by Beth » Mon Sep 13, 2010 10:01 am

Can you verify either with a Vault GUI client or through the Vault admin web page under the Undo Checkout function that you have the items checked out? It could be a failure in the checkout.
Beth Kieler
SourceGear Technical Support

EnergyLink
Posts: 4
Joined: Sun Sep 12, 2010 8:17 pm

Re: Checking files in

Post by EnergyLink » Tue Sep 14, 2010 3:49 pm

Hi,
The files are definitely checked out. I can see them checked out in the Vault GUI Client.

EnergyLink
Posts: 4
Joined: Sun Sep 12, 2010 8:17 pm

Re: Checking files in

Post by EnergyLink » Tue Sep 14, 2010 4:01 pm

I pared my code down to a simple test function, which tries to return a count of the current changeset. When I run this function I always get an empty set, even when items are checked out in the repository. Can you tell me what is missing in this code?

public static int DoCheck(string ServerAddress, string RepositoryName,
string Username, string Password) {

ClientConnection Client = new ClientConnection();
Client.LoginOptions.URL = "http://" + ServerAddress + "/VaultService";
Client.LoginOptions.User = Username;
Client.LoginOptions.Password = Password;
Client.LoginOptions.Repository = RepositoryName;
Client.ClientInstance = new ClientInstance();
Client.ClientInstance.Init(VaultConnection.AccessLevelType.Client);
Client.ClientInstance.Login(Client.LoginOptions.URL, Client.LoginOptions.User, Client.LoginOptions.Password);

VaultRepositoryInfo[] Repositories = null;
Client.ClientInstance.ListRepositories(ref Repositories);
foreach (VaultRepositoryInfo Repository in Repositories)
if (Repository.RepName == Client.LoginOptions.Repository) {
Client.ClientInstance.SetActiveRepositoryID(Repository.RepID, Client.LoginOptions.User, Repository.UniqueRepID, false, false);
break;
}

Client.ClientInstance.TreeCache.ChangeSetItems_Refresh(true);
ChangeSetItemColl ChangeSet = Client.ClientInstance.InternalChangeSet_GetItems(true);
return ChangeSet.Count;
}

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

Re: Checking files in

Post by jclausius » Wed Sep 15, 2010 8:56 am

Assuming the change set items modified are found in this cache, and you call :

ServerOperations.client.ClientInstance.Refresh();
ServerOperations.client.ClientInstance.UpdateKnownChanges_RefreshKnown(true);

instead of - Client.ClientInstance.TreeCache.ChangeSetItems_Refresh(true);

does that help populate the list?
Jeff Clausius
SourceGear

EnergyLink
Posts: 4
Joined: Sun Sep 12, 2010 8:17 pm

Re: Checking files in

Post by EnergyLink » Wed Sep 15, 2010 3:15 pm

Client.ClientInstance.Refresh(); does refresh the list, thank you. The other refresh calls have no effect that I can detect in this situation.

I can also get rid of my problem by replacing the two false parameters with true values in the call:

Client.ClientInstance.SetActiveRepositoryID(Repository.RepID, Client.LoginOptions.User, Repository.UniqueRepID, false, false);

This seems to enable the instance to compile a change set correctly.

Thanks again

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

Re: Checking files in

Post by jclausius » Thu Sep 16, 2010 8:04 am

Just looked up the method header:

public void SetActiveRepositoryID(int id, string username, string uniqueRepositoryID, bool doRefresh, bool updateKnownChangesAll)

When doRefresh is true, this method will issue a command to sync the client cache of the tree to the server's version. It will also get a list of any changes to the checkout list and update sharing info.

When updateKnownChangesAll is true, this method will scan the working folders for changes to files adding them to the change sets.


From the looks of things, the Vault client calls SetActiveRepositoryID with doRefresh = true in all cases. And updateKnownChangesAll is true when the uesr's settings are to operate in Check-Out, Edit, Commit (VSS) mode.


So using SetActiveRepositoryID(..., true, true); is most likely what you want to use.
Jeff Clausius
SourceGear

Post Reply