# !/bin/csh -f
#>
#> PACT-SCS - define the Source Control System being used
#>
# Modification History:
#   03-21-94 Jan Moura, LLNL:  Added cvs command option control CvsOpt.
#                              Added SCSVersion and SCSRelease.
#   07-07-94 Jan Moura, LLNL:  Added cvs history command
####################
# Source Version: 2.0
# Software Release #92-0043
#
# include "cpyright.h"
#

set SCSName = CVS
set SCSVersion = "2.0"
set SCSRelease = "#92-0043"

#
# new CVS variables
#
set SCSRoot = CVSROOT
set ADM     = CVS

# be sure to define the CvsOpt if undefined by this time
if (!($?CvsOpt)) then
   set CvsOpt = ""
endif

if ($CvsOpt != "") then
   echo "Using new  CVS options: "  $CvsOpt
endif

set RemoteHost = ""

if ($?CVSROOT) then
   set RemoteMethod = `expr "$CVSROOT" : ':\(.*\):.*@.*:.*'`
   set RemoteUser   = `expr "$CVSROOT" : ':.*:\(.*\)@.*:.*'`
   set RemoteHost   = `expr "$CVSROOT" : '.*@\(.*\):.*'`
   set RemoteRepo   = `expr "$CVSROOT" : '.*@.*:\(.*\)'`
endif

if ("$RemoteHost" == "") then
   if ($?CVSROOT) then
      if (`expr "$CVSROOT" : '.*\(:\).*'` == "") then
         set SCSLock = $CVSROOT/commit.lock
      else
         set SCSLock = commit.lock
      endif
   else
      set SCSLock = commit.lock
   endif

   alias Unlock     "rm -f $SCSLock"
   alias Makelock   "touch $SCSLock ; chmod 660 $SCSLock"
   alias CatLock    "cat $SCSLock"
   alias KillZombie ""

   if (-e $SCSLock) then
      set ExistLock = TRUE
   else
      set ExistLock = FALSE
   endif

else

   setenv CVS_RSH  ssh
   setenv RCP      scp

   set Host    = `uname -n`
   set WhoIAm  = $USER
   set Date    = `/bin/date '+%y_%m_%d_%H_%M_%S'`
   set Message = (\'<$WhoIAm|$Date|Remote $Host> $argv\')

   set Stage        = "$UserDir/stage"
   set SCSLock      = "$Stage/commit.lock"
   set RemLock      = "$RemoteRepo/commit.lock"

   alias Unlock     "$CVS_RSH $RemoteHost rm -f $RemLock ; rm -f $SCSLock"
   alias Makelock   'touch' $SCSLock '; chmod 660' $SCSLock '; echo' $Message '>>' $SCSLock ';' $RCP $SCSLock $RemoteHost':'$RemoteRepo
   alias CatLock    "$CVS_RSH $RemoteHost cat $RemLock"
   alias KillZombie "$CVS_RSH $RemoteHost sign -9 cvs '>>&' /dev/null"

   if (!($?DoingConfig)) then
      set LockTest = `$CVS_RSH $RemoteHost ls $RemoteRepo`
      set ExistLock = FALSE
      foreach i ($LockTest)
         set entry = $i:h
         if ("$entry" == "commit.lock") then
            set ExistLock = TRUE
         endif
      end
   endif

   if (!(-d $Stage)) then
      mkdir $Stage
   endif

endif

#
# Source Control Systems operations
#
set Commit   = "cvs $CvsOpt  commit"
set History  = "cvs $CvsOpt  history"
set Tag      = "cvs $CvsOpt  rtag"
set Update   = "cvs $CvsOpt  update"
set CheckOut = "cvs $CvsOpt  $SCSRepository co $SRCDate"

