C # clearcase: how to edit a file, then check it and then check it with the saved changes?

I am trying to programmatically edit the verified file and then validate it and save the changes made during the verification. And then check it back with the saved changes: Edit -> CheckOut -> Save -> CheckIn

When I try to save, I have a problem that the file does not recognize itself in the folder and thinks about trying to overwrite another file.

void checkOut(string sourcefile) { ClearCase.CCElement element = m_CC.get_Element(sourcefile); if (element != null) { ClearCase.CCVersion latestVersion = null; FileInfo fi = new FileInfo(sourcefile); latestVersion = element.get_Version(); 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; } } } void checkIn(string sourcefile) { ClearCase.CCElement element = m_CC.get_Element(sourcefile); element.CheckedOutFile.CheckIn("", true, sourcefile, ClearCase.CCKeepState.ccRemove); } void excelEdit() { string fileName = Globals.ThisAddIn.Application.ActiveWorkbook.Name; //EDIT EXCEL FILE from (fileName) checkOut(fileName); Globals.ThisAddIn.Application.ActiveWorkbook.SaveAs(fileName); checkIn(fileName); } 
+4
source share
4 answers

This is not the process that you would use if you did it manually, and not as I would recommend doing it programmatically.

First you have to CHECK the file (which will make it writable on disk), CHANGE it, SAVE it, and then CHECK it back IN (which will make it read-only on disk).

You might think that in Visual Studio you start editing before you do this, but in fact Visual Studio will check the file when you start editing.

+3
source

I get the impression that ClearCase checks the files, replacing the current read-only copy with a new, writable one. This explains the behavior you see.

I would advise you to copy the file to a temporary location, change the copy, check the source file, copy the modified temporary back and check it.

+2
source

Note: you can do what you want with a snapshot view where you can:

  • change read-only attribute
  • edit (make your file "captured" in the process)
  • checkout (saving the captured version with the -use / hijack option)
  • check
  –Use / hijack

Provides instructions for using the captured file as a verified version.
If the downloaded file does not have a captured analogue, this parameter is ignored.

This process may make sense if you want to test the modification immediately without telling everyone that you are modifying the specified file: if the modification works, then you are trying to check, and then check.

But with dynamic views, this would be impossible (or it would be much more complicated).

So, if you don’t have a special reason to try the changes before the design, the official process described by Steve is preferable.

+2
source

If ClearCase is like TFS, you probably set your file as ReadOnly until you do your check ...

Therefore, your process must not be installed in a read-only file β†’ Edit β†’ Quit β†’ Save β†’ Check

0
source

All Articles