UML软件工程组织

CVS 入门
作者: 卧龙小叁 来源:台南县教育网路中心
  1. 前言
  2. 术语中英对照
  3. 关於 CVS 的版本编号
  4. 操作方式
  5. 使用流程
  6. 使用 CVS 的准备动作
  7. 登入 CVS
  8. 取出整份专案
  9. 查询状态
  10. 修改程式、存入档案库
  11. 更新工作版本
  12. 比对版本差异
  13. 查询记录
  14. 新增档案
  15. 新增目录
  16. 删除档案
  17. 删除目录
  18. 更改档名
  19. 更改目录名
  20. 解决程式码冲突
  21. 取出过去的专案版本
  22. 依时间点取出过去的专案
  23. 依标记取出过去的专案
  24. 分支(branch)
  25. 合并分支及主干
  26. 取出专案,推出(release)软体版本
  27. 关键字展开
  28. 二进位档的处理
  29. CVS manpage
  30. CVS 速查
  31. 架设 CVS Server

 1. 前言

  CVS 是 Concurrent Versions System 的简称。它是现今 Open Source 成功发展的幕後功臣之一。CVS 解决多人合作开发时程式版本控管的问题,通常会再搭配邮件列表(Mailing List)做为开发团队沟通的管道。这种组合,使开发团队不受时间地域限制,合作伙伴分散全世界,且团队大小没有上限,因此 Open Source 才能集合世界各地高手,不断地薪火相传、不断地推出高品质的自由软体。

不过,CVS 初期上手不易,但若能以功能需求导向(我想要做这个,如何办到呢?)的方式来学习,可能也不是那麽困难。

本讲义,全部在 text console 模式下操作,但不代表您也必须用这种模式,您可以选用您喜爱的任何一种有支援 CVS 的编辑器或 CVS 操作环境(比如 WinCVS)。不过,您必须先了解 CVS 各种操作的涵意,这样观念才会清楚,才能确切掌握 CVS,和大家共同开发时,才能顺利愉快增进效率。一但您熟悉 console 模式之後,欲转换到其它环境,皆能有清晰的观念基础。

本文原为校园自由软体学务系统(sfs)合作开发伙伴而写的讲义,为免影响 sfs3 正式的系统(91/10开始),本文是以 xxx.yyy.edu.tw 中旧的 sfs2 专案为例子。往後您只要把出现 sfs2 的地方,改成 sfs3 或其它专案的名称,即可套用到其它专案。

注:C V S 不是 C S V !! 前者为版本控制系统,後者则是一种将每一列栏位用逗点分开的文件档案格式。

 2. 术语中英对照

 我把讲义中会用到的术语,以中英对照的方式表列於此。

这份对照只是 CVS 其中一小部份,往後会逐渐增加。

您大致看一下即可,一开始不必强记。

专案 : project

档案库 : repository

汇入专案 : import

发行版本 : version (如 SFS 3.0 版)
正式版 : release修改版次 : revision
版次编号 : revision Number工作版本 : working revision
库存版本 : repository revision存入 : commit (ci / com) (我们常称此一动作为 checkin)
取出 : checkout (co / get)
更新 : update (up / upd)
在库状态 : status (st / stat)
差异 : diff (di / dif)
新增 : add (ad / new)
移除 : remove (re / delete)
记录 : log (lo / log)
标记 : tag (ta / freeze)最新版 : Up-to-date
已修改 : Locally Modified
需更新 : Needs Patch
需合并 : Needs Merge

3. 关於 CVS 的版本编号

 CVS 的版次编号(revision number)只做为 CVS 内部控管之用,和将来发行的软体版本(version)无关。

也就是说:若某一支程式在 CVS 中版次编号为 1.5,而发行的软体版本 "您把它称为" SFS 3.0 版,那麽,这个 1.5 内部版次和 3.0 软体版本,是完全风马牛不相关的!

CVS 的版次成长的过程如下:

第一次将专案汇入 CVS Server 时,所有档案的版次编号皆为 1.1.1.1。若修改存入档案库之後,版次编号就由 1.2 起跳,尔後每存入一次,版次编号就增加 1。您可以放心尽情地修改,不同的程式档之间的版次编号不必一致,也就是说:一个专案中,A 这支程式到了 1.83 版,B 这支程式只到了 1.3 版,并不会影响将来发行软体的版本,我们可以利用标记(tag)等方式,来达到进一步控管的功能。

 4. 操作方式

 cvs 的操作方式,通常是:cvs + 动作命令 + 档案名称

常见的动作命令有:loign、logout、commit、checkout、update、status、diff、log、add、remove 等等,大部份的动作命令有简写,如 commit 可简写为 ci,checkout 可简写为 co,update 简写为 up,status 简写为 st ....,其它简写,可以执行 cvs --help-synonyms 查知。

除了动作命令之外,还有一些动作选项,比如 cvs diff -c inde.php 这个 -c 即为 diff 的动作选项,它可显示出工作版本和库存版本差异之处的原始码对照。这些选项,您可用 man cvs 查知。(本讲义末会把它列出来)

若不指定档案名称亦可,cvs 会针对目前工作目录下,所有档案及子目录,统统视为作用对象。

如比:更新工作版本时,cvs update 不加档名,则 cvs 会将您目前工作目录下所有的档案及子目录皆予以更新。

若执行 cvs update index.php,则只有 index.php 这个档案会被更新。

5. 使用流程

 CVS 使用 Client/Server 架构,Server 端会开启 2401 这个服务通道,client 端您可以选用 cvs 程式、支援 CVS 的编辑器(如 emacs)、或 CVS 的操作环境(如 Windows 平台的 wincvs / KDE 平台的 Cervisia)。

参与合作开发的伙伴,每一位都会由 CVS Server 档案库中,下载取出一份专案,这份专案储存在该员的硬碟中,我们称之为工作版本。CVS 使用的方式,便是:每位成员编辑自己的那一份工作版本,再将修改结果上传存入 CVS Server 档案库中,而这个过程,由 CVS 系统来帮忙记录及控管。

一般而言,CVS 的使用流程,大致如下:

  1. 登入 (login),只需做一次。需要密码认证,除非是允许匿名登入,否则都要输入 CVS Server 管理者配给您的密码。
  2. 取出(checkout)整份专案(类似档案下载)。此时,您的硬碟中会有一份专案的原始码目录,我们称之为工作目录。
  3. 依您的程式意图,修改某一支程式。
  4. 查询程式的在库状态(status)。 (3、4这二个动作可互调或合并操作)
  5. 视在库状态,比对二者的差异(diff),调整修改的程式(是否和他人修改的部份发生冲突,若无冲突,那就十分单纯,可在修改完之後,直接存入(commit/ci)档案库(repository)中)
  6. 若有冲突,在 mailling list 中,和他人讨论,取得协调。
  7. 将修改好的档案 commit 存入 CVS 档案柜 (俗称 checkin,类似档案上传),请务必在程式码注解中,详述您的意图。
  8. 透过 mailling list 说明您的想法,和大家讨论。
  9. 每经过一段时日,应查询在库状态,并更新您的工作目录(update)。

6. 使用 CVS 的准备动作

 使用 CVS 前,应先设妥 CVSROOT 环境变数,请在 ~/.bash_profile (个人适用) 或 /etc/profile (全体适用) 中加入以下设定:

export CVSROOT=:pserver:ols3@xxx.xxx.edu.tw:/home/export

注 :pserver:ols3@xxx.xxx.edu.tw:/home/export

只是一个例子,其中的帐号/主机/CVS目录,请勿直接套用。

实际设定值,请询问您的 CVS 管理员。

上述设定,在重新开机登入主机之後,即可生效。若不想重新登入主机,可执行 source ~/.bash_profile,然後 echo $CVSROOT 看看,显示的变数内容是否正确?

若不设 CVSROOT 环境变数,将来所有 cvs 动作命令,都必须在命令列中直接指定,如下所示:

cvs -d ":pserver:ols3@xxx.xxx.edu.tw:/home/export" login

cvs -d ":pserver:ols3@xxx.xxx.edu.tw:/home/export" checkout sfs2

若您已设妥 CVSROOT,不代表您只能使用一台 CVS Server 而已,若有其它 CVS Server,您可以在命令列中以 -d 直接指定。

7. 登入 CVS

 使用法:

cvs login

cvs -d ":pserver:ols3@xxx.xxx.edu.tw:/home/export" login

它会问你密码,正确回答密码之後,不会显示任何讯息。cvs 会将认证资讯,储存在 ~/.cvspass 中,尔後,您就不必再做登入的动作了。(除非您删除了 .cvspass)

如下所示:

$ cvs login

Logging in to :pserver:ols3@xxx.xxx.edu.tw:2401/home/export
CVS password:

登出则为:cvs logout

它会将 ~/.cvspass 清空,档案大小变成 0,如下所示:

-rw------- 1 ols3 ols3 0 10月 21 21:05 /home/ols3/.cvspass

若已登出,则下次使用 cvs 各项命令动作之前,需再做登入的动作一次。

8. 取出整份专案

 请先切换到您喜爱的工作目录中, 比如: cd ~/tmp

使用法:

cvs checkout sfs2

cvs co sfs2

它会在 ~/tmp 目录下,产生 sfs2 目录,该目录中的内容全数由 CVS Server 中下载。往後您就以在 ~/tmp/sfs2 中,来编辑修改 sfs2 专案的各个程式档了。

您取出的专案版本,我们就称之为工作版本,存放在 CVS Server 中的称为库存版本;下载的 sfs2 这个目录,则称为工作目录。

如下所示:

$ cvs co sfs2

....以上省略....
U sfs2/upgrade/1.gif
U sfs2/upgrade/footer.php
U sfs2/upgrade/header.php
U sfs2/upgrade/sfs2.sql
U sfs2/upgrade/update_function.php
U sfs2/upgrade/upgrade1.1-2.0.php
U sfs2/upgrade/ustep0.php
U sfs2/upgrade/ustep1.php
U sfs2/upgrade/ustep2.php
U sfs2/upgrade/ustep3.php
U sfs2/upgrade/ustep4.php

9. 查询状态

 使用法:

cvs status 档案名称 或 cvs st 档案名称 或cvs st

若不加档案名称,则会显示所有档案的状态。

例:

$ cvs st index.php
===================================================================
File: index.php Status: Up-to-date

Working revision: 1.1.1.1
Repository revision: 1.1.1.1 /home/export/sfs2/index.php,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)

表示 index.php 目前最新版是 1.1 版(以 1.1.1.1代表) 请注意上面右上角的讯息 Status,常见的讯息有:

Up-to-date : 最新版
Locally Modified : 已修改
Needs Patch : 需更新
Needs Merge : 需合并

10. 修改程式、存入档案库

 使用法:

cvs commit 档案名称

cvs ci 档案名称

cvs com 档案名称

cvs co

若不加档案名称,则目前目录下所有档案及子目录全部存入。

例:

index.php 程式码内容原为:

<?php
session_start();
/* 取得学务系统设定档 */
include "include/config.php";
// --程式档头
head("首页","",1);
//列出模组
print_module(1);
foot();
?>

在第 2 列新增一列注解 # 启动 session

变成:

<?php
# 启动 session
session_start();
/* 取得学务系统设定档 */
include "include/config.php";
// --程式档头
head("首页","",1);
//列出模组
print_module(1);
foot();
?>

先查一下它的状态:

$ cvs st index.php
===================================================================
File: index.php Status: Locally Modified

Working revision: 1.1.1.1
Repository revision: 1.1.1.1 /home/export/sfs2/index.php,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)

由右上角这句 Status: Locally Modified,表示 cvs 已把档案库中的 index.php 和 ~/tmp/sfs2/index.php 这个同名的 local 档案做了比对,它发现有人已对 local 的 index.php 做了修改。

接着,将 index.php 存入 CVS 档案库中:cvs ci -m "增加一列注解" index.php

 ci 是存入之意,-m 後面接续本次存入的记录讯息,主要目的,是用来让自己及合作伙伴,将来能对这次的修改动作有迹可循。若您没有加 -m "记录讯息" 也无妨,cvs 会主动叫出 vi,要求您必须输入记录讯息,如以下操作画面:

增加一列注解

