码迷,mamicode.com
首页 > 其他好文 > 详细

CVS常用操作总结

时间:2014-06-29 20:10:34      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   get   使用   strong   

导入 project

使用 cvs import 命令即可:

cvs import -m "your import message here" projname vendortag releasetag

需要注意的是,一些特定的文件或文件夹名(诸如 *.exe *.obj )是默认添加在 ignore list 中的,它们不会被导入到项目中。如实在需要,可以随后使用 cvs add 将其加入,或者在导入时使用 -I ! 选项,忽略 cvs 默认的 ignore list 。当然,在 cvsignore 文件中第一行加入 ! 也是可以的,这就需要全部重新定义自己需要的 ignore list 了。

添加二进制文件或不需要进行 keyword expansion 的文本文件

如果二进制文件的文件名没有包含在 cvswrappers 中,则需要手动添加如下:

    cvs add -kb filename
    cvs ci -m "msg" filename

对于文本文件,如果需要对其禁用 keyword expansion ,则使用 -ko 选项即可:

    cvs add -ko filename

    cvs ci -m "msg" filename

目录操作

  • 目录添加:在本地新建目录后,只需使用 cvs add 即可将其成功加入,无须使用 cvs commit

  • 目录删除:首先删除目录下的所有文件(三步: rm 删除;运行 cvs remove ;运行 cvs commit ),然后在该目录上一级运行 cvs update -P 即可,即将该目录 prune 掉。

  • 新目录的获取: repository 中新生成的目录在 cvs update 时并不会自动获取,必须使用 -d 选项才可以,即 cvs update –d

  • 改变目录名称:这实际上是一系列操作的组合,即

    1. 新建目录并运行 cvs add 将其加入 cvs

    2. 将原目录中的文件移动至新目录下。

    3. 运行 cvs commit 删除原有目录,并向 cvs 添加移动过来的文件。

文档更新

通常使用 cvs update 就可以了。当然,也可以使用 -D -r 选项来指定获取特定时间或特定版本号的文档。其中,采用 -D 指定时间更新时,需要准确到秒,并需要标明 GMT 以保证 sticky date 中时间与文档的时间一致,这是由于更新时间时 cvs 默认采用 Greenwich mean time ,而系统采用的是本地时区时间。标准的时间格式例如: 2007/06/23 20:19:00 GMT

将文档“更新”至原先的版本或日期后,该文档则标识为 sticky ,运行 cvs update 时该文档则会 sticky 于其当前版本,不会有任何的更新动作;同时,对该文档修改后再 commit 也是不允许的,因为 cvs 禁止对过去的历史做修改。而使用 cvs update -A 则可将当前文档重新恢复到最新版本。

为了获取原来的版本且不使当前文档变为 sticky ,即将当前文档 revert 到原来的某个版本,则需要使用如下的命令将原先某个版本的文档内容输出到标准输出,然后将其重定向到当前的文档即可:

cvs -Q update -p -r 1.1 Main.c > Main.c

注意: 上述命令中的 -Q 选项是不可缺少的,否则 cvs 会向控制台(实质为标准错误 standard error )输出一些不属于文档的内容:

    ===================================================================
    Checking out MainInterface.m
    RCS: /cvsroot/pub/hvdc-corona/MainInterface.m,v
    VERS: 1.1
    ***************

添加 Tags

当项目进展到一定程度可以提供出来一个较为完整的版本时,就可以对当前项目所有文档添加标记 tags ,以便今后随时将其取出。如果不这样做,由于不能保证当前各个文件的版本号一致,以至于今后只能逐一将文件取出,极不方便。这就是添加 tags 的作用。例如,

cvs tag -R tag_name

其中,-R表示recursive

处理二进制文件

Basic Concept

When cvs deals with binary files, the file merging, diffing and other such operations will be lost. But if you do not use binary mode, error will occur.

There are two issues with using CVS to store binary files. The first is that CVS by default converts line endings between the canonical form in which they are stored in the repository (linefeed only), and the form appropriate to the operating system in use on the client (for example, carriage return followed by line feed for Windows NT).

The second is that a binary file might happen to contain data which looks like a keyword, so keyword expansion must be turned off.

`-kb‘ Option and Recover

When you come across binary files that are to be managed by cvs, you should use `-kb‘ option to turn off line ending conversion and keyword expansion.

For example:

    $ cvs add -kb -m"A test file" kotest
    $ cvs ci -m"First checkin; contains a keyword" kotest

If a file accidentally gets added without `-kb‘, we still can use `cvs admin‘ to recover them. See below:

    $ echo ‘$Id: cvsnote,v 1.1.1.1 2006-04-16 15:20:53 foo Exp $‘ > kotest
    $ cvs add -m"A test file" kotest
    $ cvs ci -m"First checkin; contains a keyword" kotest
    $ cvs admin -kb kotest
    $ cvs update -A kotest
    # For non-unix systems:
    # Copy in a good copy of the file from outside CVS
    $ cvs commit -m "make it binary" kotest

For convenience, we can use Wrappers to tell cvs which kinds of files are to be treated like binary files by their file name extensions. There are no other ways for cvs to judge whether a file is binary or not.

Wrappers

Wrappers refers to the CVS feature which lets you control certain settings based on the name of the file that is being operated on.

The format of the wrapper is as follows:

    wildcard [option value][option value]...
    where option is one of
    -m update methodology value: MERGE or COPY
    -k keyword expansion value: expansion mode
    and value is a single-quote delimited value.

The command with cvs wrapper is as follows:

cvs import -I ! -W "*.exe -k ‘b‘" first-dir vendortag reltag

解决文档冲突

开始工作前先与同组人员沟通,并保证先运行 cvs update 然后再工作,可以避免文档的冲突。如果出现了冲突,则在 cvs update 时会将最新版本与本地文档的不同之处融合( merging )到本地文档中,并以下面的方式来显示:

    <<<<<<< (filename)
    the uncommitted changes in the working copy
    blah blah blah
    =======
    the new changes that came from the repository
    blah blah blah
    and so on
    >>>>>>> (latest revision number in the repository)

此时则需要进行手动编辑以处理冲突,然后再提交该文档。

显示命令帮助

执行:

cvs --help cmd_name

例如,

    orlando@Debian-Jihuan:~/HADAPT/HADAPTpro$ cvs --help tag 
    Usage: cvs tag [-bcdFflR] [-r rev|-D date] tag [files...] 
    -b Make the tag a "branch" tag, allowing concurrent development. 
    -B Allows -F and -d to disturb branch tags. Use with extreme care. 
    -c Check that working files are unmodified. 
    -d Delete the given tag. 
    -F Move tag if it already exists. 
    -f Force a head revision match if tag/date not found. 
    -l Local directory only, not recursive. 
    -R Process directories recursively. 
    -r rev Existing revision/tag. 
    -D Existing date. 
    (Specify the --help global option for a list of other help options) 

 

 

CVS常用操作总结,布布扣,bubuko.com

CVS常用操作总结

标签:style   blog   color   get   使用   strong   

原文地址:http://www.cnblogs.com/quantumman/p/3814818.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!