Commit and Get not working...

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

Moderator: SourceGear

Post Reply
ngallegos
Posts: 3
Joined: Wed Nov 26, 2008 10:52 am

Commit and Get not working...

Post by ngallegos » Wed Nov 26, 2008 1:35 pm

Hello,
I've tried and tried, using the examples and solutions to this problem in other topics, but cannot get the API to check in a modified file. This is what I am currently trying which is almost directly from an example on finding files, checking them out, modifying them, and checking them back in: http://weblogs.asp.net/jeremy_sheeley/a ... 97021.aspx

Here is what I'm doing in C#:

Code: Select all

vaultClientInstance.CheckOut(vclientfile, VaultCheckOutType.Exclusive,"no comment");
vaultClientInstance.Get(vclientfile, true, MakeWritableType.MakeAllFilesWritable, SetFileTimeType.Current, MergeType.OverwriteWorkingCopy, null);
// Modify the file
vaultClientInstance.Commit();
Previously, I did not do the Get(...) because I didn't know I needed to and would end up with the commit failing and the files in question remaining checked out with an edited status. Now, however the Get(...) throws a GetLatestVersionFailedException. It doesn't tell me why this fails, and I have no insights myself. I am sure I'm connected and logged into vault because I can check file shared paths, find files, get the repository tree and refresh it, etc... I am also pretty sure that a working folder is set because in calling vaultClientInstance.Init(), I give it a working folder. Additionally, I tried setting a working folder specific to the file I want to check in every time I try a Get(...) but to no avail.

I have also tried to specifically create a ChangeSetItemColl object and put into it ChangeSetItem_Modified objects and then call the Commit() method on this:

Code: Select all

myCheckinChangeSetCollection.Add(new ChangeSetItem_Modified(new VaultDateTime(DateTime.Now.Ticks), 
                    "Automatically checked in", 
                    "", 
                    vclientFile.ID, 
                    vclientFile.ObjVerID, 
                    workingFolderPath, 
                    vclientFile.FullName, 
                    true, 
                    (int)VaultEOL.None));

vaultClientInstance.Commit(myCheckinChangeSetCollection, false, false);
Doing this for a ChangeSetItem_AddFile works just fine but when trying to check something back in, I'm always left with a failed commit and the files being left checked out. Any ideas as to why this is happening and how I can get a checkin/commit to work?

I'm using :
Vault client version 4.1.3.18336
Vault server version 4.1.3.18336

Thanks in advance.

-Nick

shannon

Re: Commit and Get not working...

Post by shannon » Wed Nov 26, 2008 2:40 pm

Do you have a stack trace for the GetLatestVersionFailedException?

Also, it may be easier to use ServerOperations than working directly with ClientInstance....there are examples here: http://support.sourcegear.com/viewtopic.php?f=31&t=8020

ngallegos
Posts: 3
Joined: Wed Nov 26, 2008 10:52 am

Re: Commit and Get not working...

Post by ngallegos » Wed Nov 26, 2008 3:05 pm

Here is the stack trace:

Code: Select all

   at VaultClientOperationsLib.ClientInstance.ProcessGetFileRequests(GetFileInfo[] infos, MakeWritableType makeWritable, SetFileTimeType setFileTime, MergeType merge, Boolean updateHiddenFilesOnly, String ancestorFullPath, Boolean flat, String ancestorDiskPath, OverwritePrompt PromptData, Boolean isLabelGet, String currentPathToLabelItem, Int64 labelID, Boolean isRetry, Boolean isGetByDisplayVersion)
   at VaultClientOperationsLib.ClientInstance.Get(VaultClientFile[] files, Boolean forceLatest, MakeWritableType makeWritable, SetFileTimeType setFileTime, MergeType merge, OverwritePrompt PromptData)
   at VaultClientOperationsLib.ClientInstance.Get(VaultClientFile file, Boolean forceLatest, MakeWritableType makeWritable, SetFileTimeType setFileTime, MergeType merge, OverwritePrompt PromptData)
   at CodeInfoGenerator.CodeInfoGenerator.AddFileToChangeSetCollection(String vcf) in C:\Working\FlashCT\FlashCT Utilities\CodeInfoGenerator\Source\CodeInfoGenerator.cs:line 434
   at CodeInfoGenerator.CodeInfoGenerator.Generate_CSharp_ProjectCodeInfo(String[] projectPaths) in C:\Working\FlashCT\FlashCT Utilities\CodeInfoGenerator\Source\CodeInfoGenerator.cs:line 252
   at CodeInfoGenerator.Form1.generateDocsButton_Click(Object sender, EventArgs e) in C:\Working\FlashCT\FlashCT Utilities\CodeInfoGenerator\Source\Form1.cs:line 180
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at CodeInfoGenerator.Program.Main() in C:\Working\FlashCT\FlashCT Utilities\CodeInfoGenerator\Source\Program.cs:line 18
   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
I had actually already looked at those examples and tried the ServerOperations to no avail. Thinking back, I actually think that I got the same exception... I didn't try very thoroughly though because I already have a lot of other code that deals directly with the ClientInstance, and didn't want to re-write everything using ServerOperations. When I did try, I think I probably had 2 connections to vault because I logged in with the existing ClientInstance that I'd been using, and logged in using Server Operations, so that may have affected my results. But this is what I did alongside the already logged in ClientInstance:

Code: Select all

ServerOperations.client.LoginOptions.User = _username;
ServerOperations.client.LoginOptions.Password = _password;
ServerOperations.client.LoginOptions.URL = _hostname;
ServerOperations.client.LoginOptions.Repository = _repository;
ServerOperations.Login();

...
GetOptions go = new GetOptions();
go.MakeWritable = MakeWritableType.MakeAllFilesWritable;
go.Merge = MergeType.OverwriteWorkingCopy;
go.OverrideEOL = VaultEOL.None;
go.PerformDeletions = PerformDeletionsType.DoNotRemoveWorkingCopy;
go.Recursive = true;
go.SetFileTime = SetFileTimeType.Current;
ServerOperations.ProcessCommandCheckout(new string[] { vPath }, true, true, go);

// Modify the file

ServerOperations.ProcessCommandListChangeSet(new string { vPath });
ServerOperations.ProcessCommandCommit(new string[] { vPath }, UnchangedHandler.UndoCheckout, false, LocalCopyType.Leave, false);


shannon

Re: Commit and Get not working...

Post by shannon » Wed Nov 26, 2008 3:11 pm

I'm pretty sure you don't have a working folder set. The only path you can set in ClientInstance.Init is the localStoreBasePath which isn't a working folder.

If you already have code using ClientInstance, then don't use ServerOperations. However, you can use the methods in ServerOperations as code examples.

ngallegos
Posts: 3
Joined: Wed Nov 26, 2008 10:52 am

Re: Commit and Get not working...

Post by ngallegos » Wed Nov 26, 2008 3:37 pm

Success!

When I had tried to specifically set the working folder before, I hadn't noticed that there was an overload that would let me force all subfolders to be inherited. Once I used that, everything worked great. Thank you!

shannon

Re: Commit and Get not working...

Post by shannon » Mon Dec 01, 2008 8:06 am

Great, glad it's working now.

Post Reply