CVS: ----------------------------------------------------------------------
CVS: Enter Log. Lines beginning with `CVS:' are removed automatically
CVS:
CVS: Committing in .
CVS:
CVS: Modified Files:
CVS: index.php
CVS: ----------------------------------------------------------------------

按 wq 存档离开, 出现以下画面:

$ cvs ci index.php
Checking in index.php;
/home/export/sfs2/index.php,v <-- index.php
new revision: 1.2; previous revision: 1.1
done

由上述讯息可知:index.php 已成功存入档案库,目前修改版次 为 1.2。

用 cvs st index.php 再查查看 index.php 状态:

===================================================================
File: index.php Status: Up-to-date

Working revision: 1.2
Repository revision: 1.2 /home/export/sfs2/index.php,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)

由右上角 Status: Up-to-date 这个讯息可知:index.php 存入成功,和目前工作目录下的工作版本一致,已是最新的版本了。

 返回首页

11. 更新工作版本
经过一段期日,或许别人已修改了某些程式码存入档案库中,此时应该用 update 指令,更新一下目前的工作版本。

使用法:

cvs update 档案名称

cvs up 档案名称

cvs up

若要连档案库中新增的目录也下载,要加上 -d 选项。

cvs up -d

若不加档案名称,则会更新所有的档案及子目录内容。

例:

$ cvs update

显示画面如下:

cvs server: Updating .
U index.php
cvs server: Updating admin
cvs server: Updating admin/board_man
...以下省略....

$ cvs up index.php

U index.php

上述出现 U index.php,表示 local 工作版本 index.php 已经更新,和库存版本一致。

若您在更新之前,已修改了 index.php,会出现以下情况:

$ cvs up

cvs server: Updating .
M index.php
cvs server: Updating admin
cvs server: Updating admin/board_man
...以下省略....

M index.php 表示 local 版本已被修改,update 命令不会予以覆盖更新,您可以查询一下状态:

$ cvs st index.php

===================================================================
File: index.php Status: Locally Modified

Working revision: 1.7
Repository revision: 1.7 /home/export/sfs2/index.php,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)

由 Status: Locally Modified 可知您已修改了 local 工作版本,和库存版本并不一致。

有时我们需要看看二者有何差异。详情请见下一节内容。

 12. 比对版本差异

 当发现工作版本和库存版本不一致时,需要比对了解差异之处。

使用法:

cvs diff 档案名称

cvs dif 档案名称

cvs diff

以上将简单列出,比对的差异列数及内容

====================================

cvs diff -c 档案名称

cvs dif -c 档案名称

cvs diff -c

以上命令将完整显示差异之原始码对照

====================================

diff 也可以指定要和那一个修改版次做比对:

如:cvs diff -r1.5 -c index.php

即表示要拿 index.php 的工作版本和库存版本 1.5 比较差异。

若不加档案名称,则会比对所有的档案及子目录内容。

例:

$ cvs diff

显示画面如下:

cvs server: Diffing .
Index: index.php
===================================================================
RCS file: /home/export/sfs2/index.php,v
retrieving revision 1.7
diff -r1.7 index.php
15d14
< # 3333333333333333
cvs server: Diffing adir
cvs server: Diffing admin
cvs server: Diffing admin/board_man
cvs server: Diffing admin/board_man/images
cvs server: Diffing admin/create_data
cvs server: Diffing admin/create_data/images
cvs server: Diffing admin/fixed_man
cvs server: Diffing admin/fixed_man/images
... 以下省略 ...

注意 !

若不想显示一些不相干的 Diffing 讯息,
可多加一个 -Q (最安静) 或 -q (安静) 的选项:

cvs -Q diff

cvs -q diff

或直接加入档名

cvs diff index.php

上面讯息中,有几个地方解释於下:

RCS file: /home/export/sfs2/index.php,v
这一列是说:CVS 使用 RCS 这个版本控制系统的档案格式

retrieving revision 1.7
这一列是说:正在取出的库存版本的修改版次是 1.7

diff -r1.7 index.php
这一列是说:工作版本 index.php 和库存版本 1.7 做比对

15d14
< # 3333333333333333
这二列是说:比对结果发现,工作版本把库存版本的第 15 列被删除(d),
被删的那一列内容为 # 3333333333333333

注意:
d 代表删除
a 代表新增
< 这个符号代表库存版本中的某些列
> 这个符号则代表工作版本中的某些列

再举一个例子:

$ cvs diff index2.php

Index: index2.php
===================================================================
RCS file: /home/export/sfs2/index2.php,v
retrieving revision 1.2
diff -r1.2 index2.php
2a3
> # session 的意义您了解吗?

解释如下:

RCS file: /home/export/sfs2/index2.php,v
CVS 中的 RCS 档是 index.php,v (CVS 其实是借用 RCS 版本控制的格式)

retrieving revision 1.2
目前取出的 修改版次 是 1.2

diff -r1.2 index2.php
比对 1.2 和 工作版本 index2.php 的差异

2a3
在第 2 列之後,工作版本新增(add, 以 a 简写)了第 3 列,
第 3 列的内容为
# session 的意义您了解吗?

> 代表工作版本中的某些列

不过,上述比对差异太过简单,有时不容易看出端倪,因此,最好能将二者的差异之处,以原始码对照的方式列出来,将会比较清楚。此时,要加一个 -c 的动作选项,如以下例子:

$ cvs diff -c index.php

有以下结果:

Index: index.php
===================================================================
RCS file: /home/export/sfs2/index.php,v
retrieving revision 1.7
diff -c -r1.7 index.php
*** index.php 19 Oct 2002 14:58:16 -0000 1.7
--- index.php 20 Oct 2002 07:42:11 -0000
***************
*** 12,18 ****
# 22222222222222
# echo test
//列出模组
- # 3333333333333333
print_module(1);
foot();
?>
--- 12,17 ----


重点解释如下:

*** index.php 19 Oct 2002 14:58:16 -0000 1.7
这一列代表库存

--- index.php 20 Oct 2002 07:42:11 -0000
这一列代表工作版本


***************
*** 12,18 ****
库存版本差异之处由第 12 列到第 18 列

列 标记 内容
====================================
12 # 22222222222222
13 # echo test
14 //列出模组
15 - # 3333333333333333
16 print_module(1);
17 foot();
18 ?>

可以发现在第 15 列之前,出现了 - 的符号,
这表示该列在工作版本中被删除。

--- 12,17 ----
上面这一列表示工作版本差异之处,是第 12 列到第 17 列,
由於只是删除一列而已,其馀内容一样,因此 --- 12,17 ----
以下不再列出这几列的内容。

比对之後,了解差异,可再做修改,接着可按先前介绍的方法,将工作版本存入(commit 或 称 checkin)档案库中。

 13. 查询记录

 有时想了解某一个档案过去更动的记录,可按以下方法操作:

cvs log 档案名称

cvs lo 档案名称

例:

$ cvs log index.php

得到:

RCS file: /home/export/sfs2/index.php,v
Working file: index.php
head: 1.7
branch:
locks: strict
access list:
symbolic names:
v2: 1.1.1.1
sfs2man: 1.1.1
keyword substitution: kv
total revisions: 8; selected revisions: 8
description:
----------------------------
revision 1.7
date: 2002/10/19 14:58:16; author: ols3; state: Exp; lines: +3 -0
test
----------------------------
revision 1.6
date: 2002/10/19 12:42:46; author: 乙; state: Exp; lines: +2 -0
又加了2列
----------------------------
revision 1.5
date: 2002/10/19 12:18:31; author: 甲; state: Exp; lines: +1 -1
已解决和乙的冲突
----------------------------
revision 1.4
date: 2002/10/19 09:15:35; author: 乙; state: Exp; lines: +1 -0
乙做了修改
----------------------------
revision 1.3
date: 2002/10/19 08:14:44; author: 乙; state: Exp; lines: +1 -0
再加一列注解
----------------------------
revision 1.2
date: 2002/10/19 07:41:57; author: 甲; state: Exp; lines: +1 -0
增加一列注解
----------------------------
revision 1.1
date: 2002/09/23 13:16:01; author: ols3; state: Exp;
branches: 1.1.1;
Initial revision
----------------------------
revision 1.1.1.1
date: 2002/09/23 13:16:01; author: ols3; state: Exp; lines: +0 -0
init SFS2 CVS Server
=============================================================================

14. 新增档案

 有时因程式意图,需要新增一个专案中原先并不存在的档案,可按以下方法操作:

共有叁个步骤:

1. local 下编辑产生新的档案
2. 将新档案加入工作排程:cvs add 档案名称
3. 将新档案存入档案库:cvs ci -m "记录讯息" 档案名称

例:

1. local 下编辑产生新的档案,假设档名为 test.php

$ emacs test.php

2. 将新档案加入工作排程:

$ cvs add test.php

出现:

cvs server: scheduling file `test.php' for addition
cvs server: use 'cvs commit' to add this file permanently

这表示 test.php 已被排入,下一步需要再作 checkin 存入的动作。

3. 将新档案存入档案库:

$ cvs ci -m "added test.php" test.php

得到:

RCS file: /home/export/sfs2/test.php,v
done
Checking in test.php;
/home/export/sfs2/test.php,v <-- test.php
initial revision: 1.1
done

如此一来, test.php 已成功存入档案库中, 而修改版次则由 1.1 版起跳.

15. 新增目录

 有时因程式意图,需要新增一个专案中原先并不存在的目录,可按以下方法操作:

共有二个步骤:

1. local 下产生新的目录:mkdir 目录名称
2. 将新目录存入档案库:cvs add 目录名称

例:

1. local 下开新的目录,假设目录名称为 adir

$ mkdir adir

2. 将新目录存入档案库:

$ cvs add adir

得到:

Directory /home/export/sfs2/adir added to the repository

表示档案库中已新增了一个叫 adir 的目录.

查看一下工作目录中 adir 的目录内容:

ls adir/CVS

得到:

total 20
drwxrwxr-x 2 ols3 ols3 4096 10月 19 23:48 .
drwxrwxr-x 3 ols3 ols3 4096 10月 19 23:48 ..
-rw-rw-r-- 1 ols3 ols3 2 10月 19 23:48 Entries
-rw-rw-r-- 1 ols3 ols3 10 10月 19 23:48 Repository
-rw-rw-r-- 1 ols3 ols3 41 10月 19 23:48 Root

cvs 已自动在 adir 目录中,产生版本控管的相关档案了。

16. 删除档案

 有时因程式意图,需要删除一个专案中已存在的档案,可按以下方法操作:

共有叁个步骤:

1. local 中删除该档案:rm 档案名称
2. 将删除的档案加入工作排程:cvs remove 档案名称
3. 将删除的档案动作存入档案库中,以移除库存:cvs ci -m "记录讯息" 档案名称

例:

1. 先删除 local 下的档案, 如:

rm test.php

2. 再下 cvs remove 的指令:

cvs remove test.php

得:

cvs server: scheduling `test.php' for removal
cvs server: use 'cvs commit' to remove this file permanently

上述意指: 必须做一次 checkin 的动作才能永远删除 test.php

因此, 我们再下:

3. cvs ci -m "remove test.php" test.php

得:

Removing test.php;
/home/export/sfs2/test.php,v <-- test.php
new revision: delete; previous revision: 1.1
done

上面 cvs ci -m "remove test.php" test.php
中的 test.php 虽然实际上已不存在於工作目录中了,
但仍要 checkin 一次,可见此处的 test.php 指的是
档案库中的旧记录档名而已。

17. 删除目录

 有时因程式意图,需要删除专案中已存在的目录,可按以下方法操作:

共有四个步骤:

1. local 中删除该目录中所有的档案:cd 目录 && rm 档案名称
2. 将删除的档案加入工作排程:cvs remove 档案名称
3. 将删除的档案动作存入档案库中,以移除库存:cvs ci -m "记录讯息" 档案名称
4. 更新:update -P

例:

1. cd 目录 且 删除目录中所有的档案

$ cd adir
$ rm f1 f2 f3 f4 f5

2. 移除:

$ cvs remove f1 f2 f3 f4 f5

3. 存入删除的动作:

$ cvs ci -m "remove all files of adir" f1 f2 f3 f4 f5

4. 更新:

$ cvs update -P

-P 告知 cvs update 将空目录由库存中删除

18. 更改档名

 有时因程式意图,需要更改专案中某一档案的档名,可按以下方法操作:

共有四个步骤:

1. local 下将旧档名改成新档名
2. cvs remove 旧档名
3. cvs add 新档名
4. 存入档案库中:cvs ci -m "记录讯息" 旧档名 新档名

例:

1. local 下更名:

$ mv upgrade.txt up.txt

2. cvs remove 旧档名:

$ cvs remove upgrade.txt

得到:
cvs server: scheduling `upgrade.txt' for removal
cvs server: use 'cvs commit' to remove this file permanently

