home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Editor / DVD!FX17.LHA / FrexxEd / fpl / RCSControl.FPL < prev    next >
Encoding:
Text File  |  1995-02-26  |  5.6 KB  |  154 lines

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