home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / TextEditors&Viewers / Texteditors / FFRED10.LHA / fpl / RCSControl.FPL < prev    next >
Encoding:
Text File  |  1994-10-26  |  6.9 KB  |  190 lines

  1. /*****************************************************************************
  2. ***************************************************************** Check Out **
  3. *****************************************************************************/
  4. void export RCSCheckOut()
  5. {
  6.    int oldLine = ReadInfo("line");         /* Grab cursor position */
  7.    int oldCol = ReadInfo("column");
  8.    Status(0,"Checking out...");             /* Tell user we're working */
  9.    System(joinstr("bin:co -l \"", ReadInfo("full_file_name"), "\""));
  10.    Load(ReadInfo("full_file_name"));     /* Reload to get protection bit */
  11.                                             /* and ensure correct contents */
  12.    GotoLine(oldLine, oldCol-1);             /* Reposition cursor */
  13. }
  14.  
  15.  
  16. /*****************************************************************************
  17. ****************************************************** Setup comment buffer **
  18. *****************************************************************************/
  19. void export EnterRCSComment(int ReLock)
  20. {
  21.    int        RevisionID = New();             /* Make comment buffer */
  22.    int        OrgBuffer = CurrentBuffer(RevisionID);
  23.  
  24.    Rename("*RCS Comment*");                 /* rename it */
  25.    SetInfo(RevisionID, "_IsRCSBuffer", 1); /* and fill parent data */
  26.    SetInfo(RevisionID, "_RCSParentBuffer", OrgBuffer);
  27.    SetInfo(RevisionID, "_RCSReLock", ReLock);
  28.    ReturnStatus("Press C-c C-c when comment is complete!");
  29. }
  30.  
  31.  
  32. /*****************************************************************************
  33. ****************************************************************** Check In **
  34. *****************************************************************************/
  35. void export RCSCheckIn()
  36. {
  37.    int        ParentID = ReadInfo("_RCSParentBuffer");
  38.    int export thisID = CurrentBuffer(ParentID);
  39.    string    ParentName, CommentName;
  40.  
  41.    Save();                                 /* Save parent buffer */
  42.    CurrentBuffer(thisID);                 /* and get back to comment buffer */
  43.  
  44.    ParentName = ReadInfo("full_file_name", ParentID); /* get parent name */
  45.  
  46.    CommentName = joinstr("T:RCSComment", itoa(thisID)); /* build temp name */
  47.    Rename(CommentName);
  48.    Save();                                 /* and save comment buffer */
  49.    
  50.    Status(0,"Checking in...");             /* Tell user we're working... */
  51.  
  52.  
  53.    System(joinstr("bin:ci \"", ParentName, "\" < ", CommentName)); /* Check In */
  54.  
  55.    CurrentBuffer(ParentID);                 /* return control to parent */
  56.  
  57.    ParentID = ReadInfo("_RCSReLock",thisID); /* CAREFUL! New contents! */
  58.  
  59.    System(joinstr("delete ", CommentName)); /* Delete comment file */
  60.    Clean("Kill(thisID);");                    /* and the comment buffer */
  61.  
  62.  
  63.    if (ParentID)                         /* Check ReLock status!!!!!! (c ^) */
  64.    {                                     /* If ReLock, lock file again */
  65.       RCSCheckOut();
  66.    }
  67.    else
  68.    {
  69.       System(joinstr("bin:co \"", ParentName, "\"")); /* Check Out (no lock) */
  70.       SetInfo(-1,"__wp", 1);          /* and write protect parent buffer */
  71.    }
  72.  
  73. }
  74.  
  75.  
  76. /*****************************************************************************
  77. *************************************************************** ChangeWFlag **
  78. *****************************************************************************/
  79. void export ChangeWFlag(int ReLock)
  80. {
  81.    int        isRCS;
  82.    isRCS = Check(joinstr(ReadInfo("full_file_name"), ",v"),"");
  83.    isRCS = isRCS || Check(joinstr(ReadInfo("file_path"), "RCS/", ReadInfo("file_name")),"");
  84.  
  85.    if (ReadInfo("__wp"))
  86.    {
  87.       if (isRCS)
  88.       {
  89.          RCSCheckOut();
  90.       }
  91.       else
  92.       {
  93.          SetInfo(-1,"__wp", 0);          /* if not an RCS file, just alter */
  94.       }                                      /* the write protection flag. */
  95.    }        /* Note that the protection bit is _not_ altered! */
  96.    else
  97.    {
  98.       if (isRCS)
  99.       {
  100.          EnterRCSComment(ReLock);
  101.       }
  102.       else
  103.       {
  104.          if (Request("Should I put the file under RCS control?",
  105.                     "RCS request","Yes|No")) 
  106.          {
  107.             if (!Check(joinstr(ReadInfo("file_path"), "RCS")))
  108.             {                             /* Ask to create RCS dir */
  109.                if (Request("Do you want me to create an RCS directory?",
  110.                               "RCS request","Yes|No"))
  111.                {                         /* Creat RCS dir */
  112.                   System(joinstr("makedir ",ReadInfo("file_path"), "RCS"));
  113.                }
  114.             }
  115.             Request("This first comment will be used for file description.\nDo not enter revision specific information!",
  116.                     "RCS info","Um, OK!");
  117.             EnterRCSComment(ReLock);
  118.          }
  119.          else
  120.          {
  121.             SetInfo(-1,"__wp", 1);        /* if not an RCS file, just alter */
  122.          }                                 /* the write protection flag. */
  123.  
  124.       }
  125.    }
  126. }
  127.  
  128.  
  129. /*****************************************************************************
  130. ************************************************************** Make history **
  131. *****************************************************************************/
  132. export void RCSMakeHistory()
  133. {
  134.    string    file = PromptFile("","","",""); /* get file name */
  135.    if (strlen(file))
  136.    {
  137.       string    history = joinstr(file,".history");
  138.       if (Check(history))
  139.       {
  140.          switch(Request("History file already exist!","RCS request","Overwrite!|New name|Cancel"))
  141.          {
  142.             case 2:                         /* Ask new file name */
  143.                history = PromptFile(history,"Select output file...","","s");
  144.                break;
  145.             case 1:                         /* Cancel operation by setting empty name */
  146.                history="";
  147.                break;
  148.          }
  149.       }
  150.       if (strlen(history))                 /* Only continue if name defined */
  151.       {
  152.          int prevVisible = Visible(0);     /* Disable screen update */
  153.          int histID = New();             /* Get new buffer */
  154.          System(joinstr("bin:rlog \"", file, "\" >",history)); /* Get history created */
  155.          CurrentBuffer(histID);
  156.          Load(history);                     /* load history */
  157.          DeleteLine(11);                 /* and make history a bit more readable: */
  158.          SearchSet("=of+","date:");         /* Erase difference info  */
  159.          while (!Search("date:"))
  160.          {
  161.             Search(";");
  162.             DeleteEol();
  163.          }
  164.          GotoLine(1,0);
  165.          Save("");                         /* update file to disk */
  166.          Visible(prevVisible);             /* and update screen */
  167.          RedrawScreen(0);
  168.       }
  169.    }
  170. }
  171.  
  172.  
  173. /*****************************************************************************
  174. ************************************************************** Key bindings **
  175. *****************************************************************************/
  176.  
  177. AssignKey("ChangeWFlag(0);","control x control q","");
  178. AssignKey("ChangeWFlag(1);","control x control Q","");
  179. AssignKey("RCSCheckIn();","control c control c", "_IsRCSBuffer");
  180. AssignKey("Kill();","control g", "_IsRCSBuffer");
  181.  
  182.  
  183. /*****************************************************************************
  184. ********************************************************** Hidden variables **
  185. *****************************************************************************/
  186.  
  187. ConstructInfo("_IsRCSBuffer","","", "LBH", "",0,1,0);
  188. ConstructInfo("_RCSReLock","","", "LBH", "",0,1,0);
  189. ConstructInfo("_RCSParentBuffer","","", "LIH", "",0,0x7fffffff,0);
  190.