3. cvs add 新档名:

$ cvs add up.txt

得到:
cvs server: scheduling file `up.txt' for addition
cvs server: use 'cvs commit' to add this file permanently

4. 存入:

$ cvs ci -m "将 upgrade.txt 更名为 up.txt" upgrade.txt up.txt

得到:
Removing upgrade.txt;
/home/export/sfs2/upgrade.txt,v <-- upgrade.txt
new revision: delete; previous revision: 1.1.1.1
done
RCS file: /home/export/sfs2/up.txt,v
done
Checking in up.txt;
/home/export/sfs2/up.txt,v <-- up.txt
initial revision: 1.1
done

cvs 已将库存 upgrade.txt 移除,加入 up.txt
且修改版次由 1.1 起跳

19. 更改目录名

 有时因程式意图,需要更改专案中某一目录的名称,可按以下方法操作:

共有七个步骤:

1. local 下开设新目录:mkdir 新目录名 (即您要改的新名称)
2. cvs add 新目录名
3. 将旧目录内的档案全搬移到新目录下: mv 旧目录/* 新目录
4. 进入旧目录中,cvs remove 档案名
5. 进入新目录中,cvs add 档案名
6. 回到上一层目录、存入档案库中:cvs ci -m "记录讯息"
7. 更新:cvs update -P

例:

打算把 db 目录更名为 DB2,db 中有一档案为 sfs2.sql

1. local 下开设新目录:

$ mkdir DB2

2. cvs add 新目录名

$ cvs add DB2

得到:
Directory /home/export/sfs2/DB2 added to the repository

3. 将旧目录内的档案全搬移到新目录下:

$ mv db/* DB2

4. 进入旧目录中,cvs remove 档案名:

$ cd db
$ cvs remove sfs2.sql

得到:

cvs server: scheduling `sfs2.sql' for removal
cvs server: use 'cvs commit' to remove this file permanently

5. 进入新目录中,cvs add 档案名

$ cd ../DB2
$ cvs add sfs2.sql

得到:

