| 
                 
                  
                |  |   
                  | CVSRCSHOWTO原始程式码版本控制系统 |   
                  
                |  |   
                  |  |   
                  |  |   
                  | 
                      
                     
                      | 作者:Al Dev (Alavoor Vasudevan) alavoor@yahoo.com 译者:Cyril Huang cyril_huang@yahoo.com
 v7.0, 20 Feb 2000 翻译日期: 5 April 2000
 
 --------------------------------------------------------------------------------
 这份文件是一份 "实际操作的说明" ,以便於能使您很快的设定 CVS/RCS 原始程式码控制系统。这份文件里也有一些将 CVS 上常用的混合命令包成可设定的 shell scripts 。这些 scripts 为 CVS 提供了一个简单的使用者介面。这份文件的内容不仅能适用於 Linux 系统也适用於其他像 Unix 的系统,例如Solaris, HPUX, AIX, SCO, Sinix, BSD, SCO 等等。
 --------------------------------------------------------------------------------
 --------------------------------------------------------------------------------
 
 1. 简介
 
 原始码控制系统是一个必须能管理那些在软体计划发展时原始码所做的改变。软体开发者需要一个完整的原始码改变历史纪录,以便於在发生问题时,能够追溯到以前稳定的版本。既然原始程式码对於任何的软体计划与开发,都是花时间与金钱中最关键的部分,所以花时间藉由使用原始码控制系统像 CVS 和 RCS 来安全的保护(safe-guarding)原始程式码是非常重要的。
 
 CVS (Concurrent Version Control System) 是一个能让很多程式开发者同时做软体开发的非常强大工具。它使用了RCS 的档案规定格式但多了一层像应用程式介面的包装,架在 RCS 的上层。
 
 (译注: RCS 是较老的版本控制,一个受 RCS 管制的档案看起来是这样子的 proj1.c,v ,CVS 沿用了一些 RCS 的规定。)
 
 CVS 能够纪录你的档案的历史纪录( 通常是原始程式码,但是其他型态的档案则不一定)。 CVS 只存了不同版本中档案的差异,而不是你所建立的每个版本中的每个档案。 CVS 也保持了一个何时,何人更改档案,为什麽更改档案等等不同观点的历史纪录。
 
 CVS 对於软体的发行和多人同时更改目前原始码的管理是非常的有帮助。他并不只是要对单一目录下的档案提供版本控制,相反的,CVS 更提供了多层有组织的目录档案的版本控制。在这个目录下除了你的原始程式码外,还包含有一个 CVS 所建立的改版控制目录与档案。
 
 这些目录与档案最後被合并在一起形成一个软体的发行。
 
 CVS 能被使用在 "C", "C++", Java, Perl, HTML 和其他档案。
 
 --------------------------------------------------------------------------------
 --------------------------------------------------------------------------------
 
 2. 那一种版本控制系统适合我? CVS 或 RCS
 
 CVS 实际上是架在 RCS 之上的, CVS 只是一堆更强大能控制一个有完整原始程式码阶层目录的工具。我们非常强烈的推荐您使用 CVS,因为您能够很有弹性的用 perl , korn bash shell 等 scripts 语言设定您自己的 CVS 系统。请看一些 korn shell scripts 的□例 Shell Scripts 。
 
 CVS 的优点
 
 CVS 是非集中式的管理,使用者从储存柜 (repository) 登出一个档案目录,并且有他自己的独立的稳定目录树。
 
 CVS 能够在发行整个计划的原始目录树中"盖上印记" ("STAMP")。
 CVS 能够使大家同时修改档案。
 CVS 能够用 shell scripts 或 perl 设定成档案锁住成单一使用或同时修改档案模式。
 CVS 的缺点
 
 需要比 RCS 多一点的管理。
 非常成熟复杂的系统,是目前应用上已有的最高技术。(感谢网友tsaipaw@mars.seed.net.tw来信指证我的错误)
 有丰富的命令还有命令选项,因此对於初学者来说有很陡的学习曲线。简单使用的 shell scripts 可在这里找到 Shell Scripts 。
 RCS 的优点
 
 RCS 非常容易设定。较少一些管理上的工作。
 RCS 用在一个每个人在一起工作的集中区域。
 RCS 对於简单的系统很有用。
 非常严谨的单一档案修改模式 - 同步与同时是不允许的。
 RCS 的缺失
 
 由於使用单一目录控制与档案锁住,不可能由很多的程式设计者做同时的开发。因为单一目录下很多人对档案的改变,会造成 make 的使用错误。
 不能对整个软体计划戳上发行(releases)的印记。
 这份文件也包含一些 shell scripts 以提供简单的命令来作登出 (check-out), 登录 (check-in), 送交(commit) 档案的动作。请看一些 shell scripts 的□例 Shell Scripts 。
 
 对於 RCS 而言,请看 Linux CD-ROM 里面的RCS mini-howto。
 --------------------------------------------------------------------------------
 cd /mnt/cdrom/Redhat/RPMS
 ls -l howto-6.0-*.noarch.rpm
 rpm -qpl howto-6* | grep -i rcs
 --------------------------------------------------------------------------------
 或者看 http://sunsite.unc.edu/LDP/HOWTO/mini/RCS-HOWTO.html
 --------------------------------------------------------------------------------
 --------------------------------------------------------------------------------
 
 3. 设定 CVS
 
 首先,你需要安装 CVS 套件,在Redhat Linux 上请用
 --------------------------------------------------------------------------------
 cd /mnt/cdrom/Redhat/RPMS
 rpm -i rcs*.rpm
 rpm -i cvs*.rpm
 To see the list of files installed do -
 rpm -qpl cvs*.rpm | less
 --------------------------------------------------------------------------------
 然後用 j, k, CTRL+f, CTRL+D, CTRL+B, CTRL+U 或上下左右键, page up/down 浏览一下结果。请用 'man less' 查看 less 的用法
 在其他的 unix 机器上,你可能需要下载 RCS CVS 的 tar.gz 档案,然後根据 README, INSTALL 档的指示来安装 CVS。请到 http://www.cyclic.com 和 http://www.loria.fr/~molli/cvs-index.html
 
 3.1 CVS 的专有环境变数
 
 下列的环境变数需要在 /etc/profile 档中设定,/etc/profile 是对所有使用者都有效的内定值设定档,如果没有设定 /etc/profile,那麽你应该加这些设定到你自己的设定档  /.bash_profile 内。
 
 --------------------------------------------------------------------------------
 export EDITOR=/bin/vi
 export CVSROOT=/home/cvsroot
 export CVSREAD=yes
 --------------------------------------------------------------------------------
 
 建造一个目录来存你原始程式码的储藏柜 (repository) 并且给予 unix group 与 user 读写的权力。 (译注:这个目录下将会有很多你将来的原始码。)
 
 --------------------------------------------------------------------------------
 export CVSROOT=/home/cvsroot
 mkdir $CVSROOT
 chmod o-rwx $CVSROOT
 chmod ug+rwx $CVSROOT
 --------------------------------------------------------------------------------
 要初始化你的 CVS ,并且从现在开始把你的原始程式码交给 CVS 管理。请做 -
 --------------------------------------------------------------------------------
 
 cvs init
 
 (译注;这个初始化的动作在於建造一个储藏柜,是一个目录$CVSROOT/。
 同时 $CVSROOT/CVSROOT 也在此时被建造,这个模组目录下面是控制你CVS的administration files,
 里面的档案做一些修改後,可以使CVS更强大好用。
 $CVSROOT 下的目录每个都是 module 的意思,一个 module 可以就是一个专案计划。
 但也可能是你把一个计划拆成很多 module ,不同 module 交给不同的 team 去发展。)
 
 # 一定要换到想要 CVS 控制的计划目录下喔
 cd $HOME/my_source_code_dir
 
 # 把整个目录纳入管理用 import 命令
 cvs import my_source_code_dir V1_0 R1_0
 
 (译注:其实是 cd 到你的project下後,cvs import 模组 vendor_tag release_tag,
 不一定要是目录名称 my_source_code_dir,vendor_tag, release_tag 只是识别用的东西,
 将来你可以用 tag 来存取你要的特定版本
 这个动作会在 $CVSROOT/ 下开个" 模组 "的目录,然後把 my_source_code_dir 整个放到 CVS 下管理,
 $HOME/my_source_code_dir 就没用了。import 的动作是把已经写好的一堆 code 摆进来,
 如果将来想新增档案xxxx.c,必须先写好xxxx.c,再用 cvs add xxxx.c)
 
 --------------------------------------------------------------------------------
 
 3.2 从 RCS 转换到 CVS 系统
 
 要转换已经存在的 RCS 档案到 CVS ,请使用下面的 script 。并确定你从你的 Linux CD-ROM 安装了 korn shell 套件 pdksh*.rpm。
 
 注意 : Korn shell /bin/ksh 在你从Linux CD-ROM 安装 pdksh*.rpm 时就会产生
 
 --------------------------------------------------------------------------------
 
 #!/bin/ksh
 
 #############################################################
 # Program to Migrate the existing source code in RCS to CVS
 #
 # Needs the korn shell RPM package  pdksh*.rpm from Linux
 # contrib cdrom
 #############################################################
 #
 # rcs2cvs - convert source tree from RCS to CVS
 #
 
 # project to convert
 PROJECT='project'
 
 # current RCS root
 RCSROOT="$HOME/rcs"
 
 if cd "$RCSROOT/$PROJECT"
 then
 cd "$RCSROOT"
 else
 echo >&2 "`basename "$0"`: can't change to RCS directory '$RCSROOT/$PROJECT'."
 exit 1
 fi
 
 # current CVS root
 CVSROOT="$HOME/cvs"
 
 # create new CVS directory for project 'project'
 if mkdir "$CVSROOT/$PROJECT"
 then
 :
 else
 echo >&2 "`basename "$0"`: can't create CVS directory '$CVSROOT/$PROJECT'."
 exit 2
 fi
 
 # create CVS project tree from RCS tree
 find "$PROJECT" -type d -name RCS -print |
 while read RCS
 do
 CVS="`dirname "$RCS"`"
 (if cd "$RCS"
 then
 #               if find . -type f -name '*,v' -print | cpio -pdmv "$CVSROOT/$CVS"
 if find . -type f -print | cpio -pdmv "$CVSROOT/$CVS"
 then
 :
 else
 echo >&2 "`basename "$0"`: can't convert RCS subdirectory '$RCSROOT/$RCS' to CVS subdirectory '$CVSROOT/$CVS'."
 fi
 else
 echo >&2 "`basename "$0"`: can't change to RCS subdirectory '$RCSROOT/$RCS'."
 fi)
 done
 
 --------------------------------------------------------------------------------
 
 现在 RCS 已经被改成 CVS 系统下的 'project'. 你可以开始用CVS命令来存取 'project' 这个模组了.
 --------------------------------------------------------------------------------
 --------------------------------------------------------------------------------
 
 4. Shell Scripts
 
 下面的 scripts 是基本 CVS 命令的集合,而且是 Korn shell 的 scripts 。你可以把他转成 perl 或者 bash。你可以自己修改成你想要的样子。这些只是运用基本 CVS 命令但有些特殊的花样加在里面。例如, sedit 这个 script 提供了档案锁住的功能使得其他人知道有某人正在修改这个档案,当然你也可以直接使用 CVS 命令而不用这些 scripts ,这些 scripts 只是在展示 CVS 是多麽的有弹性。
 
 把这些 scripts 复制到 /usr/local/bin 下,并且此目录应该在你的 PATH 环境变数中。
 
 sget [-r revision_number]  要从 CVS 获得一个唯读档案或整个唯读目录,请按 sget
 sedit [-r revision_number]  要修改一个一个程式码时,这个 scripts 会做档案锁住的动作,因此没有别人可以登出这个档案了。当然你可以改变这个 script 成你想要的功能 - 例如不锁住,只出现警告讯息,或者相反的,非常严谨的锁档案。请按 sedit
 scommit [-r revision_number]  要交出某个你修改的档案或整个目录。 把你的改变交给 CVS。请按 scommit
 supdate  要藉由从 CVS 得到最新的档案来update 一个档案或整个目录。请按 supdate
 sunlock [-r revision_number]  要把因为用 sedit 後的档案锁关掉。这会释放档案锁(Release File Lock)。请按 sunlock
 slist 要看目前正被你修改的档案列表。做 'ls -l | grep | ...' 命令,请按 slist
 sinfo  要得到一个档案的改版资讯。 请按 sinfo
 slog  要得到一个 CVS 档案改版的历史纪录,请按 slog
 sdif
 sdif -r rev1 -r rev2  要得到你的档案与 CVS 柜子里的档案不同的地方在哪里。请按 sdif
 
 注意: sdif 只有一个 'f' ,因为这里已经有一个 unix 命令叫 'sdiff'。
 
 sadd  要新增一个档案到 CVS 柜子里。请按 sadd
 sdelete  要从 CVS 柜子里清掉一个档案。请按 sdelete
 sfreeze   要冻结原始码 (freeze codes) ,这是将要发行 (release) 整个原始码目录树。请按 sfreeze
 saddtree   要新增一个目录树到 CVS 。请按 saddtree
 例如 :
 
 --------------------------------------------------------------------------------
 cd $HOME;
 sfreeze REVISION_1_0  srctree
 --------------------------------------------------------------------------------
 这将会冻结原始码,并贴上一个标签 REVISION_1_0 ,如此一来你就可以稍後用版本名字登出整个目录树。
 
 ******************************************************
 
 4.1 sget
 
 注意 : Korn shell /bin/ksh 在你从Linux CD-ROM 安装 pdksh*.rpm 时就会产生
 
 请把他存成一般文字档并改变存取权限 chmod a+rx
 --------------------------------------------------------------------------------
 
 #!/bin/ksh
 
 # CVS program sget
 # Program to check out the file from CVS read-only
 
 cmdname=`basename $0`
 
 Usage()
 {
 print "\nUsage: $cmdname [-r revision_number/symbolic_tag_name]  "
 print "The options -r are optional "
 print "For example - "
 print " $cmdname -r 1.1 foo.cpp"
 print " $cmdname foo.cpp "
 print " $cmdname some_directory "
 print "Extract by symbolic revision tag like - "
 print " $cmdname -r REVISION_1 some_directory "
 print " "
 exit
 }
 
 # Command getopt will not supported in next major release.
 # Use getopts instead.
 while getopts r: ii
 do
 case $ii in
 r) FLAG1=$ii; OARG1="$OPTARG";;
 ?) Usage; exit 2;;
 esac
 done
 shift ` expr $OPTIND - 1 `
 
 #echo FLAG1 = $FLAG1 , OARG1 = $OARG1
 
 if [ $# -lt 1 ]; then
 Usage
 fi
 
 bkextn=sget_bak
 
 hme=` echo $HOME | cut -f1 -d' '  `
 if [ "$hme" = "" ]; then
 print "\nError: \$HOME is not set!!\n"
 exit
 fi
 
 # Check if file already exists....
 if [ -f $1 ]; then
 user_perms=" "
 group_perms=" "
 other_perms=" "
 user_perms=`ls -l $1 | awk '{print $1 }' | cut -b3-3 `
 group_perms=`ls -l $1 | awk '{print $1 }' | cut -b6-6 `
 other_perms=`ls -l $1 | awk '{print $1 }' | cut -b9-9 `
 if [ "$user_perms" = "w" -o "$group_perms" = "w"  \
 -o "$other_perms" = "w" ]; then
 print "\nError: The file is writable. Aborting $cmdname ......"
 print "       You should either backup, scommit or delete the file and"
 print "       try $cmdname again\n"
 exit
 fi
 fi
 
 cur_dir=`pwd`
 #echo $cur_dir
 
 len=${#hme}
 len=$(($len + 2))
 #echo $len
 
 subdir=` echo $cur_dir | cut -b $len-2000 `
 #echo $subdir
 
 if [ "$subdir" = "" ]; then
 fdname=$1
 else
 fdname=$subdir"/"$1
 fi
 
 # Move the file
 touch $1 2>/dev/null
 \mv -f $1 $1.$bkextn
 
 # Create subshell
 (
 cd $hme
 #echo $fdname
 
 # Use -A option to clear all sticky flags
 if [ "$FLAG1" = "" ]; then
 cvs -r checkout -A $fdname
 else
 cvs -r checkout -A -$FLAG1 $OARG1 $fdname
 fi
 )
 #pwd
 
 if [ -f $1 ]; then
 print "\nREAD-ONLY copy of the file $fdname obtained."
 print "Done $cmdname"
 #print "\nTip (Usage): $cmdname  \n"
 fi
 
 --------------------------------------------------------------------------------
 
 4.2 sedit
 
 注意 : Korn shell /bin/ksh 在你从Linux CD-ROM 安装 pdksh*.rpm 时就会产生
 
 请把他存成一般文字档并改变存取权限 chmod a+rx
 
 --------------------------------------------------------------------------------
 #!/bin/ksh
 # CVS program sedit
 # Program to check out the file from CVS read/write mode with locking
 
 cmdname=`basename $0`
 
 Usage()
 {
 #       print "\nUsage: $cmdname [-r revision_number] [-F] "
 #       print "The options -r, -F are optional "
 #       print "The option -F is FORCE edit even if file is "
 #       print "locked by another developer"
 
 print "\nUsage: $cmdname [-r revision_number] "
 print "The options -r are optional "
 
 print "For example - "
 print " $cmdname -r 1.1 foo.cpp"
 print " $cmdname foo.cpp "
 #       print " $cmdname -F foo.cpp "
 print " "
 }
 
 # Command getopt will not supported in next major release.
 # Use getopts instead.
 #while getopts r:F ii
 while getopts r: ii
 do
 case $ii in
 r) FLAG1=$ii; OARG1="$OPTARG";;
 #       F) FLAG2=$ii; OARG2="$OPTARG";;
 ?) Usage; exit 2;;
 esac
 done
 shift ` expr $OPTIND - 1 `
 
 #echo FLAG1 = $FLAG1 , OARG1 = $OARG1
 
 if [ $# -lt 1 ]; then
 Usage
 exit
 fi
 
 hme=` echo $HOME | cut -f1 -d' '  `
 if [ "$hme" = "" ]; then
 print "\nError: \$HOME is not set!!\n"
 exit
 fi
 
 bkextn=sedit_bak
 
 cur_dir=`pwd`
 #echo $cur_dir
 
 len=${#hme}
 len=$(($len + 2))
 #echo $len
 
 subdir=` echo $cur_dir | cut -b $len-2000 `
 #echo $subdir
 
 if [ "$subdir" = "" ]; then
 fdname=$1
 else
 fdname=$subdir"/"$1
 fi
 
 # If file is already checked out by another developer....
 cvs_root=` echo $CVSROOT | cut -f1 -d' '  `
 if [ "$cvs_root" = "" ]; then
 print "\nError: \$CVSROOT is not set!!\n"
 exit
 fi
 cldir=$CVSROOT/$subdir/Locks
 mkdir $cldir 2>/dev/null
 rcsfile=$CVSROOT/$subdir/$1,v
 #echo $rcsfile
 
 if [ ! -e $rcsfile ]; then
 print "\nError: File $1 does not exist in CVS repository!!\n"
 exit
 fi
 
 # Get the tip revision number of the file....
 # Use tmpfile as the arg cannot be set inside the sub-shell
 tmpfile=$hme/sedit-lock.tmp
 \rm -f $tmpfile 2>/dev/null
 if [ "$FLAG1" = "" ]; then
 (
 cd $hme
 cvs log $fdname | head -6 | grep head: | awk '{print $2}' > $tmpfile
 )
 OARG1=`cat $tmpfile`
 \rm -f $tmpfile 2>/dev/null
 fi
 
 lockfile=$cldir/$1-$OARG1
 #if [ -e $lockfile -a "$FLAG2" = "" ]; then
 if [ -e $lockfile ]; then
 print "\nError: File $1 Revision $OARG1 already locked by another developer !!"
 aa=` ls -l $lockfile | awk '{print "Locking developers unix login name is = " $3}' `
 print $aa
 print "That developer should do scommit OR sunlock to release the lock"
 print " "
 #       print "You can also use -F option to force edit the file even if"
 #       print "the file is locked by another developer. But you must talk to"
 #       print "other developer to work concurrently on this file."
 #       print "For example - this option is useful if you work on a seperate" 
                          #       print "C++ function in the file which does not interfere with other"
 #       print "developer."
 #       print " "
 exit
 fi
 
 # Get read-only copy now....
 if [ ! -e $1 ]; then
 (
 cd $hme
 cvs -r checkout $fdname 1>/dev/null
 )
 fi
 
 # Check if file already exists....
 if [ -f $1 ]; then
 user_perms=" "
 group_perms=" "
 other_perms=" "
 user_perms=`ls -l $1 | awk '{print $1 }' | cut -b3-3 `
 group_perms=`ls -l $1 | awk '{print $1 }' | cut -b6-6 `
 other_perms=`ls -l $1 | awk '{print $1 }' | cut -b9-9 `
 if [ "$user_perms" = "w" -o "$group_perms" = "w"  \
 -o "$other_perms" = "w" ]; then
 print "\nError: The file is writable. Aborting $cmdname ......"
 print "       You must backup, scommit or delete file and"
 print "       try $cmdname again\n"
 exit
 fi
 #print "\nNote: The file $1 is read-only."
 #print "Hence I am moving it to $1.$bkextn ....\n"
 \mv -f $1 $1.$bkextn
 chmod 444 $1.$bkextn
 elif [ -d $1 ]; then
 print "\nError: $1 is a directory and NOT a file. Aborting $cmdname ....\n"
 exit
 fi
 
 # Create subshell
 print "\nNow getting the file $1 from CVS repository ...\n"
 (
 cd $hme
 #echo $fdname
 # Use -A option to clear the sticky tag and to get
 # the HEAD revision version
 if [ "$FLAG1" = "" ]; then
 cvs -w checkout -A $fdname
 else
 cvs -w checkout -A -$FLAG1 $OARG1 $fdname
 fi
 )
 
 if [ -e $1 ]; then
 touch $lockfile
 fi
 
 #pwd
 
 print "\nDone $cmdname"
 #print "\nTip (Usage): $cmdname  \n"
 
 --------------------------------------------------------------------------------
 
 4.3 scommit
 
 注意 : Korn shell /bin/ksh 在你从Linux CD-ROM 安装 pdksh*.rpm 时就会产生
 
 请把他存成一般文字档并改变存取权限 chmod a+rx
 
 --------------------------------------------------------------------------------
 
 #!/bin/ksh
 # CVS program scommit
 # Program to commit the changes and check in the file into CVS
 
 cmdname=`basename $0`
 
 Usage()
 {
 print "\nUsage: $cmdname [-r revision_number] "
 print "The options -r are optional "
 print "For example - "
 print " $cmdname -r 1.1 foo.cpp"
 print " $cmdname foo.cpp "
 print " "
 }
 
 # Command getopt will not supported in next major release.
 # Use getopts instead.
 while getopts r: ii
 do
 case $ii in
 r) FLAG1=$ii; OARG1="$OPTARG";;
 ?) Usage; exit 2;;
 esac
 done
 shift ` expr $OPTIND - 1 `
 #echo FLAG1 = $FLAG1 , OARG1 = $OARG1
 
 if [ $# -lt 1 ]; then
 Usage
 exit 2
 fi
 
 if [ -d $1 ]; then
 Usage
 exit 2
 fi
 
 hme=` echo $HOME | cut -f1 -d' '  `
 if [ "$hme" = "" ]; then
 print "\nError: \$HOME is not set!!\n"
 exit
 fi
 
 # Find sub-directory
 cur_dir=`pwd`
 #echo $cur_dir
 len=${#hme}
 len=$(($len + 2))
 #echo $len
 subdir=` echo $cur_dir | cut -b $len-2000 `
 #echo $subdir
 if [ "$subdir" = "" ]; then
 fdname=$1
 else
 fdname=$subdir"/"$1
 fi
 
 # If file is already checked out by another user....
 cvs_root=` echo $CVSROOT | cut -f1 -d' '  `
 if [ "$cvs_root" = "" ]; then
 print "\nError: \$CVSROOT is not set!!\n"
 exit
 fi
 cldir=$CVSROOT/$subdir/Locks
 mkdir $cldir 2>/dev/null
 
 # Get the working revision number of the file....
 # Use tmpfile as the arg cannot be set inside the sub-shell
 tmpfile=$hme/sedit-lock.tmp
 \rm -f $tmpfile 2>/dev/null
 if [ "$FLAG1" = "" ]; then
 (
 cd $hme
 cvs status $fdname 2>/dev/null | grep "Working revision:" | awk '{print $3}' >$tmpfile
 )
 OARG1=`cat $tmpfile`
 \rm -f $tmpfile 2>/dev/null
 fi
 
 if [ "$OARG1" = "" ]; then
 print "The file $fdname is NEW, it is not in the CVS repository"
 else
 lockfile=$cldir/$1-$OARG1
 if [ -e $lockfile ]; then
 # Check if this revision is owned by you...
 aa=` ls -l $lockfile | awk '{print $3}' `
 userid=`id | cut -d'(' -f2 | cut -d')' -f1 `
 if [ "$aa" != "$userid" ]; then
 print " "
 print "The file $fdname is NOT locked by you!!"
 print "It is locked by unix user name $aa and your login name is $userid"
 #                       print "If you are working concurrently with other developer"
 #                       print "and you used -F option with sedit."
 print "You need to wait untill other developer does scommit"
 print "or sunlock"
 print "Aborting the $cmdname ...."
 print " "
 exit 2
 fi
 else
 if [ -f $CVSROOT/$subdir/$1,v ]; then
 print "You did not lock the file $fdname with sedit!!"
 print "Aborting the $cmdname ...."
 exit 2
 else
 print "\nThe file $fdname does not exist in CVS repository yet!!"
 print "You should have done sadd on $fdname ...."
 fi
 fi
 fi
 
 if [ -d $1 ]; then
 Usage
 exit 2
 # Do not allow directory commits for now ...
 #cvs commit
 else
 cvs commit $1
 exit_status=$?
 fi
 
 if [ $exit_status -eq 0 ]; then
 print "\nDone $cmdname. $cmdname successful"
 #print "\nTip (Usage): $cmdname \n"
 fi
 --------------------------------------------------------------------------------
 
 4.4 supdate
 
 注意 : Korn shell /bin/ksh 在你从Linux CD-ROM 安装 pdksh*.rpm 时就会产生
 
 请把他存成一般文字档并改变存取权限 chmod a+rx
 --------------------------------------------------------------------------------
 
 #!/bin/ksh
 
 # CVS program supdate
 # Program to update the file from CVS read/write mode
 
 cmdname=`basename $0`
 
 if [ $# -lt 1 ]; then
 print "\nUsage: $cmdname "
 exit
 fi
 
 # Check if file already exists....
 if [ $# -gt 0 -a  -f $1 ]; then
 user_perms=" "
 group_perms=" "
 other_perms=" "
 user_perms=`ls -l $1 | awk '{print $1 }' | cut -b3-3 `
 group_perms=`ls -l $1 | awk '{print $1 }' | cut -b6-6 `
 other_perms=`ls -l $1 | awk '{print $1 }' | cut -b9-9 `
 if [ "$user_perms" = "w" -o "$group_perms" = "w"  \
 -o "$other_perms" = "w" ]; then
 while :
 do
 print "\n$cmdname will backup your working file "
 print "$1 to $1.supdate_bak before doing any merges."
 print "Are you sure you want the merge the changes from"
 print -n "CVS repository to your working file ?  [n]: "
 read ans
 if [ "$ans" = "y" -o "$ans" = "Y" ]; then
 if [ -f $1.supdate_bak ]; then
 print "\nWarning : File $1.supdate_bak already exists!!"
 print "Please examine the file $1.supdate_bak and delete it"
 print "and than re-try this $cmdname "
 print "Aborting $cmdname ...."
 exit
 else
 cp $1 $1.supdate_bak
 break
 fi
 elif [ "$ans" = "n" -o "$ans" = "N" -o "$ans" = "" -o "$ans" = " " ]; then
 exit
 fi
 done
 fi
 fi
 
 if [ -d $1 ]; then
 print "\nDirectory update is disabled as cvs update"
 print "merges the changes from repository to your working directory"
 print "So give the filename to update - as shown below: "
 print " Usage: $cmdname "
 exit
 #       cvs update
 else
 cvs update $1
 fi
 
 print "\nDone $cmdname. $cmdname successful"
 #print "\nTip (Usage): $cmdname \n"
 --------------------------------------------------------------------------------
 
 4.5 sunlock
 
 注意 : Korn shell /bin/ksh 在你从Linux CD-ROM 安装 pdksh*.rpm 时就会产生
 
 请把他存成一般文字档并改变存取权限 chmod a+rx.
 --------------------------------------------------------------------------------
 
 #!/bin/ksh
 # CVS program sunlock
 # Program to unlock the file to release the lock done by sedit
 
 cmdname=`basename $0`
 
 Usage()
 {
 print "\nUsage: $cmdname [-r revision_number] "
 print " The options -r is optional "
 print "For example - "
 print " $cmdname -r 1.1 foo.cpp"
 print " $cmdname foo.cpp "
 print " "
 }
 
 # Command getopt will not supported in next major release.
 # Use getopts instead.
 while getopts r: ii
 do
 case $ii in
 r) FLAG1=$ii; OARG1="$OPTARG";;
 ?) Usage; exit 2;;
 esac
 done
 shift ` expr $OPTIND - 1 `
 
 if [ $# -lt 1 ]; then
 Usage
 exit
 fi
 
 hme=` echo $HOME | cut -f1 -d' '  `
 if [ "$hme" = "" ]; then
 print "\nError: \$HOME is not set!!\n"
 exit
 fi
 
 cur_dir=`pwd`
 #echo $cur_dir
 
 len=${#hme}
 len=$(($len + 2))
 #echo $len
 
 subdir=` echo $cur_dir | cut -b $len-2000 `
 #echo $subdir
 
 if [ "$subdir" = "" ]; then
 fdname=$1
 else
 fdname=$subdir"/"$1
 fi
 
 # If file is already checked out by another user....
 cvs_root=` echo $CVSROOT | cut -f1 -d' '  `
 if [ "$cvs_root" = "" ]; then
 print "\nError: \$CVSROOT is not set!!\n"
 exit
 fi
 cldir=$CVSROOT/$subdir/Locks
 rcsfile=$CVSROOT/$subdir/$1,v
 #echo $rcsfile
 
 if [ ! -e $rcsfile ]; then
 print "\nError: File $1 does not exist in CVS repository!!\n"
 exit
 fi
 
 # Get the tip revision number of the file....
 # Use tmpfile as the arg cannot be set inside the sub-shell
 tmpfile=$hme/sedit-lock.tmp
 \rm -f $tmpfile 2>/dev/null
 if [ "$FLAG1" = "" ]; then
 (
 cd $hme
 cvs log $fdname | head -6 | grep head: | awk '{print $2}' > $tmpfile
 )
 OARG1=`cat $tmpfile`
 \rm -f $tmpfile 2>/dev/null
 fi
 
 lockfile=$cldir/$1-$OARG1
 #echo lockfile is : $lockfile
 if [ ! -e $lockfile ]; then
 print "\nFile $1 revision $OARG1 is NOT locked by anyone"
 print " "
 exit
 fi
 
 ans=""
 while :
 do
 print "\n\n***************************************************"
 print "WARNING: $cmdname will release lock and enable other"
 print "         developers to edit the file. It is advisable"
 print "         to save your changes with scommit command"
 print "***************************************************"
 print -n "\nAre you sure you want to unlock the file ? [n]: "
 read ans
 if [ "$ans" = "" -o "$ans" = " " -o "$ans" = "n" -o "$ans" = "N" ]; then
 print "\nAborting $cmdname ...."
 exit
 fi
 if [ "$ans" = "y" -o "$ans" = "Y" ]; then
 print "\n\n\n\n\n "
 print "CAUTION: You may lose all the changes made to file!!"
 print -n "Do you really want to unlock the file ? [n]: "
 read ans
 if [ "$ans" = "y" -o "$ans" = "Y" ]; then
 break
 else
 exit
 fi
 else
 print "\n\nWrong entry. Try again..."
 sleep 1
 fi
 done
 
 if [ -e $lockfile ]; then
 \rm -f $lockfile
 print "\nDone $cmdname"
 else
 print "\nFile $1 is NOT locked by anyone"
 print " "
 fi
 --------------------------------------------------------------------------------
 
 4.6 slist
 
 注意 : Korn shell /bin/ksh 在你从Linux CD-ROM 安装 pdksh*.rpm 时就会产生
 
 请把他存成一般文字档并改变存取权限 chmod a+rx
 --------------------------------------------------------------------------------
 
 #!/bin/ksh
 
 # CVS program slist
 # Program to list all edited source files from CVS
 #cmdname=`basename $0`
 
 #echo "no of params : " $#
 #echo "all args : " $@
 
 recurse_flag=""
 
 if [ "$1" = "" ]; then
 dir=.
 recurse_flag=""
 else
 dir=$@
 recurse_flag=" -prune "
 fi
 
 FOUT=slist_temporary_file.out
 
 \rm -f $FOUT
 
 find $dir  $recurse_flag -type f -exec ls -ltr {} \; \
 | grep -v "/CVS/" \
 | grep ^\-rw \
 | grep -v \\.o \
 | grep -v \\.log \
 | grep -v \\.out \
 | grep -v \\.pid \
 | awk '{ if ($NF != "tags") print $0 }' \
 | awk '{ if ($NF != "a.out") print $0 }' \
 | awk '{ if ($NF != "core") print $0 }' \
 | awk '{ print $NF }' > $FOUT
 
 aa=`cat $FOUT`
 \rm -f $FOUT
 
 for ii in $aa ; do
 ftype=" "
 ftype=`file $ii | awk '{print $2 }' `
 
 # find . -type f -exec file {} \;
 # 1)ELF 2)commands 3)[nt]roff, 4)c 5)English  6)executable
 # 7)ascii 8)current 9)empty
 # Binaries are ELF, lib.a are current
 #
 if [ "$ftype" = "ascii" -o "$ftype" = "commands" \
 -o "$ftype" = "[nt]roff," -o "$ftype" = "c" -o "$ftype" = "data" \
 -o "$ftype" = "English" -o "$ftype" = "executable" ]; then
 pcfile=` echo $ii | cut -d'.' -f1`
 pcfile=${pcfile}".pc"
 if [ ! -f $pcfile ]; then
 ls -l $ii
 else
 if [ "$ii" = "$pcfile" ]; then
 ls -l $ii
 fi
 fi
 fi
 done;
 
 #| grep -v ^\-rwx \
 
 #ls -l | grep ^\-rw | grep -v \\.o
 #ls -l | grep ^\-rw | grep -v \\.o | awk '{ if ($NF != "tags") print $0 }'
 #ls -l | grep ^\-rw | grep -v ^\-rwx | grep -v \\.o |  awk '{ if ($NF != "tags") print $0 }' | awk '{ if ($NF != "core") print $0 }'
 
 #print "\nDone $cmdname. $cmdname successful"
 #print "\nTip (Usage): $cmdname \n"
 --------------------------------------------------------------------------------
 
 4.7 sinfo
 
 注意 : Korn shell /bin/ksh 在你从Linux CD-ROM 安装 pdksh*.rpm 时就会产生
 
 请把他存成一般文字档并改变存取权限 chmod a+rx
 --------------------------------------------------------------------------------
 
 #!/bin/ksh
 
 # CVS program sinfo
 # Program to get the status of files in working directory
 
 cmdname=`basename $0`
 
 if [ $# -lt 1 ]; then
 print "\nUsage: $cmdname [file/directory name] "
 print "For example - "
 print " $cmdname foo.cpp"
 print " $cmdname some_directory "
 print " "
 exit
 fi
 
 hme=` echo $HOME | cut -f1 -d' '  `
 if [ "$hme" = "" ]; then
 print "\nError: \$HOME is not set!!\n"
 exit
 fi
 
 tmpfile=$hme/cvs_sinfo.tmp
 rm -f $tmpfile
 cur_dir=`pwd`
 #echo $cur_dir
 
 len=${#hme}
 len=$(($len + 2))
 #echo $len
 
 subdir=` echo $cur_dir | cut -b $len-2000 `
 #echo $subdir
 
 if [ "$subdir" = "" ]; then
 fdname=$1
 else
 fdname=$subdir"/"$1
 fi
 
 # Create subshell
 if [ -f $1 ]; then
 (
 cd $hme
 clear
 cvs status $fdname
 )
 elif [ -d $1 ]; then
 (
 cd $hme
 clear
 echo "  " >> $tmpfile
 echo "  ****************************************" >> $tmpfile
 echo "        Overall Status of Directory" >> $tmpfile
 echo "  ****************************************" >> $tmpfile
 cvs release $fdname 1>>$tmpfile 2>>$tmpfile << EOF
 Y
 EOF
 echo "\n   -------------------------------\n" >> $tmpfile
 
 aa=`cat $tmpfile | grep ^"M " | awk '{print $2}' `
 for ii in $aa
 do
 jj="(cd $hme; cvs status $subdir/$ii );"
 echo $jj | /bin/sh  \
 | grep -v Sticky | awk '{if (NF != 0) print $0}' \
 1>>$tmpfile 2>>$tmpfile
 done
 
 cat $tmpfile | grep -v ^? | grep -v "Are you sure you want to release" \
 | less
 rm -f $tmpfile
 )
 else
 print "\nArgument $1 if not a file or directory"
 exit
 fi
 --------------------------------------------------------------------------------
 
 4.8 slog
 
 注意 : Korn shell /bin/ksh 在你从Linux CD-ROM 安装 pdksh*.rpm 时就会产生
 
 请把他存成一般文字档并改变存取权限 chmod a+rx
 --------------------------------------------------------------------------------
 
 #!/bin/ksh
 
 # CVS program slog
 # Program to list history of the file in CVS
 
 cmdname=`basename $0`
 
 if [ $# -lt 1 ]; then
 print "\nUsage: $cmdname  \n"
 exit
 fi
 
 # Check if file does not exist....
 if [ ! -f $1 ]; then
 print "\nError: $1 is NOT a file. Aborting $cmdname ......"
 exit
 fi
 
 cvs log $1 | /usr/local/bin/less
 
 print "\nDone $cmdname. $cmdname successful"
 #print "\nTip (Usage): $cmdname \n"
 --------------------------------------------------------------------------------
 
 4.9 sdif
 
 注意 : Korn shell /bin/ksh 在你从Linux CD-ROM 安装 pdksh*.rpm 时就会产生
 
 请把他存成一般文字档并改变存取权限 chmod a+rx
 --------------------------------------------------------------------------------
 
 #!/bin/ksh
 
 # CVS program sdif
 # Program to see difference of the working file with CVS copy
 
 cmdname=`basename $0`
 
 Usage()
 {
 print "\nUsage: $cmdname  "
 print "$cmdname -r -r  \n"
 exit
 }
 FLAG1=""
 FLAG2=""
 OARG1=""
 OARG2=""
 # Command getopt will not supported in next major release.
 # Use getopts instead.
 while getopts r:r: ii
 do
 case $ii in
 r)
 if [ "$FLAG1" = "" ]; then
 FLAG1=$ii;
 OARG1="$OPTARG"
 else
 FLAG2=$ii;
 OARG2="$OPTARG"
 fi
 ;;
 ?) Usage; exit 2;;
 esac
 done
 shift ` expr $OPTIND - 1 `
 
 if [ "$FLAG2" = "" ]; then
 FLAG2=r
 OARG2=HEAD
 fi
 
 if [ "$FLAG1" = "" ]; then
 cvs diff -r HEAD $1 | less
 else
 cvs diff -$FLAG1 $OARG1 -$FLAG2 $OARG2 $1 | less
 fi
 --------------------------------------------------------------------------------
 
 4.10 sadd
 
 注意 : Korn shell /bin/ksh 在你从Linux CD-ROM 安装 pdksh*.rpm 时就会产生
 
 请把他存成一般文字档并改变存取权限 chmod a+rx
 --------------------------------------------------------------------------------
 
 #!/bin/ksh
 
 # test
 # CVS program sadd
 # Program to add the file to CVS
 
 cmdname=`basename $0`
 if [ $# -lt 1 ]; then
 print "\nUsage: $cmdname  \n"
 exit
 fi
 
 # Check if file exists ....
 if [ -f $1 ]; then
 cvs add $1
 exit
 fi
 
 if [ ! -d $1 ]; then
 &n
 --------------------------------------------------------------------------------
 
 5. CVS 的其他文件
 
 在 unix 提示符号下,请打 -
 
 cvs --help
 cvs --help-options
 cvs --help-commands
 cvs -H checkout
 cvs -H commit
 man cvs
 man tkcvs
 网站 http://www.cyclic.com
 网站 http://www.loria.fr/~molli/cvs-index.html
 (译注:或者在 unix 提示符号下打 info cvs 也可得到一样的讯息)
 (译注:这篇也不错简单明了) http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/cvs/
 tkcvs http://www.tkcvs.org 是 CVS 的 Tcl/Tk GUI 介面。这里也有线上求助。
 
 cd $HOME/src/foo.cpp
 tkcvs
 在 foo.cpp 上点一下
 在 'spectacle Icon' 旁边的 'Revision Log Icon' 点一下。
 这将会显示一个 Tree 组织的图在视窗里。然後在文字 '1.3' 上用滑鼠的右键点一下还有 '1.1' 滑鼠的左键点一下,然後再点一下 "Diff" 。这样将会显示两个视窗出来!!
 在 "Next" 上点一下将会显示更多版本'1.3' 与 '1.1' 的 diffs。 请按 "Center" 将文字对齐置中。 (译注:这边原文好像有脱误)
 这里也有 Windows 95 用的 CVS 喔,叫 WinCVS。 http://www.wincvs.org WinCVS 可以用在 Samba 系统上喔 - http://www.samba.org
 
 基本重要的命令 -
 
 cvs checkout
 cvs update
 cvs add
 cvs remove
 cvs commit
 cvs status
 cvs log
 cvs diff -r1.4 -r1.5  这行指令将会输出档案 filename 1.4 版和 1.5 版的差异在哪里。
 
 --------------------------------------------------------------------------------
 --------------------------------------------------------------------------------
 
 6. Emacs 编辑器
 
 Emacs 是非常强大的编辑器而且还支援了 CVS/RCS - 尤其是对於改版後的合并和比较。 Emacs的主要网站在 http://www.emacs.org.
 --------------------------------------------------------------------------------
 --------------------------------------------------------------------------------
 
 7. 问题反应系统 (Problem Reporting System)
 
 伴随着 CVS 的使用,你可能会想要用计划追踪系统(Project Tracking system)或问题反应系统(Problem Reporting System)。每一个软体计划需要问题反应系统来作 bugs 的回报与追踪,并且把相关负责部分,分配给不同的程式设计师。
 
 想知道计划追踪系统(Project Tracking system)请看这个网站 http://www.stonekeep.com。
 
 --------------------------------------------------------------------------------
 --------------------------------------------------------------------------------
 
 8. 这份文件的其他档案格式
 
 这份文件用了将近 10 个不同的档案格式来发行 - DVI, Postscript, Latex, LyX, GNU-info, HTML, RTF(Rich Text Format), Plain-text, Unix man pages and SGML。
 你可以在下面的 Web 获得单一的 HTML, DVI, Postscript or SGML 型式的 tar.gz 档案, ftp://sunsite.unc.edu/pub/Linux/docs/HOWTO/other-formats/ 或者 ftp://metalab.unc.edu/pub/Linux/docs/HOWTO/other-formats/
 Plain text 格式的在: ftp://sunsite.unc.edu/pub/Linux/docs/HOWTO,或者 ftp://metalab.unc.edu/pub/Linux/docs/HOWTO
 翻译成其他国家语言像是法文,德文,西班牙文,中文,日文等等可在下面网址找得到。 ftp://sunsite.unc.edu/pub/Linux/docs/HOWTO 或者 ftp://metalab.unc.edu/pub/Linux/docs/HOWTO 对於任何想翻译这份文件到其他语言是都欢迎的。
 这份文件是用一种叫 "SGML" 的工具写成的。你可以从下列网址得到 - http://www.xs4all.nl/~cg/sgmltools/ 编译原始码後,你就会得到下列命令,像是
 sgml2html cvs-rcs-howto.sgml (产生 html 档案)
 sgml2rtf cvs-rcs-howto.sgml (产生 RTF 档案)
 sgml2latex cvs-rcs-howto.sgml (产生 latex 档案)
 这份文件是位於 -
 
 http://sunsite.unc.edu/LDP/HOWTO/CVS-RCS-HOWTO.html
 你也可以在下面映射网站找到这份文件 -
 
 http://www.caldera.com/LDP/HOWTO/CVS-RCS-HOWTO.html
 http://www.WGS.com/LDP/HOWTO/CVS-RCS-HOWTO.html
 http://www.cc.gatech.edu/linux/LDP/HOWTO/CVS-RCS-HOWTO.html
 http://www.redhat.com/linux-info/ldp/HOWTO/CVS-RCS-HOWTO.html
 其他比较靠近你的映射网站 http://sunsite.unc.edu/LDP/hmirrors.html 选择其中一个网站并到这个目录 /LDP/HOWTO/CVS-RCS-HOWTO.html
 想看 dvi 格式的文件,请用 xdvi 。若原本没安装,可在 Redhat Linux 下的 tetex-xdvi*.rpm 套件中找得到。要不然可以经由桌面上的ControlPanel | Applications | Publishing | TeX menu buttons找到他。
 
 想看 dvi 格式的文件,请下命令 -
 xdvi -geometry 80x90 howto.dvi,
 并且用滑鼠调整视窗大小。请看 xdvi 的线上求助 man xdvi。
 使用方向键, Page Up, Page Down 来检视文件。你也可以用 'f', 'd', 'u', 'c', 'l', 'r', 'p', 'n'来移动。
 要关掉专家模式 menu 请按 x 。
 
 你可以用软体 'gv' (ghostview) 或 'ghostscript' 来读 postscript 档案。
 在 Redhat Linux 下,ghostscript 在 ghostscript*.rpm 套件里, gv 在 gv*.rpm 套件里,如果你已经装了这个应用程式,可以透过 ControlPanel | Applications | Graphics menu 里找到, gv 是比 ghostscript 更友善使用。Ghostscript 和 gv 也可以在其他作业平台如 OS/2, windows 95 和 NT 下使用。
 
 要读 postscript 文件,请下这个命令 -
 gv howto.ps
 
 用 ghostscript 请打 -
 ghostscript howto.ps
 
 你可以用 Netscape Navigator, Microsoft Internet explorer, Redhat Baron Web browser 或其他浏览器来读 HTML 格式的文件。
 
 你可以用一个 latex 的 "X-Windows" 介面软体叫做 LyX 的,来读 latex 或 LyX 的输出。
 --------------------------------------------------------------------------------
 --------------------------------------------------------------------------------
 
 9. 版权
 
 这份文件版权为 GNU GPL,但是请在所有的复制中保留原作者的名字与电子邮件地址。
 |  |  |