Checking files in
Moderator: SourceGear
-
- Posts: 4
- Joined: Sun Sep 12, 2010 8:17 pm
Checking files in
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
Thank you
Matt
Re: Checking files in
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
SourceGear Technical Support
-
- Posts: 4
- Joined: Sun Sep 12, 2010 8:17 pm
Re: Checking files in
Hi,
The files are definitely checked out. I can see them checked out in the Vault GUI Client.
The files are definitely checked out. I can see them checked out in the Vault GUI Client.
-
- Posts: 4
- Joined: Sun Sep 12, 2010 8:17 pm
Re: Checking files in
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;
}
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;
}
Re: Checking files in
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?
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
SourceGear
-
- Posts: 4
- Joined: Sun Sep 12, 2010 8:17 pm
Re: Checking files in
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
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
Re: Checking files in
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.
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
SourceGear