cvs server: scheduling file `sfs2.sql' for addition
cvs server: use 'cvs commit' to add this file permanently

6. 回到上一层目录、存入档案库中:

$ cd ..
$ cvs ci -m "把 db 目录更名为 DB2"

得到:
RCS file: /home/export/sfs2/DB2/sfs2.sql,v
done
Checking in DB2/sfs2.sql;
/home/export/sfs2/DB2/sfs2.sql,v <-- sfs2.sql
initial revision: 1.1
done
Removing db/sfs2.sql;
/home/export/sfs2/db/sfs2.sql,v <-- sfs2.sql
new revision: delete; previous revision: 1.1.1.1
done

7. 更新:(以移除库存中的空目录)

cvs update -P

哇 ! 看到了吧? 要更换目录名称是如此麻烦,因此,最好您的专案一开始就做好较完善的规划,以免带来困扰。

20. 解决程式码冲突

 多人合作开发,难免会遇到二个人同时更动同一支程式码的情况,本节将说明解决的方法。

情境假设:甲乙二人是 sfs2 专案合作开发的伙伴,甲乙二人都各自有一份最新的工作版本,乙先对 index.php 做了修改, 且乙已将它存入档案库中,之後,甲也修改其工作目录中的 index.php,甲正准备将 index.php 存入档案库中,但因甲乙二人修改的是同一支程式,且对某一列有不同的改法,因此产生了冲突。

我们来看看二人的动作,以及甲解决程式码冲突的方法:

乙修改的 index.php 如下所示:

<?php
# 启动 session
# session 的意义您了解吗?
# 我是乙, I say hi! <---- 乙新增这一列
session_start();
/* 取得学务系统设定档 */
include "include/config.php";
// --程式档头
head("首页","",1);
//列出模组
print_module(1);
foot();
?>

乙把它 checkin 存入档案库中:

$ cvs ci -m "乙做了修改" index.php

乙得到以下讯息,目前最新的版次为 1.4 版:

Checking in index.php;
/home/export/sfs2/index.php,v <-- index.php
new revision: 1.4; previous revision: 1.3
done

假设甲对 index.php 也做了修改,如下所示:

<?php
甲修改的 index.php:

# 启动 session
# session 的意义您了解吗?
# 我是甲, I say HI! <---- 甲新增这一列
session_start();
/* 取得学务系统设定档 */
include "include/config.php";
// --程式档头
head("首页","",1);
//列出模组
print_module(1);
foot();
?>

甲在存入档案库之前,先做了查询的动作:

$ cvs st index.php

===================================================================
File: index.php Status: Needs Merge

Working revision: 1.3
Repository revision: 1.4 /home/export/sfs2/index.php,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)

右上角这句 Status: Needs Merge表示甲的工作版本 index.php 1.3 版和库存最新的 index.php 1.4 版有所突冲 !

为了 解冲突所在,甲做了差异比对:

$ cvs diff -c index.php

Index: index.php
===================================================================
RCS file: /home/export/sfs2/index.php,v
retrieving revision 1.4
diff -c -r1.4 index.php
*** index.php 19 Oct 2002 09:15:35 -0000 1.4
--- index.php 20 Oct 2002 13:18:30 -0000
***************
*** 1,7 ****
<?php
# 启动 session
# session 的意义您了解吗?
! # 我是乙, I say hi!
session_start();
/* 取得学务系统设定档 */
include "include/config.php";
--- 1,7 ----
<?php
# 启动 session
# session 的意义您了解吗?
! # 我是甲, I say HI!
session_start();
/* 取得学务系统设定档 */
include "include/config.php";

注意:! 表示程式码发生了冲突

接着,甲执行 cvs update index.php 以更新 index.php

$ cvs update index.php

得到:

RCS file: /home/export/sfs2/index.php,v
retrieving revision 1.3
retrieving revision 1.4
Merging differences between 1.3 and 1.4 into index.php
rcsmerge: warning: conflicts during merge
cvs server: conflicts found in index.php
C index.php

C index.php 表示甲乙修改版本有冲突。

甲把 index.php 用编辑器叫出来看看:

$ emacs index.php

得:

<?php
# 启动 session
# session 的意义您了解吗?
<<<<<<< index.php
# 我是甲, I say HI!
=======
# 我是乙, I say hi!
>>>>>>> 1.4
session_start();
/* 取得学务系统设定档 */
include "include/config.php";
// --程式档头
head("首页","",1);
//列出模组
print_module(1);
foot();
?>


请注意 !
<<<<<<< index.php <--- 甲的 index.php
# 我是甲, I say HI! <--- 甲修改的
=======
# 我是乙, I say hi! <--- 乙修改的
>>>>>>> 1.4 <--- 档案库中的 index.php 1.4 版

此时,甲要做二件事:

透过 mailling list 和 乙取得协调,看要使用那一个?

协调之後,去除冲突指引符号 <<< 和 >>> 及分隔符号===,并修改程式码。

假设甲修改之後,结果如下:

<?php
# 启动 session
# session 的意义您了解吗?
# 我们是甲和乙, We say HI! <--- 甲最後决定的结果
session_start();
/* 取得学务系统设定档 */
include "include/config.php";
// --程式档头
head("首页","",1);
//列出模组
print_module(1);
foot();
?>

甲将 index.php 存入档案库中:

$ cvs ci -m "已解决和乙的冲突" index.php

得到:

Checking in index.php;
/home/export/sfs2/index.php,v <-- index.php
new revision: 1.5; previous revision: 1.4
done

此时,index.php 存入档案库,成为 1.5 版,至此,已解决甲乙二人程式码冲突的问题罗。

 返回首页

21. 取出过去的专案版本

 CVS 提供二种方式取出过去的专案版本:

依时间点取出 (by date)

依标记取出 (by tag)

专案会一直往前发展,终於有一天,领导人评估之後,认为该专案目前已经稳定成熟,可以推出正式版本了。这时,领导人通常会给专案的程式码加上一个标记,比如:r2002_10_20,然後将专案打包,并为该软体命名一个发行版本(如 SFS 3.0 版)。

不过,正式版推出一段时间之後,可能会有使用者发现软体在某些地方功能不太正常,因此将问题回报给专案成员。而这段期间,专案仍持续不断地往前发展,在发展中的这种最新版本,通常不稳定,无法立即可用,实在不适合正式推出。为了修正程式码中的臭虫,有必要取出过去的程式码。此时,当初设定的标记就十分重要了 ! 我们可以根据标记,取出当时专案中的所有程式码,以进行修正的动作。至於目前持续发展中的版本,则不会受到任何影响。

当然,也可以依时间点来取出当时的专案,不过,正式版究竟在何时推出的? 可能很难追忆,所以,一般而言,还是以使用标记的方式居多。

关於上述这二种方式,分别说明於后。请参考一下节。

22. 依时间点取出过去的专案

 请记住一个观念:当您取出过去的专案时,目前的工作版本会暂时变成旧专案,若修改它,您是无法把它存入 CVS 档案库中! 因为它是过去的历史,CVS 不容许您修改历史,此时必须在原先的发展路线上,开辟另外一个分支(branch),所有修正臭虫的程式码,全部在这条分支上去进行。

关於分支的作法,往後再来说明,现在先把重点摆在:依时间点来取出过去的专案。

作法如下:

cvs -q update -D "时间点"

时间点格式,有许多种,通常用 "2002-10-22 23:50:23 GMT" 这种格式,就行得通了。

例:假设欲取出 2002-10-19 10:00:00 之前的专案,作法如下:

cvs -q update -D "2002-10-19 10:00:0 GMT"

请务必加上 GMT(统一时间),因为 CVS 内部是使用 GMT 标准,而您的主机中通常是使用 local 时间,若不加上 GMT,会产生时差而无法取出正确的时间点的程式码版本。

这是执行上述指令前,目前工作目录中最新版 index.php 的在库状态:

$ cvs st index.php
===================================================================
File: index.php Status: Up-to-date

Working revision: 1.10
Repository revision: 1.10 /home/export/sfs2/index.php,v
Sticky Tag: (none)
Sticky Date: (none) <--- 请注意这一列
Sticky Options: (none)

现在执行:

$ cvs -q update -D "2002-10-19 10:00:0 GMT"

再查一下 index.php 的状态:

$ cvs st index.php

得到:

$ cvs st index.php
===================================================================
File: index.php Status: Up-to-date

Working revision: 1.4
Repository revision: 1.4 /home/export/sfs2/index.php,v
Sticky Tag: (none)
Sticky Date: 2002.10.19.10.00.00 <--- 请注意这一列
Sticky Options: (none)

上面 Sticky Date 已固定在 2002-10-19 10:00:00 这个时间点,这表示您目前的工作版本已暂时变成这时间点之前的版本,以 index.php 而言,它目前是回到 1.4 版。别担心,您先前的工作版本不会消失,等一下即可回复。

注意 ! 若您修改了它,您是无法将它 checkin 存入档案库的 ! CVS 认为过去的历史不能修改,就如同人的历史不能改变一样 ! 要修改的话,只能使用分支(branch)的作法,由原先的时间点另外走一条叉路出来。

取消时间点的方法如下:

cvs -q update -A 这样就可以回到您原先的工作版本了。

执行:

$ cvs st index.php
===================================================================
File: index.php Status: Up-to-date

Working revision: 1.10
Repository revision: 1.10 /home/export/sfs2/index.php,v
Sticky Tag: (none)
Sticky Date: (none) <--- 请注意这一列
Sticky Options: (none)

您看,index.php 又回到原有的版本了。

23. 依标记取出过去的专案

 在第 21 节中曾提到,通常在推出正式版软体时,专案领导人会加上一个标记,做为将来维护的基点。

加上标记的方法如下:

cvs -q tag 标记名称

注意! 标记名称只能是英数字 - 及 _

例:

cvs -q tag r2002_10_20

这个动作,会将目前的档案库中的专案各个程式码加上一个标记 r2002_10_20,往後专案持续进行时,这个标记不会消失。请注意:tag 指令并不会自动把您目前的工作版本全换成这个标记版本。

取出这个标记的专案,一般而言有二个方法:重新取出或更新。

方法一、重新取出法:这个方法主要是不想去动到您的工作版本

请另辟一个新目录,切换到该目录下,执行:

cvs co -r r2002_10_20 sfs2

它会在新目录下抓出含有 r2002_10_20 标记的专案。

此时,查一下 index.php 的状态:

$ cvs st index.php

得到:

===================================================================
File: index.php Status: Up-to-date

Working revision: 1.9
Repository revision: 1.9 /home/export/sfs2/index.php,v
Sticky Tag: r2002_10_20 (revision: 1.9) <--- 请注意这一列
Sticky Date: (none)
Sticky Options: (none)


各位应该记得吧? index.php 的最新版是 1.10,而我目前取出的标记版本是 1.9

由此,各位可以了解:其实标记的作用,就是在过去的某一个时间点留下注记,
以方便日後将这个时间点的历史取出,以做处理之用(通常是修正臭虫)。

回复的方法同上一节,如下所示:

cvs -q update -A

查一下状态:

$ cvs st index.php
===================================================================
File: index.php Status: Up-to-date

Working revision: 1.10
Repository revision: 1.10 /home/export/sfs2/index.php,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)

方法二、更新法:这个方法会使您的工作版本暂时变成过去标记的版本

cvs -q update -r r2002_10_20

查一下状态:

$ cvs st index.php
===================================================================
File: index.php Status: Up-to-date

Working revision: 1.9
Repository revision: 1.9 /home/export/sfs2/index.php,v
Sticky Tag: r2002_10_20 (revision: 1.9)
Sticky Date: (none)
Sticky Options: (none)

此时您的工作版本暂时变成 r2002_10_20 版。回复的方法同前。

cvs -q update -A

查一下状态:

$ cvs st index.php
===================================================================
File: index.php Status: Up-to-date

Working revision: 1.10
Repository revision: 1.10 /home/export/sfs2/index.php,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)

24. 分支(branch)

 CVS 可以让您回到某一稳定版本,由该处去修正程式的错误,修正的结果循另一条路线发展,以提供更可靠的程式版本。这就是分支的概念。原来的主要发展版本,我们就称之为主干。

开分支的方法如下:

1. 依标记取出过去某一版本的专案:(取出专案)

$ cvs co -d oldsfs2 -r r2002_10_20 sfs2

-d 选会产生一个目录 oldsfs2,取出的专案程式码置於其中

2. 进入该目录,产生分支:(产生分支)

$ cd oldsfs2
$ cvs -q tag -b r2002_10_20_branch

-b 指示产生一个分支,结果如下:

....以上省略....
T upgrade/ustep0.php
T upgrade/ustep1.php
T upgrade/ustep2.php
T upgrade/ustep3.php
T upgrade/ustep4.php

T 表示已做了标记。注意 ! 做标记只会影响档案库中的内容,并不会使目前的工作版本有任何变化。因此,更新的动作要自己做一次。

3. 更新工作版本使其变成分支:(进入分支)

$ cvs -q update -r r2002_10_20_branch

查一下状态:

$ cvs st index.php

结果如下:

$ cvs st index.php
===================================================================
File: index.php Status: Up-to-date

Working revision: 1.9
Repository revision: 1.9 /home/export/sfs2/index.php,v
Sticky Tag: r2002_10_20_branch (branch: 1.9.2) <--- 注意这一列
Sticky Date: (none)
Sticky Options: (none)

由上可知:新的分支已经产生,index.php 分支的根基点是 1.9 版,分支由 1.9.2 起跳。

修改一下 index.php 并予以 checkin 存入,再查一下它的状态:

$ emacs index.php

$ cvs ci -m "test branch" index.php

得:
Checking in index.php;
/home/export/sfs2/index.php,v <-- index.php
new revision: 1.9.2.1; previous revision: 1.9
done

$ cvs st index.php

===================================================================
File: index.php Status: Up-to-date

Working revision: 1.9.2.1 <--- 注意这一列
Repository revision: 1.9.2.1 /home/export/sfs2/index.php,v
Sticky Tag: r2002_10_20_branch (branch: 1.9.2)
Sticky Date: (none)
Sticky Options: (none)

存入档案库中,其分支版本跳至 1.9.2.1。目前的状况如下图所示:


                    Figure 1. 分支图

若要由分支回到主干,可下:cvs -q update -A

25. 合并分支及主干

 分支的目的之一是为了修正某些程式的错误,开发中的版本,极可能也有这个 bug 存在,因此通常分支修改完之後,会和主干做合并的动作。

假设 r2002_10_20 推出正式版之後,发现有 bug,为了修正臭虫,於是做了分支 r2002_10_20_branch。以 index.php 为例,设若 bug 是在 index.php 中,且已被修正,今想把它和主干合并,以修正主干的错误,作法如下:

进入工作目录(主干版本)

$ cvs -q update -j r2002_10_20_branch

结果如下:

RCS file: /home/export/sfs2/index.php,v
retrieving revision 1.9
retrieving revision 1.9.2.1
Merging differences between 1.9 and 1.9.2.1 into index.php <--- 注意这一列

$ cvs -q ci -m "合并分支 r2002_10_20_branch 和主干"

结果如下:

Checking in index.php;
/home/export/sfs2/index.php,v <-- index.php
new revision: 1.11; previous revision: 1.10
done

您可以发现分支的内容已合并放入主干版本中,变成 1.11 版了。

26. 取出专案,推出(release)软体版本

 当我们 checkout 出库存专案时,在工作目录下每一个子目录中皆有一个 CVS 资讯目录,但我们要推出正式版本的软体,不希望把这些 CVS 目录也打包进去。CVS 有提供一个动作命令,用来取出不含控制讯息的整份专案。

作法如下:

cvs -q export -r 标记 -d 软体目录名称 专案名称

例:

cvs -q export -r r2002_10_20 -d sfs2.1 sfs2

注:-d 是指定要将取出的专案放在一个新的目录之中,这个新的目录名称由您自取,通常和推出的软体发行版本有关,比如我这里把它命为 2.1 版,所以取名为 sfs2.1,也可以取名为 sfs-3.2.1、foo-1.5.1 等等,这由您自行决定。

上述会在目前的目录中,产生 sfs2.1 的目录,将 sfs2 的整份专案放置其中,您只要将该目录予以打包压缩,即可放上网站供人下载。

结果如下:

$ ls -F sfs2.1

admin/ images/ install.php Readme.txt* student/ themes/
COPYING.txt* include/ login.php* rlogin.php* studentreg/ upgrade/
education/ index.php* person/ school/ teacher/ upgrade.txt*

$ tar cvzf sfs2.1.tar.gz sfs2.1

27. 关键字展开

 CVS 提供许多关键字展开功能(keyword),当您 checkin 存入档案库时,CVS 会自动填入相关资讯,方便您备忘管理之用。通常我们将它摆放在程式码的注解中或说明文件的档头档尾。

常用的关键字有:

$Author$

$Date$

$Header$

$Id$

$Locker$

$Name$

$RCSfile$

$Revision$

$Source$

$State$

$Log$

我最喜欢用的是 $Id$,底下是一个简单的用例:

未 checkin 前,程式码如下:

<?php
//--------------------------------------------------------------------//
// 名称: 登入查验程式
// 版本: $Id$
//--------------------------------------------------------------------//
include_once("./include/init_config.php");
....以下省略....

checkin 之後,程式码中的关键字自动会展开如下:

<?php
//--------------------------------------------------------------------//
// 名称: 登入查验程式
// 版本: $Id: CN.php,v 1.1.1.1 2002/07/06 06:29:42 ols3 Exp $
//--------------------------------------------------------------------//
include_once("./include/init_config.php");
....以下省略....

这些关键字展开的内容,CVS 会自动维护。

28. 二进位档的处理

 由於 CVS 会自动对 checkin 存入的档案做 1.关键字展开 2. 换列字元转换,因此,若要存入的档案是二进位档,应该把这二个动作关掉。

关掉的方法是加上 -kb 的选项,如下所示:

cvs add -kb 档案名称

cvs ci -m "记录讯息" 档案名称

若您只是想关掉 "关键字展开",请加上 -ko 的选项。

29. CVS manpage

 以下是 cvs 的 manpage:

NAME
cvs - Concurrent Versions System

SYNOPSIS
cvs [ cvs_options ]
cvs_command [ command_options ] [ command_args ]

NOTE
This manpage is a summary of some of the features of cvs
but for more in-depth documentation, consult the Ced?
erqvist manual (as described in the SEE ALSO section of
this manpage).

DESCRIPTION
CVS is a version control system, which allows you to keep
old versions of files (usually source code), keep a log of
who, when, and why changes occurred, etc., like RCS or
SCCS. Unlike the simpler systems, CVS does not just oper?
ate on one file at a time or one directory at a time, but
operates on hierarchical collections of directories con?
sisting of version controlled files. CVS helps to manage
releases and to control the concurrent editing of source
files among multiple authors. CVS allows triggers to
enable/log/control various operations and works well over
a wide area network.

cvs keeps a single copy of the master sources. This copy
is called the source ``repository''; it contains all the
information to permit extracting previous software
releases at any time based on either a symbolic revision
tag, or a date in the past.

ESSENTIAL COMMANDS
cvs provides a rich variety of commands (cvs_command in
the Synopsis), each of which often has a wealth of
options, to satisfy the many needs of source management in
distributed environments. However, you don't have to mas?
ter every detail to do useful work with cvs; in fact, five
commands are sufficient to use (and contribute to) the
source repository.

cvs checkout modules...
A necessary preliminary for most cvs work: creates
your private copy of the source for modules (named
collections of source; you can also use a path rel?
ative to the source repository here). You can work
with this copy without interfering with others'
work. At least one subdirectory level is always
created.

cvs update
Execute this command from within your private
source directory when you wish to update your
copies of source files from changes that other
developers have made to the source in the reposi?
tory.

cvs add file...
Use this command to enroll new files in cvs records
of your working directory. The files will be added
to the repository the next time you run `cvs
commit'. Note: You should use the `cvs import'
command to bootstrap new sources into the source
repository. `cvs add' is only used for new files
to an already checked-out module.

cvs remove file...
Use this command (after erasing any files listed)
to declare that you wish to eliminate files from
the repository. The removal does not affect others
until you run `cvs commit'.

cvs commit file...
Use this command when you wish to ``publish'' your
changes to other developers, by incorporating them
in the source repository.

OPTIONS
The cvs command line can include cvs_options, which apply
to the overall cvs program; a cvs_command, which specifies
a particular action on the source repository; and com?
mand_options and command_arguments to fully specify what
the cvs_command will do.

Warning: you must be careful of precisely where you place
options relative to the cvs_command. The same option can
mean different things depending on whether it is in the
cvs_options position (to the left of a cvs command) or in
the command_options position (to the right of a cvs com?
mand).

There are only two situations where you may omit cvs_com?
mand: `cvs -H' or `cvs --help' elicits a list of available
commands, and `cvs -v' or `cvs --version' displays version
information on cvs itself.


CVS OPTIONS
As of release 1.6, cvs supports GNU style long options as
well as short options. Only a few long options are cur?
rently supported, these are listed in brackets after the
short options whose functions they duplicate.

Use these options to control the overall cvs program:

-H [ --help ]
Display usage information about the specified
cvs_command (but do not actually execute the com?
mand). If you don't specify a command name, `cvs
-H' displays a summary of all the commands avail?
able.

-Q Causes the command to be really quiet; the command
will generate output only for serious problems.

-q Causes the command to be somewhat quiet; informa?
tional messages, such as reports of recursion
through subdirectories, are suppressed.

-b bindir
Use bindir as the directory where RCS programs are
located (CVS 1.9 and older). Overrides the setting
of the RCSBIN environment variable. This value
should be specified as an absolute pathname.


-d CVS_root_directory
Use CVS_root_directory as the root directory path?
name of the master source repository. Overrides
the setting of the CVSROOT environment variable.
This value should be specified as an absolute path?
name.

-e editor
Use editor to enter revision log information.
Overrides the setting of the CVSEDITOR, VISUAL, and
EDITOR environment variables.

