1

Within my program I have a method that checks out a file but I need to be able to check it back in again,

 ClearCase.ClearTool CCTool = new ClearCase.ClearTool();
    ClearCase.Application m_CC = new ClearCase.Application();
    ClearCase.CCCheckedOutFile file = null;

            void GetVersions(string sourcefile, string destinationPath)
            {
                ClearCase.CCElement element = m_CC.get_Element(sourcefile);

                if (element != null)
                {
                    ClearCase.CCVersion latestVersion = null;
                    FileInfo fi = new FileInfo(sourcefile);

                    latestVersion = element.get_Version("\\main\\LATEST");
                    if (latestVersion != null)
                    {
                        ClearCase.CCBranch branch = latestVersion.Branch;
                        ClearCase.CCCheckedOutFile file = latestVersion.CheckOut(ClearCase.CCReservedState.ccReserved, "", false, ClearCase.CCVersionToCheckOut.ccVersion_SpecificVersion, true, false);
                        string path = file.ExtendedPath;
                    }
                }
            }

What this will do is check out the latest version and create it on your own branch, would there be a way of checking it back in so you are putting it on the main with a new version.

Thanks, Berbies

Berbies
  • 303
  • 1
  • 5
  • 17

1 Answers1

1

Once you have CCCheckoutFile objects, you can call the checkin method on them to check them in:

Function CheckIn([ Comment As String = "" ], 
                 [ EvenIfIdentical As Boolean = False ], 
                 [ FromPath As String = "" ], 
                 [ KeepState As CCKeepState = ccKeep ]) As CCVersion

If you don't have those objects, you need to get them first, like in this CCCheckedOutFileQuery for instance.

Or, for just one given file, you can determine if a file is checked-out to a particular view.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thank you sir, is there a way that I can check out the file, then change it from read only to write. The way my program works is that it checks out the item first, hopefully changes it from read only to write, then performs my activity then checks it back in with the new version. – Berbies Aug 04 '11 at 22:08
  • @Berbies: a checkout is supposed to change a file protection to write, so you shouldn't have to do anything special. – VonC Aug 05 '11 at 03:48