Next Previous Contents

6. Shell Scripts

The following are wrappers around the basic CVS commands. These scripts give you initial booster-push into the CVS system and are useful until you become very familiar with the CVS commands. The scripts are written for Korn shell since it is always available on all flavors of Unix, but you can translate to bash or Perl if needed. You can customize these scripts to your taste. They are basically CVS commands, but features are added to make it site specific. For example, the sedit script provides locking so that users will know someone is editing the file. Of course users can directly use the CVS commands to bypass these scripts. These scripts demonstrate how CVS can be customized to a great extent.

NOTE: The wrapper shell scripts assume the user's home directory as the root and check out the tree from CVS to build the tree underneath user's home directory.

TIP: In these shell scripts, every target filename is composed of 3 parts - Home directory, sub-directory and the filename. The full-path is $HOME/$subdir/$fname And in CVS the same directory structure is maintained (by variable $subdir) therefore in cvs there will be something like $CVSROOT/$subdir/$fname. In all scripts, these 4 variables $HOME, $CVSROOT, $subdir and $fname play an important role. For example, sample values can be like HOME=/home/aldev, subdir=myproject/src, CVSROOT=/home/cvsroot, and fname=foo.cpp

Copy these scripts to /usr/local/bin and this should be in the user's PATH environment.

  1. sget [-r revision_number] <file/directory name> To get a file or entire directory from CVS in READ ONLY mode. Click sget
  2. sedit [-r revision_number] <filename> To edit a file in order to make changes to code. This will lock the file so that nobody else can check it out. Of course you can change the script to your requirement - make no locking, warning message, or very strong locking. Click sedit
  3. scommit [-r revision_number] <filename> To commit the changes you made to filename or entire directory. Upload your changes to CVS. Click scommit
  4. supdate <filename/directory> To update a filename or to update an entire directory by getting the latest files from CVS. Click supdate
  5. sunlock [-r revision_number] <filename> To unlock the file got by sedit. Will release the lock. Click sunlock
  6. slist To see the list of files currently being edited by you. Does 'ls -l | grep | ...' command. Click slist . Note that there is also another Unix command by the name slist (list available Netware servers). You should make sure cvs script slist comes before other in your PATH environment.
  7. sinfo <filename/directory> To get the information of changes/revisions to a file. Click sinfo
  8. slog <filename> To get the history of changes/revisions to a file from CVS. Click slog
  9. sdif <filename>

    sdif -r rev1 -r rev2 <filename> To get the diff of your file with CVS. Click sdif

    NOTE: sdif has only one 'f' because there is already another Unix command called 'sdiff'

  10. sadd <filename> To add a new file to CVS repository. Click sadd
  11. sdelete <filename> To delete a file from CVS repository. Click sdelete
  12. sfreeze <revision name> <directory name> To freeze the code, that is make a release of the entire source tree. Click sfreeze

    For example :


            cd $HOME;   
            sfreeze REVISION_1_0  srctree  
    

    This will freeze code with tag REVISION_1_0 so that you can later checkout the entire tree by using the revision name.

                ******************************************************


Next Previous Contents