-f Do not read the cvs startup file (~/.cvsrc).

-l Do not log the cvs_command in the command history
(but execute it anyway). See the description of
the history command for information on command his?
tory.

-n Do not change any files. Attempt to execute the
cvs_command, but only to issue reports; do not
remove, update, or merge any existing files, or
create any new files.

-t Trace program execution; display messages showing
the steps of cvs activity. Particularly useful
with -n to explore the potential impact of an unfa?
miliar command.

-r Makes new working files read-only. Same effect as
if the CVSREAD environment variable is set.

-v [ --version ]
Displays version and copyright information for cvs.

-w Makes new working files read-write (default).
Overrides the setting of the CVSREAD environment
variable.

-x Encrypt all communication between the client and
the server. As of this writing, this is only
implemented when using a Kerberos connection.

-z compression-level
When transferring files across the network use gzip
with compression level compression-level to com?
press and de-compress data as it is transferred.
Requires the presence of the GNU gzip program in
the current search path at both ends of the link.

USAGE
Except when requesting general help with `cvs -H', you
must specify a cvs_command to cvs to select a specific
release control function to perform. Each cvs command
accepts its own collection of options and arguments. How?
ever, many options are available across several commands.
You can display a usage summary for each command by speci?
fying the -H option with the command.

CVS STARTUP FILE
Normally, when CVS starts up, it reads the .cvsrc file
from the home directory of the user reading it. This
startup procedure can be turned off with the -f flag.

The .cvsrc file lists CVS commands with a list of argu?
ments, one command per line. For example, the following
line in .cvsrc:

diff -c

will mean that the `cvs diff' command will always be
passed the -c option in addition to any other options that
are specified in the command line (in this case it will
have the effect of producing context sensitive diffs for
all executions of `cvs diff' ).

CVS COMMAND SUMMARY
Here are brief descriptions of all the cvs commands:

add Add a new file or directory to the repository,
pending a `cvs commit' on the same file. Can only
be done from within sources created by a previous
`cvs checkout' invocation. Use `cvs import' to
place whole new hierarchies of sources under cvs
control. (Does not directly affect repository;
changes working directory.)

admin Execute control functions on the source repository.
(Changes repository directly; uses working direc?
tory without changing it.)

checkout
Make a working directory of source files for edit?
ing. (Creates or changes working directory.)

commit Apply to the source repository changes, additions,
and deletions from your working directory.
(Changes repository.)

diff Show differences between files in working directory
and source repository, or between two revisions in
source repository. (Does not change either reposi?
tory or working directory.)

export Prepare copies of a set of source files for ship?
ment off site. Differs from `cvs checkout' in that
no cvs administrative directories are created (and
therefore `cvs commit' cannot be executed from a
directory prepared with `cvs export'), and a sym?
bolic tag must be specified. (Does not change
repository; creates directory similar to working
directories).

history
Show reports on cvs commands that you or others
have executed on a particular file or directory in
the source repository. (Does not change repository
or working directory.) History logs are kept only
if enabled by creation of the
`$CVSROOT/CVSROOT/history' file; see cvs(5).

import Incorporate a set of updates from off-site into the
source repository, as a ``vendor branch''.
(Changes repository.)

init Initialize a repository by adding the CVSROOT sub?
directory and some default control files. You must
use this command or initialize the repository in
some other way before you can use it.

log Display log information. (Does not change reposi?
tory or working directory.)

rdiff Prepare a collection of diffs as a patch file
between two releases in the repository. (Does not
change repository or working directory.)

release
Cancel a `cvs checkout', abandoning any changes.
(Can delete working directory; no effect on reposi?
tory.)

remove Remove files from the source repository, pending a
`cvs commit' on the same files. (Does not directly
affect repository; changes working directory.)

rtag Explicitly specify a symbolic tag for particular
revisions of files in the source repository. See
also `cvs tag'. (Changes repository directly; does
not require or affect working directory.)

status Show current status of files: latest version, ver?
sion in working directory, whether working version
has been edited and, optionally, symbolic tags in
the RCS file. (Does not change repository or work?
ing directory.)

tag Specify a symbolic tag for files in the repository.
By default, tags the revisions that were last syn?
chronized with your working directory. (Changes
repository directly; uses working directory without
changing it.)
update Bring your working directory up to date with
changes from the repository. Merges are performed
automatically when possible; a warning is issued if
manual resolution is required for conflicting
changes. (Changes working directory; does not
change repository.)

COMMON COMMAND OPTIONS
This section describes the command_options that are avail?
able across several cvs commands. Not all commands sup?
port all of these options; each option is only supported
for commands where it makes sense. However, when a com?
mand has one of these options you can count on the same
meaning for the option as in other commands. (Other com?
mand options, which are listed with the individual com?
mands, may have different meanings from one cvs command to
another.) Warning: the history command is an exception;
it supports many options that conflict even with these
standard options.

-D date_spec
Use the most recent revision no later than
date_spec (a single argument, date description
specifying a date in the past). A wide variety of
date formats are supported, in particular ISO
("1972-09-24 20:05") or Internet ("24 Sep 1972
20:05"). The date_spec is interpreted as being in
the local timezone, unless a specific timezone is
specified. The specification is ``sticky'' when
you use it to make a private copy of a source file;
that is, when you get a working file using -D, cvs
records the date you specified, so that further
updates in the same directory will use the same
date (unless you explicitly override it; see the
description of the update command). -D is
available with the checkout, diff, history, export,
rdiff, rtag, and update commands. Examples of
valid date specifications include:
1 month ago
2 hours ago
400000 seconds ago
last year
last Monday
yesterday
a fortnight ago
3/31/92 10:00:07 PST
January 23, 1987 10:05pm
22:00 GMT

-f When you specify a particular date or tag to cvs
commands, they normally ignore files that do not
contain the tag (or did not exist on the date) that
you specified. Use the -f option if you want files
retrieved even when there is no match for the tag
or date. (The most recent version is used in this
situation.) -f is available with these commands:
checkout, export, rdiff, rtag, and update.

-k kflag
Alter the default processing of keywords. The -k
option is available with the add, checkout, diff,
export, rdiff, and update commands. Your kflag
specification is ``sticky'' when you use it to cre?
ate a private copy of a source file; that is, when
you use this option with the checkout or update
commands, cvs associates your selected kflag with
the file, and continues to use it with future
update commands on the same file until you specify
otherwise.

Some of the more useful kflags are -ko and -kb (for
binary files), and -kv which is useful for an
export where you wish to retain keyword information
after an import at some other site.

-l Local; run only in current working directory,
rather than recurring through subdirectories.
Available with the following commands: checkout,
commit, diff, export, remove, rdiff, rtag, status,
tag, and update. Warning: this is not the same as
the overall `cvs -l' option, which you can specify
to the left of a cvs command!

-n Do not run any checkout/commit/tag/update program.
(A program can be specified to run on each of these
activities, in the modules database; this option
bypasses it.) Available with the checkout, commit,
export, and rtag commands. Warning: this is not
the same as the overall `cvs -n' option, which you
can specify to the left of a cvs command!

-P Prune (remove) directories that are empty after
being updated, on checkout, or update. Normally,
an empty directory (one that is void of revision-
controlled files) is left alone. Specifying -P
will cause these directories to be silently removed
from your checked-out sources. This does not
remove the directory from the repository, only from
your checked out copy. Note that this option is
implied by the -r or -D options of checkout and
export.

-p Pipe the files retrieved from the repository to
standard output, rather than writing them in the
current directory. Available with the checkout and
update commands.

-r tag Use the revision specified by the tag argument
instead of the default ``head'' revision. As well
as arbitrary tags defined with the tag or rtag com?
mand, two special tags are always available: `HEAD'
refers to the most recent version available in the
repository, and `BASE' refers to the revision you
last checked out into the current working direc?
tory.

The tag specification is ``sticky'' when you use
this option with `cvs checkout' or `cvs update' to
make your own copy of a file: cvs remembers the tag
and continues to use it on future update commands,
until you specify otherwise. tag can be either a
symbolic or numeric tag. Specifying the -q global
option along with the -r command option is often
useful, to suppress the warning messages when the
RCS file does not contain the specified tag. -r is
available with the checkout, commit, diff, history,
export, rdiff, rtag, and update commands. Warning:
this is not the same as the overall `cvs -r'
option, which you can specify to the left of a cvs
command!

CVS COMMANDS
Here (finally) are details on all the cvs commands and the
options each accepts. The summary lines at the top of
each command's description highlight three kinds of
things:

Command Options and Arguments
Special options are described in detail below;
common command options may appear only in the
summary line.

Working Directory, or Repository?
Some cvs commands require a working directory to
operate; some require a repository. Also, some
commands change the repository, some change the
working directory, and some change nothing.

Synonyms
Many commands have synonyms, which you may find
easier to remember (or type) than the principal
name.


add [-k kflag] [-m 'message'] files...
Requires: repository, working directory.
Changes: working directory.
Synonym: new
Use the add command to create a new file or direc?
tory in the source repository. The files or direc?
tories specified with add must already exist in the
current directory (which must have been created
with the checkout command). To add a whole new
directory hierarchy to the source repository (for
example, files received from a third-party vendor),
use the `cvs import' command instead.

If the argument to `cvs add' refers to an immediate
sub-directory, the directory is created at the cor?
rect place in the source repository, and the neces?
sary cvs administration files are created in your
working directory. If the directory already exists
in the source repository, `cvs add' still creates
the administration files in your version of the
directory. This allows you to use `cvs add' to add
a particular directory to your private sources even
if someone else created that directory after your
checkout of the sources. You can do the following:

example% mkdir new_directory
example% cvs add new_directory
example% cvs update new_directory

An alternate approach using `cvs update' might be:

example% cvs update -d new_directory

(To add any available new directories to your work?
ing directory, it's probably simpler to use `cvs
checkout' or `cvs update -d'.)

The added files are not placed in the source repos?
itory until you use `cvs commit' to make the change
permanent. Doing a `cvs add' on a file that was
removed with the `cvs remove' command will resur?
rect the file, if no `cvs commit' command inter?
vened.

You will have the opportunity to specify a logging
message, as usual, when you use `cvs commit' to
make the new file permanent. If you'd like to have
another logging message associated with just cre?
ation of the file (for example, to describe the
file's purpose), you can specify it with the `-m
message' option to the add command.

The `-k kflag' option specifies the default way
that this file will be checked out. The `kflag'
argument is stored in the RCS file and can be
changed with `cvs admin'. Specifying `-ko' is use?
ful for checking in binaries that shouldn't have
keywords expanded.

admin [rcs-options] files...
Requires: repository, working directory.
Changes: repository.
Synonym: rcs
This is the cvs interface to assorted administra?
tive facilities, similar to rcs(1). This command
works recursively, so extreme care should be used.

checkout [options] modules...
Requires: repository.
Changes: working directory.
Synonyms: co, get
Make a working directory containing copies of the
source files specified by modules. You must exe?
cute `cvs checkout' before using most of the other
cvs commands, since most of them operate on your
working directory.

modules are either symbolic names (themselves
defined as the module `modules' in the source
repository; see cvs(5)) for some collection of
source directories and files, or paths to directo?
ries or files in the repository.

Depending on the modules you specify, checkout may
recursively create directories and populate them
with the appropriate source files. You can then
edit these source files at any time (regardless of
whether other software developers are editing their
own copies of the sources); update them to include
new changes applied by others to the source reposi?
tory; or commit your work as a permanent change to
the repository.

Note that checkout is used to create directories.
The top-level directory created is always added to
the directory where checkout is invoked, and usu?
ally has the same name as the specified module. In
the case of a module alias, the created sub-direc?
tory may have a different name, but you can be sure
that it will be a sub-directory, and that checkout
will show the relative path leading to each file as
it is extracted into your private work area (unless
you specify the -Q global option).

Running `cvs checkout' on a directory that was
already built by a prior checkout is also permit?
ted, and has the same effect as specifying the -d
option to the update command described below.

The options permitted with `cvs checkout' include
the standard command options -P, -f, -k kflag , -l,
-n, -p, -r tag, and -D date.

In addition to those, you can use these special
command options with checkout:

