📄 html3.html
字号:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb_2312-80">
<META NAME="Generator" CONTENT="Microsoft Word 97">
<TITLE>cvs</TITLE>
</HEAD>
<BODY LINK="#0000ff" VLINK="#800080" BACKGROUND="velvet.jpg">
<P ALIGN="JUSTIFY"><a href="html2.html"><img src="prev.gif" width="16" height="16" border="0"></a><a href="html4.html"><img src="next.gif" width="16" height="16" border="0"></a><a href="index.html"><img src="toc.gif" width="16" height="16" border="0"></a></P>
<P ALIGN="JUSTIFY"> </P>
<P ALIGN="JUSTIFY"><FONT FACE="宋体" LANG="ZH-CN" COLOR="#ffff00"> CVS,顾名思义,是个可以用在小组协作环境下的源码版本管理系统。同类的软件有AT&T的SCCS(Source
Code Control System),还有PVCS等。在OpenSource项目里CVS用得最为广泛, Linux kernel不使用CVS来维护,下面我们将会参考FreeBSD的源码管理来做示例。CVS是个相当复杂的系统,FreeBSD甚至设有专门的“CVS管理员”(CVS
</font><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00">“</FONT><FONT FACE="宋体" LANG="ZH-CN" COLOR="#ffff00">Maester</FONT><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00">”</FONT><FONT FACE="宋体" LANG="ZH-CN" COLOR="#ffff00">)来全面负责项目的CVS
repository维护。</font></P>
<FONT FACE="宋体" LANG="ZH-CN" COLOR="#ffff00">
<P ALIGN="JUSTIFY"> 下面介绍与CVS相关的若干概念和术语:</P>
<P ALIGN="JUSTIFY"> Repository: “源码仓库”,CVS存放的项目源码历史档案</P>
<P ALIGN="JUSTIFY"> CVSROOT: 该环境变量指明CVS Repository存放的目录</P>
<P ALIGN="JUSTIFY"> Module: 模块。就是CVSROOT下的顶级目录名</P>
<P ALIGN="JUSTIFY"> Vendor Branch: 分支。在一套Repository里可以存放多个代码分支的历史</P>
<P ALIGN="JUSTIFY"> Release Tag: 发行标记。对于每一个版本,可以用符号来做标记</P>
<P ALIGN="JUSTIFY"> 下面是一个CVS repository的版本衍生图,大致描绘了FreeBSD的版本发行情况。图中的RELENG_3和RELENG_4表示“Release Engine”,也就是Vendor Branch,每个Branch分头发展,等某个Branch的开发到了一定的质量水准,就做个Release Tag。比如最近的4.0-RELEASE的Release Tag是REL_4_0。</P>
<P ALIGN="JUSTIFY"> 这些不同的Branch都存放在同一个Repository Tree里。</P>
<P ALIGN="JUSTIFY"> </P>
<P ALIGN="JUSTIFY"> <IMG SRC="Image2.jpg" WIDTH=550 HEIGHT=357></P>
<P ALIGN="JUSTIFY"> </P>
<P ALIGN="JUSTIFY"> CVS是个很复杂的系统,可以参考下面两个URL获得进一步的信息:</P>
</FONT><P ALIGN="JUSTIFY"><FONT FACE="宋体" LANG="ZH-CN" COLOR="#ffff00">		</font><A HREF="http://www.cyclic.com/"><FONT FACE="Lucida Console" COLOR="#ffff00">http://www.cyclic.com</FONT></A></P>
<P ALIGN="JUSTIFY"><FONT FACE="宋体" LANG="ZH-CN" COLOR="#ffff00">		</font><A HREF="http://www.loria.fr/~molli/cvs-index.html"><FONT FACE="Lucida Console" COLOR="#ffff00">http://www.loria.fr/~molli/cvs-index.html</FONT></A></P>
<FONT FACE="宋体" LANG="ZH-CN" COLOR="#ffff00"><P ALIGN="JUSTIFY">(在cvs软件包里含有详细的文档,应当查阅info版本。几个ps文件都太老了)</P>
<P ALIGN="JUSTIFY">下面介绍CVS的基本用法。</P>
<P ALIGN="JUSTIFY">① Import 导入/创建CVS Repository Tree</P>
<P ALIGN="JUSTIFY"> 首先建一个目录作为你的CVSROOT,然后用cvs init命令对其初始化(建立一系列log,config文件)。然后到工作目录下使用cvs import命令:</P>
</FONT><P ALIGN="JUSTIFY"><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00"> </font><FONT FACE="Lucida Console" COLOR="#ffff00">[hahalee@builder]$ mkdir /home/hahalee/CVS</font></P>
<P ALIGN="JUSTIFY"><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00"> </font><FONT FACE="Lucida Console" COLOR="#ffff00">[hahalee@builder]$ export CVSROOT=/home/hahalee/CVS</font></P>
<P ALIGN="JUSTIFY"><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00"> </font><FONT FACE="Lucida Console" COLOR="#ffff00">[hahalee@builder]$ cvs init</font></P>
<P ALIGN="JUSTIFY"><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00"> </font><FONT FACE="宋体" LANG="ZH-CN" COLOR="#ffff00">[hahalee@builder]$ cvs import </FONT><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00">_</FONT><FONT FACE="宋体" LANG="ZH-CN" COLOR="#ffff00">b 0.5.0 hftpd RELENG_0 REL_0</font></P>
<P ALIGN="JUSTIFY"><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00"> </font><FONT FACE="Lucida Console" COLOR="#ffff00">N hftpd/tar.h</font></P>
<P ALIGN="JUSTIFY"><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00"> </font><FONT FACE="Lucida Console" COLOR="#ffff00">N hftpd/auth.h</font></P>
<P ALIGN="JUSTIFY"><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00"> </font><FONT FACE="Lucida Console" COLOR="#ffff00">[blah...blah...blah...]</font></P>
<P ALIGN="JUSTIFY"><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00"> </font><FONT FACE="Lucida Console" COLOR="#ffff00">N hftpd/docs/rfcs/rfc0959.txt</font></P>
<P ALIGN="JUSTIFY"><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00"> </font><FONT FACE="Lucida Console" COLOR="#ffff00">N hftpd/docs/rfcs/rfc2428.txt</font></P>
<P ALIGN="JUSTIFY"><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00"> </font><FONT FACE="Lucida Console" COLOR="#ffff00">No conflicts created by this import</FONT><FONT FACE="宋体" LANG="ZH-CN" COLOR="#ffff00">	</font></P><P ALIGN="JUSTIFY">
<FONT FACE="宋体" LANG="ZH-CN" COLOR="#ffff00"> 上述操作在$CVSROOT下生成hftpd目录,可以看到里面都是后缀为“,v”的文件,这就是import进来的Repository。RELENG_0是vendor-tag,REL_0是release-tag。vendor-tag就是vendor branch tag,可以理解为</font><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00">”</FONT><FONT FACE="宋体" LANG="ZH-CN" COLOR="#ffff00">code name</FONT><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00">”</FONT><FONT FACE="宋体" LANG="ZH-CN" COLOR="#ffff00">。</font></P><FONT FACE="宋体" LANG="ZH-CN" COLOR="#ffff00">
<P ALIGN="JUSTIFY">② Checkout 创建私有工作目录/Export</P>
<P ALIGN="JUSTIFY"> 换一个空目录,运行 cvs checkout modules_name 即可:</P>
</FONT><P ALIGN="JUSTIFY"><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00"> </font><FONT FACE="Lucida Console" COLOR="#ffff00">[hahalee@builder]$ cvs checkout hftpd# hftpd</FONT><FONT FACE="宋体" LANG="ZH-CN" COLOR="#ffff00">是我们的</FONT><FONT FACE="Lucida Console" COLOR="#ffff00">module</FONT><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00"> </FONT><FONT FACE="Lucida Console" COLOR="#ffff00">name</font></P>
<P ALIGN="JUSTIFY"><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00"> </font><FONT FACE="Lucida Console" COLOR="#ffff00">cvs checkout: Updating hftpd</font></P>
<P ALIGN="JUSTIFY"><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00"> </font><FONT FACE="Lucida Console" COLOR="#ffff00">U hftpd/AUTHORS</font></P>
<P ALIGN="JUSTIFY"><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00"> </font><FONT FACE="Lucida Console" COLOR="#ffff00">U hftpd/COPYING</font></P>
<P ALIGN="JUSTIFY"><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00"> </font><FONT FACE="Lucida Console" COLOR="#ffff00">[blah blah blah]							# </FONT><FONT FACE="宋体" LANG="ZH-CN" COLOR="#ffff00">省略许多</font></P>
<P ALIGN="JUSTIFY"><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00"> </font><FONT FACE="Lucida Console" COLOR="#ffff00">[hahalee@builder t]$ ls -l</font></P>
<P ALIGN="JUSTIFY"><FONT FACE="宋体" LANG="ZH-CN" COLOR="#ffff00"> 总共</font><FONT FACE="Lucida Console" COLOR="#ffff00"> 0</font></P>
<P ALIGN="JUSTIFY"><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00"> </font><FONT FACE="Lucida Console" COLOR="#ffff00">drwxrwxr-x 5 hahalee hahalee 1253 Apr 7 20:08 hftpd</font></P>
<P ALIGN="JUSTIFY"><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00"> </font><FONT FACE="Lucida Console" COLOR="#ffff00">[hahalee@builder t]$ find ./ -type d</font></P>
<FONT FACE="宋体" LANG="ZH-CN" COLOR="#ffff00"><P ALIGN="JUSTIFY"> 从最后一条命令的输出可看到,checkout的工作目录里多了CVS目录。里面记载了CVS相关的信息,可以方便后续的cvs操作。如果纯粹是为了拷贝出最新的source tree,可以用export,此时不会建立CVS目录。</P>
<P ALIGN="JUSTIFY">③ Update 更新</P>
<P> 当你完成某一部分代码的时候,先不忙提交,可以把别人可能做了的其他修改update过来然后统一编译调试无误后再提交,这是team work的准则。在checkout出来的工作目录下(不管什么子目录),直接cvsup update 就可以了,当然你要先把CVSROOT环境变量设置好。</P>
<P>④ Commit 提交</P>
<P> 很简单,cvs commit。但你必须要在checkout出来的工作目录里提交才行:</P>
</FONT><P ALIGN="JUSTIFY"><FONT FACE="System" LANG="ZH-CN" COLOR="#ffff00"> </font><FONT FACE="Lucida Console" COLOR="#ffff00">[hahalee@builder]$ cvs commit</font></P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -