CVS is a version control system that records the history of your source files. It is freely available at http://www.cvshome.org/.

 

OptiPerl has been modified in ways to work better with CVS. A project in CVS can be linked to a project in OptiPerl, and you can easily checkout the latest version and commit new changes. OptiPerl however is not a GUI for CVS; it cannot help with uncommon tasks of CVS like first importing a project or administrative tasks. But for more common tasks, in day to day programming, it can help save a lot of time.

 

When you first install OptiPerl, the CVS menu is under menu Tools/User Tools/CVS. Beneath we will explain however how to implement those commands from scratch, for better understanding. Also most configurations of CVS might need some changes in the tools parameters.

 

icon_arrow Linking a project in OptiPerl to a CVS project

 

  • Add in Data0 of OptiPerl's project options the repository of CVS, for example:

 

c:\cvsroot

 

or for remote servers something like:

 

:pserver:faun.example.org:/usr/local/cvsroot

 

You can skip this if you use only one repository and it is set in the CVSROOT environment variable. Also remove all references to "-d %data0" below.

 

  • Add in Data1 the module name, for example:

 

mysite/cgi-bin

 

(notice the use of the slash (/))

 

  • Add in Data2 the folder in which you will checkout. You must setup the starting directory for checkout correctly, since especially for scripts being tested with web servers, it is not easy to change their location each time (unless of course this does not matter for you).

 

If your project's files are in c:\webs\mysite\cgi-bin and you first imported from this folder using

 

cvs import mysite/cgi-bin vendor start

 

then enter here c:\webs

 

  • Add in Data3 the top level folder of the project. For example

 

c:\webs\mysite\cgi-bin

 

icon_arrow Logging in (for remote server)

 

Create a custom tool:

 

Name: CVS Login

Program: CVS.exe

Parameters: -d %data0% login

 

icon_idea For this tool and all the next, from the "Build parameters" of "configure tools" (right click in the grid), select "Leave window open". This will keep the console window open after running, so you can verify the results.

 

 

icon_arrow Checkout

 

Create a custom tool:

 

Name: CVS Checkout

Program: CVS.exe

Parameters: -d %data0% checkout -P %data1%

Starting path: %data2%

 

We had setup %data2% with the folder above the top-level folder of the project. Remember that the top-level directory created is always added to the directory where checkout is invoked.

 

icon_exclaim Note that this tool, and some of the next, requires you also enter the starting path. You can enter this value from the "Build parameters" dialog. The tags in the starting path are also evaluated by OptiPerl and replaced.

 

 

icon_arrow Updating

 

To bring the work tree in sync with repository (if you are part of a developing group) create a custom tool:

 

Name: CVS Update

Program: CVS.exe

Parameters: -d %data0% update -d -C

Starting path: %data3%

 

 

icon_arrow Commit

 

To commit changes, enter the following:

 

Name: CVS Commit

Program: CVS.exe

Parameters: -d %data0% commit -m"%querybox%"

Starting path: %data3%

 

The %querybox% will bring up an input box before running, so you can enter a string.

 

icon_exclaim Make sure you save changes in the editor before committing.

 

 

icon_arrow Viewing changes with diff (the fun part)

 

The following will compare the active file in the editor, and display changes in a new page of the editor:

 

Name: CVS Diff

Program: CVS.exe

Parameters: -d %data0% diff -c %PathSN%%n<diff - %fileNoExt%>%%getfile%

Starting path: %folder%

 

%PathSN% is the full short path to the file, without spaces.

 

The parameters %n<diff - %filenoext%>% %getfile% are "magic" which are deleted when running. They command optiperl:

 

%n<diff - %fileNoExt%>%

To open a new file in the editor named "diff - filename" (without the extension)

 

%getfile%

To get all output and insert in the editor.

 

icon_idea Especially with diff, but with other of CVS commands too, you may want to enter each time you run more parameters. Use the %querybox% for this.

 

icon_arrow Jumping to the line referenced from diff output (the fun part II)

 

If you try the above, on a new tab you will get the results of diff. We will explain here, how to jump to the line of the changed file, depending on where you have the cursor on the diff output file (made with the -c parameter). For example, if you have the cursor on:

 

....................

diff -c -r1.2 vegetables3.pl

*** vegetables3.pl        30 Jul 2002 17:32:51 -0000        1.2

--- vegetables3.pl        30 Jul 2002 17:48:52 -0000

 

.................

 

--- 1,6 ----                        

#!perl                                        <- Cursor on this line

+    $a=1;

 

 

You will go to the file vegetables3.pl on line 1. To do this, create a tool:

 

Name: CVS Goto line from diff

Program: c:\tools\CVSGotoline.pl  (wherever you save this file)

Parameters: %SENDFILE%%GETLINE%%SENDLINE%

 

 

Now create CVSGotoline.pl with the following code:

 

# Get the active line. The format used to send

# is linenumber<tab>activefilename

# linenumber is 0 indexed.

($linenum,$activefilename) = split(/\t/,<STDIN>);

 

# Get input from OptiPerl.

@lines = <STDIN>;

 

# the first line of the output should contain

# the file used for diff

die unless ($lines[0]=~/Index: (\S+)/);

$difffile = $1;

 

# Now starting from the the active line in the

# editor and going backwards, find something

# like "--- 10,30"

while ($linenum >= 0) {

if ($lines[$linenum]=~/^--- (\d+),(\d+)/)

{

# print now the line we want to go to and the

# file we want to go to:

print $1 - 1 . "\t$difffile";

exit;

}

$linenum--;

}

 

Notice the use of %SENDLINE% in the parameters. This instructs OptiPerl to send to the script as the first line something like:

 

14<tab>filename

 

With 14 being the line under the cursor when called and filename the full path to the active filename.

 

With %GETLINE% OptiPerl expects as the first line of output the same format, so it will navigate there.

 

 

Other issues

 

icon_idea For the implementations above, we have used Data0..Data3 of the project options. You may of course use other numbers, just make sure that the tools parameters correspond afterwards. Also keep corresponding place holders between all projects that use CVS, so the tools can be commonly used between projects.

 

icon_exclaim When adding custom commands, the default is to add them in the tools menu. If you add many tools, this will make the menu huge! Don't allow this to happen, create a menu called CVS and put your tools there. You can also assign shortcuts and icons to your tools.

 

icon_lol You got the feel of it! If you use CVS a lot, probably you have personal preferences on how to use it's commands, and probably you can set them up using OptiPerl's tools. If you are administrator of a multi-user version of OptiPerl, you can also copy the Tools.csv in OptiPerl's application data folder to each user, or append it's contents, changing the username for each if needed.

 

CVS integration is not hard-coded into OptiPerl, instead it can be built using OptiPerl's custom tools. This is because people who use CVS are probably more mature programmers that have strong personal preferences on using it. Matching them would be impossible, so the framework is given to let programmers use CVS exactly as they want.

 

 

Top  Previous  Next