Use the -A option to reset any sticky tags, dates,
or -k options. (If you get a working file using
one of the -r, -D, or -k options, cvs remembers the
corresponding tag, date, or kflag and continues
using it on future updates; use the -A option to
make cvs forget these specifications, and retrieve
the ``head'' version of the file).

The -j branch option merges the changes made
between the resulting revision and the revision
that it is based on (e.g., if the tag refers to a
branch, cvs will merge all changes made in that
branch into your working file).

With two -j options, cvs will merge in the changes
between the two respective revisions. This can be
used to ``remove'' a certain delta from your work?
ing file.

In addition, each -j option can contain on optional
date specification which, when used with branches,
can limit the chosen revision to one within a spe?
cific date. An optional date is specified by
adding a colon (:) to the tag. An example might be
what `cvs import' tells you to do when you have
just imported sources that have conflicts with
local changes:

example% cvs checkout -jTAG:yesterday -jTAG module

Use the -N option with `-d dir' to avoid shortening
module paths in your working directory. (Nor?
mally, cvs shortens paths as much as possible when
you specify an explicit target directory.)

Use the -c option to copy the module file, sorted,
to the standard output, instead of creating or mod?
ifying any files or directories in your working
directory.

Use the -d dir option to create a directory called
dir for the working files, instead of using the
module name. Unless you also use -N, the paths
created under dir will be as short as possible.

Use the -s option to display per-module status
information stored with the -s option within the
modules file.

commit [-lnR] [-m 'log_message' | -f file] [-r
revision] [files...]
Requires: working directory, repository.
Changes: repository.
Synonym: ci
Use `cvs commit' when you want to incorporate
changes from your working source files into the
general source repository.

If you don't specify particular files to commit,
all of the files in your working current directory
are examined. commit is careful to change in the
repository only those files that you have really
changed. By default (or if you explicitly specify
the -R option), files in subdirectories are also
examined and committed if they have changed; you
can use the -l option to limit commit to the cur?
rent directory only. Sometimes you may want to
force a file to be committed even though it is
unchanged; this is achieved with the -f flag, which
also has the effect of disabling recursion (you can
turn it back on with -R of course).

commit verifies that the selected files are up to
date with the current revisions in the source
repository; it will notify you, and exit without
committing, if any of the specified files must be
made current first with `cvs update'. commit does
not call the update command for you, but rather
leaves that for you to do when the time is right.

When all is well, an editor is invoked to allow you
to enter a log message that will be written to one
or more logging programs and placed in the source
repository file. You can instead specify the log
message on the command line with the -m option,
thus suppressing the editor invocation, or use the
-F option to specify that the argument file con?
tains the log message.

The -r option can be used to commit to a particular
symbolic or numeric revision. For example, to
bring all your files up to the revision ``3.0''
(including those that haven't changed), you might
do:

example% cvs commit -r3.0

cvs will only allow you to commit to a revision
that is on the main trunk (a revision with a single
dot). However, you can also commit to a branch
revision (one that has an even number of dots) with
the -r option. To create a branch revision, one
typically use the -b option of the rtag or tag com?
mands. Then, either checkout or update can be used
to base your sources on the newly created branch.
From that point on, all commit changes made within
these working sources will be automatically added
to a branch revision, thereby not perturbing main-
line development in any way. For example, if you
had to create a patch to the 1.2 version of the
product, even though the 2.0 version is already
under development, you might do:

example% cvs rtag -b -rFCS1_2 FCS1_2_Patch product_module
example% cvs checkout -rFCS1_2_Patch product_module
example% cd product_module
[[ hack away ]]
example% cvs commit

Say you have been working on some extremely experi?
mental software, based on whatever revision you
happened to checkout last week. If others in your
group would like to work on this software with you,
but without disturbing main-line development, you
could commit your change to a new branch. Others
can then checkout your experimental stuff and uti?
lize the full benefit of cvs conflict resolution.
The scenario might look like:

example% cvs tag -b EXPR1
example% cvs update -rEXPR1
[[ hack away ]]
example% cvs commit

Others would simply do `cvs checkout -rEXPR1
whatever_module' to work with you on the experimen?
tal change.

diff [-kl] [rcsdiff_options] [[-r rev1 | -D date1] [-r
rev2 | -D date2]] [files...]
Requires: working directory, repository.
Changes: nothing.
You can compare your working files with revisions
in the source repository, with the `cvs diff' com?
mand. If you don't specify a particular revision,
your files are compared with the revisions they
were based on. You can also use the standard cvs
command option -r to specify a particular revision
to compare your files with. Finally, if you use -r
twice, you can see differences between two revi?
sions in the repository. You can also specify -D
options to diff against a revision in the past.
The -r and -D options can be mixed together with at
most two options ever specified.

See rcsdiff(1) for a list of other accepted
options.

If you don't specify any files, diff will display
differences for all those files in the current
directory (and its subdirectories, unless you use
the standard option -l) that differ from the corre?
sponding revision in the source repository (i.e.
files that you have changed), or that differ from
the revision specified.

export [-flNnQq] -r rev|-D date [-d dir] [-k kflag]
module...
Requires: repository.
Changes: current directory.
This command is a variant of `cvs checkout'; use it
when you want a copy of the source for module with?
out the cvs administrative directories. For exam?
ple, you might use `cvs export' to prepare source
for shipment off-site. This command requires that
you specify a date or tag (with -D or -r), so that
you can count on reproducing the source you ship to
others.

The only non-standard options are `-d dir' (write
the source into directory dir) and `-N' (don't
shorten module paths). These have the same mean?
ings as the same options in `cvs checkout'.

The -kv option is useful when export is used. This
causes any keywords to be expanded such that an
import done at some other site will not lose the
keyword revision information. Other kflags may be
used with `cvs export' and are described in co(1).

history [-report] [-flags] [-options args] [files...]
Requires: the file `$CVSROOT/CVSROOT/history'
Changes: nothing.
cvs keeps a history file that tracks each use of
the checkout, commit, rtag, update, and release
commands. You can use `cvs history' to display
this information in various formats.

Warning: `cvs history' uses `-f', `-l', `-n', and
`-p' in ways that conflict with the descriptions in
COMMON COMMAND OPTIONS.

Several options (shown above as -report) control
what kind of report is generated:

-c Report on each time commit was used (i.e., each
time the repository was modified).

-m module
Report on a particular module. (You can mean?
ingfully use -m more than once on the command
line.)

-o Report on checked-out modules.

-T Report on all tags.

