home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************
- ***************************************************************** Check Out **
- *****************************************************************************/
- void export RCSCheckOut()
- {
- int oldLine = ReadInfo("line"); /* Grab cursor position */
- int oldCol = ReadInfo("column");
- Status(0,"Checking out..."); /* Tell user we're working */
- System(joinstr("bin:co -l \"", ReadInfo("full_file_name"), "\""));
- Load(ReadInfo("full_file_name")); /* Reload to get protection bit */
- /* and ensure correct contents */
- GotoLine(oldLine, oldCol-1); /* Reposition cursor */
- }
-
-
- /*****************************************************************************
- ****************************************************** Setup comment buffer **
- *****************************************************************************/
- void export EnterRCSComment(int ReLock)
- {
- int RevisionID = New(); /* Make comment buffer */
- int OrgBuffer = CurrentBuffer(RevisionID);
-
- Rename("*RCS Comment*"); /* rename it */
- SetInfo(RevisionID, "_IsRCSBuffer", 1); /* and fill parent data */
- SetInfo(RevisionID, "_RCSParentBuffer", OrgBuffer);
- SetInfo(RevisionID, "_RCSReLock", ReLock);
- ReturnStatus("Press C-c C-c when comment is complete!");
- }
-
-
- /*****************************************************************************
- ****************************************************************** Check In **
- *****************************************************************************/
- void export RCSCheckIn()
- {
- int ParentID = ReadInfo("_RCSParentBuffer");
- int export thisID = CurrentBuffer(ParentID);
- string ParentName, CommentName;
-
- Save(); /* Save parent buffer */
- CurrentBuffer(thisID); /* and get back to comment buffer */
-
- ParentName = ReadInfo("full_file_name", ParentID); /* get parent name */
-
- CommentName = joinstr("T:RCSComment", itoa(thisID)); /* build temp name */
- Rename(CommentName);
- Save(); /* and save comment buffer */
-
- Status(0,"Checking in..."); /* Tell user we're working... */
-
-
- System(joinstr("bin:ci \"", ParentName, "\" < ", CommentName)); /* Check In */
-
- CurrentBuffer(ParentID); /* return control to parent */
-
- ParentID = ReadInfo("_RCSReLock",thisID); /* CAREFUL! New contents! */
-
- System(joinstr("delete ", CommentName)); /* Delete comment file */
- Clean("Kill(thisID);"); /* and the comment buffer */
-
-
- if (ParentID) /* Check ReLock status!!!!!! (c ^) */
- { /* If ReLock, lock file again */
- RCSCheckOut();
- }
- else
- {
- System(joinstr("bin:co \"", ParentName, "\"")); /* Check Out (no lock) */
- SetInfo(-1,"__wp", 1); /* and write protect parent buffer */
- }
-
- }
-
-
- /*****************************************************************************
- *************************************************************** ChangeWFlag **
- *****************************************************************************/
- void export ChangeWFlag(int ReLock)
- {
- int isRCS;
- isRCS = Check(joinstr(ReadInfo("full_file_name"), ",v"),"");
- isRCS = isRCS || Check(joinstr(ReadInfo("file_path"), "RCS/", ReadInfo("file_name")),"");
-
- if (ReadInfo("__wp"))
- {
- if (isRCS)
- {
- RCSCheckOut();
- }
- else
- {
- SetInfo(-1,"__wp", 0); /* if not an RCS file, just alter */
- } /* the write protection flag. */
- } /* Note that the protection bit is _not_ altered! */
- else
- {
- if (isRCS)
- {
- EnterRCSComment(ReLock);
- }
- else
- {
- if (Request("Should I put the file under RCS control?",
- "RCS request","Yes|No"))
- {
- if (!Check(joinstr(ReadInfo("file_path"), "RCS")))
- { /* Ask to create RCS dir */
- if (Request("Do you want me to create an RCS directory?",
- "RCS request","Yes|No"))
- { /* Creat RCS dir */
- System(joinstr("makedir ",ReadInfo("file_path"), "RCS"));
- }
- }
- Request("This first comment will be used for file description.\nDo not enter revision specific information!",
- "RCS info","Um, OK!");
- EnterRCSComment(ReLock);
- }
- else
- {
- SetInfo(-1,"__wp", 1); /* if not an RCS file, just alter */
- } /* the write protection flag. */
-
- }
- }
- }
-
-
- /*****************************************************************************
- ************************************************************** Make history **
- *****************************************************************************/
- export void RCSMakeHistory()
- {
- string file = PromptFile("","","",""); /* get file name */
- if (strlen(file))
- {
- string history = joinstr(file,".history");
- if (Check(history))
- {
- switch(Request("History file already exist!","RCS request","Overwrite!|New name|Cancel"))
- {
- case 2: /* Ask new file name */
- history = PromptFile(history,"Select output file...","","s");
- break;
- case 1: /* Cancel operation by setting empty name */
- history="";
- break;
- }
- }
- if (strlen(history)) /* Only continue if name defined */
- {
- int prevVisible = Visible(0); /* Disable screen update */
- int histID = New(); /* Get new buffer */
- System(joinstr("bin:rlog \"", file, "\" >",history)); /* Get history created */
- CurrentBuffer(histID);
- Load(history); /* load history */
- DeleteLine(11); /* and make history a bit more readable: */
- SearchSet("=of+","date:"); /* Erase difference info */
- while (!Search("date:"))
- {
- Search(";");
- DeleteEol();
- }
- GotoLine(1,0);
- Save(""); /* update file to disk */
- Visible(prevVisible); /* and update screen */
- RedrawScreen(0);
- }
- }
- }
-
-
- /*****************************************************************************
- ************************************************************** Key bindings **
- *****************************************************************************/
-
- AssignKey("ChangeWFlag(0);","control x control q","");
- AssignKey("ChangeWFlag(1);","control x control Q","");
- AssignKey("RCSCheckIn();","control c control c", "_IsRCSBuffer");
- AssignKey("Kill();","control g", "_IsRCSBuffer");
-
-
- /*****************************************************************************
- ********************************************************** Hidden variables **
- *****************************************************************************/
-
- ConstructInfo("_IsRCSBuffer","","", "LBH", "",0,1,0);
- ConstructInfo("_RCSReLock","","", "LBH", "",0,1,0);
- ConstructInfo("_RCSParentBuffer","","", "LIH", "",0,0x7fffffff,0);
-