-x type
Extract a particular set of record types X from
the cvs history. The types are indicated by
single letters, which you may specify in combi?
nation. Certain commands have a single record
type: checkout (type `O'), release (type `F'),
and rtag (type `T'). One of four record types
may result from an update: `W', when the working
copy of a file is deleted during update (because
it was gone from the repository); `U', when a
working file was copied from the repository;
`G', when a merge was necessary and it suc?
ceeded; and 'C', when a merge was necessary but
collisions were detected (requiring manual merg?
ing). Finally, one of three record types
results from commit: `M', when a file was modi?
fied; `A', when a file is first added; and `R',
when a file is removed.

-e Everything (all record types); equivalent to
specifying `-xMACFROGWUT'.

-z zone
Use time zone zone when outputting history
records. The zone name LT stands for local
time; numeric offsets stand for hours and min?
utes ahead of UTC. For example, +0530 stands
for 5 hours and 30 minutes ahead of (i.e. east
of) UTC.

The options shown as -flags constrain the report
without requiring option arguments:

-a Show data for all users (the default is to show
data only for the user executing `cvs history').

-l Show last modification only.

-w Show only the records for modifications done
from the same working directory where `cvs
history' is executing.

The options shown as -options args constrain the
report based on an argument:

-b str
Show data back to a record containing the string
str in either the module name, the file name, or
the repository path.

-D date
Show data since date.

-p repository
Show data for a particular source repository
(you can specify several -p options on the same
command line).

-r rev
Show records referring to revisions since the
revision or tag named rev appears in individual
RCS files. Each RCS file is searched for the
revision or tag.

-t tag
Show records since tag tag was last added to the
history file. This differs from the -r flag
above in that it reads only the history file,
not the RCS files, and is much faster.

-u name
Show records for user name.


import [-options] repository vendortag releasetag...
Requires: Repository, source distribution
directory.
Changes: repository.
Use `cvs import' to incorporate an entire source
distribution from an outside source (e.g., a source
vendor) into your source repository directory. You
can use this command both for initial creation of a
repository, and for wholesale updates to the module
form the outside source.

The repository argument gives a directory name (or
a path to a directory) under the CVS root directory
for repositories; if the directory did not exist,
import creates it.

When you use import for updates to source that has
been modified in your source repository (since a
prior import), it will notify you of any files that
conflict in the two branches of development; use
`cvs checkout -j' to reconcile the differences, as
import instructs you to do.

By default, certain file names are ignored during
`cvs import': names associated with CVS administra?
tion, or with other common source control systems;
common names for patch files, object files, archive
files, and editor backup files; and other names
that are usually artifacts of assorted utilities.
For an up to date list of ignored file names, see
the Cederqvist manual (as described in the SEE ALSO
section of this manpage).

The outside source is saved in a first-level
branch, by default `1.1.1'. Updates are leaves of
this branch; for example, files from the first
imported collection of source will be revision
`1.1.1.1', then files from the first imported
update will be revision `1.1.1.2', and so on.

At least three arguments are required. repository
is needed to identify the collection of source.
vendortag is a tag for the entire branch (e.g., for
`1.1.1'). You must also specify at least one
releasetag to identify the files at the leaves cre?
ated each time you execute `cvs import'.

One of the standard cvs command options is avail?
able: -m message. If you do not specify a logging
message with -m, your editor is invoked (as with
commit) to allow you to enter one.

There are three additional special options.

Use `-d' to specify that each file's time of last
modification should be used for the checkin date
and time.

Use `-b branch' to specify a first-level branch
other than `1.1.1'.

Use `-I name' to specify file names that should be
ignored during import. You can use this option
repeatedly. To avoid ignoring any files at all
(even those ignored by default), specify `-I !'.

log [-l] rlog-options [files...]
Requires: repository, working directory.
Changes: nothing.
Synonym: rlog
Display log information for files. Among the more
useful options are -h to display only the header
(including tag definitions, but omitting most of
the full log); -r to select logs on particular
revisions or ranges of revisions; and -d to select
particular dates or date ranges. See rlog(1) for
full explanations. This command is recursive by
default, unless the -l option is specified.

rdiff [-flags] [-V vn] [-r t|-D d [-r t2|-D d2]]
modules...
Requires: repository.
Changes: nothing.
Synonym: patch
Builds a Larry Wall format patch(1) file between
two releases, that can be fed directly into the
patch program to bring an old release up-to-date
with the new release. (This is one of the few cvs
commands that operates directly from the reposi?
tory, and doesn't require a prior checkout.) The
diff output is sent to the standard output device.
You can specify (using the standard -r and -D
options) any combination of one or two revisions or
dates. If only one revision or date is specified,
the patch file reflects differences between that
revision or date and the current ``head'' revisions
in the RCS file.

Note that if the software release affected is con?
tained in more than one directory, then it may be
necessary to specify the -p option to the patch
command when patching the old sources, so that
patch is able to find the files that are located in
other directories.

The standard option flags -f, and -l are available
with this command. There are also several special
options flags:

If you use the -s option, no patch output is pro?
duced. Instead, a summary of the changed or added
files between the two releases is sent to the stan?
dard output device. This is useful for finding
out, for example, which files have changed between
two dates or revisions.

If you use the -t option, a diff of the top two
revisions is sent to the standard output device.
This is most useful for seeing what the last change
to a file was.

If you use the -u option, the patch output uses the
newer ``unidiff'' format for context diffs.

You can use -c to explicitly specify the `diff -c'
form of context diffs (which is the default), if
you like.

release [-dQq] modules...
Requires: Working directory.
Changes: Working directory, history log.
This command is meant to safely cancel the effect
of `cvs checkout'.' Since cvs doesn't lock files,
it isn't strictly necessary to use this command.
You can always simply delete your working direc?
tory, if you like; but you risk losing changes you
may have forgotten, and you leave no trace in the
cvs history file that you've abandoned your check?
out.

Use `cvs release' to avoid these problems. This
command checks that no un-committed changes are
present; that you are executing it from immediately
above, or inside, a cvs working directory; and that
the repository recorded for your files is the same
as the repository defined in the module database.

If all these conditions are true, `cvs release'
leaves a record of its execution (attesting to your
intentionally abandoning your checkout) in the cvs
history log.

You can use the -d flag to request that your work?
ing copies of the source files be deleted if the
release succeeds.

remove [-lR] [files...]
Requires: Working directory.
Changes: Working directory.
Synonyms: rm, delete
Use this command to declare that you wish to remove
files from the source repository. Like most cvs
commands, `cvs remove' works on files in your work?
ing directory, not directly on the repository. As
a safeguard, it also requires that you first erase
the specified files from your working directory.

The files are not actually removed until you apply
your changes to the repository with commit; at that
point, the corresponding RCS files in the source
repository are moved into the `Attic' directory
(also within the source repository).

This command is recursive by default, scheduling
all physically removed files that it finds for
removal by the next commit. Use the -l option to
avoid this recursion, or just specify that actual
files that you wish remove to consider.

rtag [-falnRQq] [-b] [-d] [-r tag | -D date] sym?
bolic_tag modules...
Requires: repository.
Changes: repository.
Synonym: rfreeze
You can use this command to assign symbolic tags to
particular, explicitly specified source versions in
the repository. `cvs rtag' works directly on the
repository contents (and requires no prior check?
out). Use `cvs tag' instead, to base the selection
of versions to tag on the contents of your working
directory.

In general, tags (often the symbolic names of soft?
ware distributions) should not be removed, but the
-d option is available as a means to remove com?
pletely obsolete symbolic names if necessary (as
might be the case for an Alpha release, say).

`cvs rtag' will not move a tag that already exists.
With the -F option, however, `cvs rtag' will re-
locate any instance of symbolic_tag that already
exists on that file to the new repository versions.
Without the -F option, attempting to use `cvs rtag'
to apply a tag that already exists on that file
will produce an error message.

The -b option makes the tag a ``branch'' tag,
allowing concurrent, isolated development. This is
most useful for creating a patch to a previously
released software distribution.

You can use the standard -r and -D options to tag
only those files that already contain a certain
tag. This method would be used to rename a tag:
tag only the files identified by the old tag, then
delete the old tag, leaving the new tag on exactly
the same files as the old tag.

rtag executes recursively by default, tagging all
subdirectories of modules you specify in the argu?
ment. You can restrict its operation to top-level
directories with the standard -l option; or you can
explicitly request recursion with -R.

The modules database can specify a program to exe?
cute whenever a tag is specified; a typical use is
to send electronic mail to a group of interested
parties. If you want to bypass that program, use
the standard -n option.

Use the -a option to have rtag look in the `Attic'
for removed files that contain the specified tag.
The tag is removed from these files, which makes it
convenient to re-use a symbolic tag as development
continues (and files get removed from the up-coming
distribution).

status [-lRqQ] [-v] [files...]
Requires: working directory, repository.
Changes: nothing.
Display a brief report on the current status of
files with respect to the source repository,
including any ``sticky'' tags, dates, or -k
options. (``Sticky'' options will restrict how
`cvs update' operates until you reset them; see the
description of `cvs update -A...'.)

You can also use this command to anticipate the
potential impact of a `cvs update' on your working
source directory. If you do not specify any files
explicitly, reports are shown for all files that
cvs has placed in your working directory. You can
limit the scope of this search to the current
directory itself (not its subdirectories) with the
standard -l option flag; or you can explicitly
request recursive status reports with the -R
option.

The -v option causes the symbolic tags for the RCS
file to be displayed as well.

tag [-lQqR] [-F] [-b] [-d] [-r tag | -D date] [-f] sym?
bolic_tag [files...]
Requires: working directory, repository.
Changes: repository.
Synonym: freeze
Use this command to assign symbolic tags to the
nearest repository versions to your working
sources. The tags are applied immediately to the
repository, as with rtag.

One use for tags is to record a ``snapshot'' of the
current sources when the software freeze date of a
project arrives. As bugs are fixed after the
freeze date, only those changed sources that are to
be part of the release need be re-tagged.

The symbolic tags are meant to permanently record
which revisions of which files were used in creat?
ing a software distribution. The checkout, export
and update commands allow you to extract an exact
copy of a tagged release at any time in the future,
regardless of whether files have been changed,
added, or removed since the release was tagged.

You can use the standard -r and -D options to tag
only those files that already contain a certain
tag. This method would be used to rename a tag:
tag only the files identified by the old tag, then
delete the old tag, leaving the new tag on exactly
the same files as the old tag.

Specifying the -f flag in addition to the -r or -D
flags will tag those files named on the command
line even if they do not contain the old tag or did
not exist on the specified date.

By default (without a -r or -D flag) the versions
to be tagged are supplied implicitly by the cvs
records of your working files' history rather than
applied explicitly.

If you use `cvs tag -d symbolic_tag...', the sym?
bolic tag you specify is deleted instead of being
added. Warning: Be very certain of your ground
before you delete a tag; doing this effectively
discards some historical information, which may
later turn out to have been valuable.

`cvs tag' will not move a tag that already exists.
With the -F option, however, `cvs tag' will re-
locate any instance of symbolic_tag that already
exists on that file to the new repository versions.
Without the -F option, attempting to use `cvs tag'
to apply a tag that already exists on that file
will produce an error message.

The -b option makes the tag a ``branch'' tag,
allowing concurrent, isolated development. This is
most useful for creating a patch to a previously
released software distribution.

Normally, tag executes recursively through subdi?
rectories; you can prevent this by using the stan?
dard -l option, or specify the recursion explicitly
by using -R.

update [-ACdflPpQqR] [-d] [-r tag|-D date] files...
Requires: repository, working directory.
Changes: working directory.
After you've run checkout to create your private
copy of source from the common repository, other
developers will continue changing the central
source. From time to time, when it is convenient
in your development process, you can use the update
command from within your working directory to rec?
oncile your work with any revisions applied to the
source repository since your last checkout or
update.

update keeps you informed of its progress by print?
ing a line for each file, prefaced with one of the
characters `U A R M C ?' to indicate the status of
the file:

U file The file was brought up to date with respect to
the repository. This is done for any file that
exists in the repository but not in your source,
and for files that you haven't changed but are
not the most recent versions available in the
repository.

A file The file has been added to your private copy of
the sources, and will be added to the source
repository when you run `cvs commit' on the
file. This is a reminder to you that the file
needs to be committed.

R file The file has been removed from your private copy
of the sources, and will be removed from the
source repository when you run `cvs commit' on
the file. This is a reminder to you that the
file needs to be committed.

M file The file is modified in your working directory.
`M' can indicate one of two states for a file
you're working on: either there were no modifi?
cations to the same file in the repository, so
that your file remains as you last saw it; or
there were modifications in the repository as
well as in your copy, but they were merged suc?
cessfully, without conflict, in your working
directory.

C file A conflict was detected while trying to merge
your changes to file with changes from the
source repository. file (the copy in your work?
ing directory) is now the result of merging the
two versions; an unmodified copy of your file is
also in your working directory, with the name
`.#file.version', where version is the revision
that your modified file started from. (Note
that some systems automatically purge files that
begin with `.#' if they have not been accessed
for a few days. If you intend to keep a copy of
your original file, it is a very good idea to
rename it.)

? file file is in your working directory, but does not
correspond to anything in the source repository,
and is not in the list of files for cvs to
ignore (see the description of the -I option).


Use the -A option to reset any sticky tags, dates, or
-k options. (If you get a working copy of a file by
using one of the -r, -D, or -k options, cvs remembers
the corresponding tag, date, or kflag and continues
using it on future updates; use the -A option to make
cvs forget these specifications, and retrieve the
``head'' version of the file).

The -jbranch option merges the changes made between
the resulting revision and the revision that it is
based on (e.g., if the tag refers to a branch, cvs
will merge all changes made in that branch into your
working file).

With two -j options, cvs will merge in the changes
between the two respective revisions. This can be
used to ``remove'' a certain delta from your working
file. E.g., If the file foo.c is based on revision
1.6 and I want to remove the changes made between 1.3
and 1.5, I might do:

example% cvs update -j1.5 -j1.3 foo.c # note the order...

In addition, each -j option can contain on optional
date specification which, when used with branches,
can limit the chosen revision to one within a spe?
cific date. An optional date is specified by adding
a colon (:) to the tag.

-jSymbolic_Tag:Date_Specifier

Use the -d option to create any directories that
exist in the repository if they're missing from the
working directory. (Normally, update acts only on
directories and files that were already enrolled in
your working directory.) This is useful for updating
directories that were created in the repository since
the initial checkout; but it has an unfortunate side
effect. If you deliberately avoided certain directo?
ries in the repository when you created your working
directory (either through use of a module name or by
listing explicitly the files and directories you
wanted on the command line), then updating with -d
will create those directories, which may not be what
you want.

Use -I name to ignore files whose names match name
(in your working directory) during the update. You
can specify -I more than once on the command line to
specify several files to ignore. By default, update
ignores files whose names match certain patterns; for
an up to date list of ignored file names, see the
Cederqvist manual (as described in the SEE ALSO sec?
tion of this manpage).

Use `-I !' to avoid ignoring any files at all.

Use the `-C' option to overwrite locally modified
files with clean copies from the repository (the mod?
ified file is saved in `.#file.revision', however).

The standard cvs command options -f, -k, -l, -P, -p,
and -r are also available with update.

FILES
For more detailed information on cvs supporting files, see
cvs(5).

Files in home directories:

.cvsrc The cvs initialisation file. Lines in this file
can be used to specify default options for each cvs
command. For example the line `diff -c' will
ensure that `cvs diff' is always passed the -c
option in addition to any other options passed on
the command line.

.cvswrappers
Specifies wrappers to be used in addition to those
specified in the CVSROOT/cvswrappers file in the
repository.

Files in working directories:

CVS A directory of cvs administrative files. Do not
delete.

CVS/Entries
List and status of files in your working directory.

CVS/Entries.Backup
A backup of `CVS/Entries'.

CVS/Entries.Static
Flag: do not add more entries on `cvs update'.

CVS/Root
Pathname to the repository ( CVSROOT ) location at
the time of checkout. This file is used instead of
the CVSROOT environment variable if the environment
variable is not set. A warning message will be
issued when the contents of this file and the CVS?
ROOT environment variable differ. The file may be
over-ridden by the presence of the
CVS_IGNORE_REMOTE_ROOT environment variable.

CVS/Repository
Pathname to the corresponding directory in the
source repository.

CVS/Tag
Contains the per-directory ``sticky'' tag or date
information. This file is created/updated when you
specify -r or -D to the checkout or update com?
mands, and no files are specified.

CVS/Checkin.prog
Name of program to run on `cvs commit'.

CVS/Update.prog
Name of program to run on `cvs update'.

Files in source repositories:

$CVSROOT/CVSROOT
Directory of global administrative files for repos?
itory.

CVSROOT/commitinfo,v
Records programs for filtering `cvs commit'
requests.

CVSROOT/cvswrappers,v
Records cvs wrapper commands to be used when check?
ing files into and out of the repository. Wrappers
allow the file or directory to be processed on the
way in and out of CVS. The intended uses are many,
one possible use would be to reformat a C file
before the file is checked in, so all of the code
in the repository looks the same.

CVSROOT/editinfo,v
Records programs for editing/validating `cvs
commit' log entries.

CVSROOT/history
Log file of cvs transactions.

CVSROOT/loginfo,v
Records programs for piping `cvs commit' log
entries.

CVSROOT/modules,v
Definitions for modules in this repository.

CVSROOT/rcsinfo,v
Records pathnames to templates used during a `cvs
commit' operation.

CVSROOT/taginfo,v
Records programs for validating/logging `cvs tag'
and `cvs rtag' operations.

MODULE/Attic
Directory for removed source files.

#cvs.lock
A lock directory created by cvs when doing sensi?
tive changes to the source repository.

#cvs.tfl.pid
Temporary lock file for repository.

#cvs.rfl.pid
A read lock.

#cvs.wfl.pid
A write lock.

ENVIRONMENT VARIABLES
CVSROOT
Should contain the full pathname to the root of the
cvs source repository (where the RCS files are
kept). This information must be available to cvs
for most commands to execute; if CVSROOT is not
set, or if you wish to override it for one invoca?
tion, you can supply it on the command line: `cvs
-d cvsroot cvs_command...' You may not need to set
CVSROOT if your cvs binary has the right path com?
piled in; use `cvs -v' to display all compiled-in
paths.

CVSREAD
If this is set, checkout and update will try hard
to make the files in your working directory read-
only. When this is not set, the default behavior
is to permit modification of your working files.

RCSBIN Specifies the full pathname where to find RCS pro?
grams, such as co(1) and ci(1) (CVS 1.9 and older).


CVSEDITOR
Specifies the program to use for recording log mes?
sages during commit. If not set, the VISUAL and
EDITOR environment variables are tried (in that
order). If neither is set, a system-dependent
default editor (e.g., vi) is used.

CVS_IGNORE_REMOTE_ROOT
If this variable is set then cvs will ignore all
references to remote repositories in the CVS/Root
file.

CVS_RSH
cvs uses the contents of this variable to determine
the name of the remote shell command to use when
starting a cvs server. If this variable is not set
then `rsh' is used.

CVS_SERVER
cvs uses the contents of this variable to determine
the name of the cvs server command. If this vari?
able is not set then `cvs' is used.

CVSWRAPPERS
This variable is used by the `cvswrappers' script
to determine the name of the wrapper file, in addi?
tion to the wrappers defaults contained in the
repository (CVSROOT/cvswrappers) and the user's
home directory (~/.cvswrappers).

AUTHORS
Dick Grune
Original author of the cvs shell script version
posted to comp.sources.unix in the volume6 release
of December, 1986. Credited with much of the cvs
conflict resolution algorithms.

Brian Berliner
Coder and designer of the cvs program itself in
April, 1989, based on the original work done by
Dick.

Jeff Polk
Helped Brian with the design of the cvs module and
vendor branch support and author of the checkin(1)
shell script (the ancestor of `cvs import').

And many others too numerous to mention here.

SEE ALSO
The most comprehensive manual for CVS is Version Manage?
ment with CVS by Per Cederqvist et al. Depending on your
system, you may be able to get it with the info cvs com?
mand or it may be available as cvs.ps (postscript),
cvs.texinfo (texinfo source), or cvs.html.

For CVS updates, more information on documentation, soft?
ware related to CVS, development of CVS, and more, see:
http://www.cyclic.com
http://www.loria.fr/~molli/cvs-index.html

ci(1), co(1), cvs(5), cvsbug(8), diff(1), grep(1),
patch(1), rcs(1), rcsdiff(1), rcsmerge(1), rlog(1).

 

30. CVS 速查

CVS Quick Reference
A CVS command looks like:
cvs [ global_options ] command [ command_options ] [ command_args ]


Global options:
--allow-root=rootdir
Specify legal CVSROOT directory (server only) (not in CVS 1.9 and older).
-a
Authenticate all communication (client only) (not in CVS 1.9 and older).
-b
Specify RCS location (CVS 1.9 and older).
-d root
Specify the CVSROOT.
-e editor
Edit messages with editor.
-f
Do not read the `~/.cvsrc' file.
-H
--help
Print a help message.
-l
Do not log in CVSROOT/history file.
-n
Do not change any files.
-Q
Be really quiet.
-q
Be somewhat quiet.
-r
Make new working files read-only.
-s variable=value
Set a user variable.
-T tempdir
Put temporary files in tempdir.
-t
Trace CVS execution.
-v
--version
Display version and copyright information for CVS.
-w
Make new working files read-write.
-x
Encrypt all communication (client only).
-z gzip-level
Set the compression level (client only).
Keyword expansion modes
-kkv $Id: ref.html,v 1.10 2001/06/15 02:18:18 dprice Exp $

-kkvl $Id: ref.html,v 1.10 2001/06/15 02:18:18 dprice Exp $

-kk $Id: ref.html,v 1.10 2001/06/15 02:18:18 dprice Exp $

-kv info-ref.html,v 1.1 1999/04/14 19:04:02 kingdon Exp

-ko no expansion

-kb no expansion, file is binary


Keywords
$Author: dprice $

$Date: 2001/06/15 02:18:18 $

$Header: /usr/local/tigris/data/helm/cvs/repository/www/www/docs/ref.html,v 1.10 2001/06/15 02:18:18 dprice Exp $

$Id: ref.html,v 1.10 2001/06/15 02:18:18 dprice Exp $

$Locker: $

$Name: $

$RCSfile: ref.html,v $

$Revision: 1.10 $

$Source: /usr/local/tigris/data/helm/cvs/repository/www/www/docs/ref.html,v $

$State: Exp $

$Log: ref.html,v $
Revision 1.10 2001/06/15 02:18:18 dprice
Tidied.


Revision 1.1 1999/04/14 19:04:02 kingdon

By popular demand, want to put the CVS Reference Card on-line.


Commands, command options, and command arguments:
add [options] [files...]
Add a new file/directory.
-k kflag
Set keyword expansion.
-m msg
Set file description.
admin [options] [files...]
Administration of history files in the repository.
-b[rev]
Set default branch.
-cstring
Set comment leader.
-ksubst
Set keyword substitution.
-l[rev]
Lock revision rev, or latest revision.
-mrev:msg
Replace the log message of revision rev with msg.
-orange
Delete revisions from the repository.
-q
Run quietly; do not print diagnostics.
-sstate[:rev]
Set the state.
-t
Set file description from standard input.
-tfile
Set file description from file.
-t-string
Set file description to string.
-u[rev]
Unlock revision rev, or latest revision.
annotate [options] [files...]
Show last revision where each line was modified.
-D date
Annotate the most recent revision no later than date.
-f
Use head revision if tag/date not found.
-l
Local; run only in current working directory.
-R
Operate recursively (default).
-r tag
Annotate revision tag.
checkout [options] modules...
Get a copy of the sources.
-A
Reset any sticky tags/date/options.
-c
Output the module database.
-D date
Check out revisions as of date (is sticky).
-d dir
Check out into dir.
-f
Use head revision if tag/date not found.
-j rev
Merge in changes.
-k kflag
Use kflag keyword expansion.
-l
Local; run only in current working directory.
-N
Don't "shorten" module paths if -d specified.
-n
Do not run module program (if any).
-P
Prune empty directories.
-p
Check out files to standard output (avoids stickiness).
-R
Operate recursively (default).
-r tag
Checkout revision tag (is sticky).
-s
Like -c, but include module status.
commit [options] [files...]
Check changes into the repository.
-F file
Read log message from file.
-f
Force the file to be committed; disables recursion.
-l
Local; run only in current working directory.
-m msg
Use msg as log message.
-n
Do not run module program (if any).
-R
Operate recursively (default).
-r rev
Commit to rev.
diff [options] [files...]
Show differences between revisions. In addition to the options shown below, accepts a wide variety of options to control output style, for example `-c' for context diffs.
-D date1
Diff revision for date against working file.
-D date2
Diff rev1/date1 against date2.
-l
Local; run only in current working directory.
-N
Include diffs for added and removed files.
-R
Operate recursively (default).
-r rev1
Diff revision for rev1 against working file.
-r rev2
Diff rev1/date1 against rev2.
edit [options] [files...]
Get ready to edit a watched file.
-a actions
Specify actions for temporary watch, where actions is edit, unedit, commit, all, or none.
-l
Local; run only in current working directory.
-R
Operate recursively (default).
editors [options] [files...]
See who is editing a watched file.
-l
Local; run only in current working directory.
-R
Operate recursively (default).
export [options] modules...
Export files from CVS.
-D date
Check out revisions as of date.
-d dir
Check out into dir.
-f
Use head revision if tag/date not found.
-k kflag
Use kflag keyword expansion.
-l
Local; run only in current working directory.
-N
Don't "shorten" module paths if -d specified.
-n
Do not run module program (if any).
-P
Prune empty directories.
-R
Operate recursively (default).
-r tag
Checkout revision tag.
history [options] [files...]
Show repository access history.
-a
All users (default is self).
-b str
Back to record with str in module/file/repos field.
-c
Report on committed (modified) files.
-D date
Since date.
-e
Report on all record types.
-l
Last modified (committed or modified report).
-m module
Report on module (repeatable).
-n module
In module.
-o
Report on checked out modules.
-r rev
Since revision rev.
-T
Produce report on all TAGs.
-t tag
Since tag record placed in history file (by anyone).
-u user
For user user (repeatable).
-w
Working directory must match.
-x types
Report on types, one or more of TOEFWUCGMAR.
-z zone
Output for time zone zone.
import [options] repository vendor-tag release-tags...
Import files into CVS, using vendor branches.
-b bra
Import to vendor branch bra.
-d
Use the file's modification time as the time of import.
-k kflag
Set default keyword substitution mode.
-m msg
Use msg for log message.
-I ign
More files to ignore (! to reset).
-W spec
More wrappers.
init
Create a CVS repository if it doesn't exist.
log [options] [files...]
Print out history information for files.
-b
Only list revisions on the default branch.
-d dates
Specify dates (d1<d2 for range, d for latest before).
-h
Only print header.
-l
Local; run only in current working directory.
-N
Do not list tags.
-R
Only print name of RCS file.
-rrevs
Only list revisions revs.
-s states
Only list revisions with specified states.
-t
Only print header and descriptive text.
-wlogins
Only list revisions checked in by specified logins.
login
Prompt for password for authenticating server.
logout
Remove stored password for authenticating server.
rdiff [options] modules...
Show differences between releases.
-c
Context diff output format (default).
-D date
Select revisions based on date.
-f
Use head revision if tag/date not found.
-l
Local; run only in current working directory.
-R
Operate recursively (default).
-r rev
Select revisions based on rev.
-s
Short patch - one liner per file.
-t
Top two diffs - last change made to the file.
-u
Unidiff output format.
-V vers
Use RCS Version vers for keyword expansion (obsolete).
release [options] directory
Indicate that a directory is no longer in use.
-d
Delete the given directory.
remove [options] [files...]
Remove an entry from the repository.
-f
Delete the file before removing it.
-l
Local; run only in current working directory.
-R
Operate recursively (default).
rtag [options] tag modules...
Add a symbolic tag to a module.
-a
Clear tag from removed files that would not otherwise be tagged.
-b
Create a branch named tag.
-D date
Tag revisions as of date.
-d
Delete tag.
-F
Move tag if it already exists.
-f
Force a head revision match if tag/date not found.
-l
Local; run only in current working directory.
-n
No execution of tag program.
-R
Operate recursively (default).
-r rev
Tag existing tag rev.
status [options] files...
Display status information in a working directory.
-l
Local; run only in current working directory.
-R
Operate recursively (default).
-v
Include tag information for file.
tag [options] tag [files...]
Add a symbolic tag to checked out version of files.
-b
Create a branch named tag.
-c
Check that working files are unmodified.
-D date
Tag revisions as of date.
-d
Delete tag.
-F
Move tag if it already exists.
-f
Force a head revision match if tag/date not found.
-l
Local; run only in current working directory.
-R
Operate recursively (default).
-r rev
Tag existing tag rev.
unedit [options] [files...]
Undo an edit command.
-a actions
Specify actions for temporary watch, where actions is edit, unedit, commit, all, or none.
-l
Local; run only in current working directory.
-R
Operate recursively (default).
update [options] [files...]
Bring work tree in sync with repository.
-A
Reset any sticky tags/date/options.
-D date
Check out revisions as of date (is sticky).
-d
Create directories.
-f
Use head revision if tag/date not found.
-I ign
More files to ignore (! to reset).
-j rev
Merge in changes.
-k kflag
Use kflag keyword expansion.
-l
Local; run only in current working directory.
-P
Prune empty directories.
-p
Check out files to standard output (avoids stickiness).
-R
Operate recursively (default).
-r tag
Checkout revision tag (is sticky).
-W spec
More wrappers.
watch [on|off|add|remove] [options] [files...]
on/off: turn on/off read-only checkouts of files. add/remove: add or remove notification on actions.
-a actions
Specify actions for temporary watch, where actions is edit, unedit, commit, all, or none.
-l
Local; run only in current working directory.
-R
Operate recursively (default).
watchers [options] [files...]
See who is watching a file.
-l
Local; run only in current working directory.
-R
Operate recursively (default).

31. 架设 CVS Server

 撰写中 ......


版权所有:UML软件工程组织