CVS 学习笔记

使用本地cvs服务器
[tom@suse-tom ~]$cvs -d /home/tom/cvs init

[tom@suse-tom cvs-sp]$cvs import -m "Initial version of Simple Project" test/tom-csv tom start     
N test/tom-csv/hello.c
N test/tom-csv/Makefile

No conflicts created by this import

[tom@suse-tom cvs-sp]$
test/tom-csvtomstart
Project nameVendor TagRelease Tag
name for projtag for the entire branchtag for a specific release
[tom@suse-tom ~]$mkdir junk
[tom@suse-tom ~]$cd junk/
[tom@suse-tom junk]$cvs checkout test/tom-csv				#下载到本地
cvs checkout: Updating test/tom-csv
U test/tom-csv/Makefile
U test/tom-csv/hello.c


[tom@suse-tom junk]$cd test/tom-csv/
[tom@suse-tom tom-csv]$ls
CVS  hello.c  Makefile
[tom@suse-tom tom-csv]$vim Makefile 
[tom@suse-tom tom-csv]$make
cc     hello.c   -o hello
[tom@suse-tom tom-csv]$vim hello
[tom@suse-tom tom-csv]$./hello 
hele


[tom@suse-tom tom-csv]$cvs diff
cvs diff: Diffing .
Index: Makefile
===================================================================
RCS file: /home/tom/cvs/test/tom-csv/Makefile,v
retrieving revision 1.1.1.1
diff -r1.1.1.1 Makefile
3c3
< test:
---
> hello:
9c9
< install:test
---
> install:hello
> 
[tom@suse-tom tom-csv]$cvs commit
cvs commit: Examining .
/home/tom/cvs/test/tom-csv/Makefile,v  <--  Makefile
new revision: 1.2; previous revision: 1.1

在这里插入图片描述

[tom@suse-tom test]$cvs diff				#commit 完diff
cvs diff: Diffing .
cvs diff: Diffing tom-csv
[tom@suse-tom test]$
[tom@suse-tom test]$cvs rdiff -r1.1 test/tom-csv
cvs rdiff: Diffing test/tom-csv
Index: test/tom-csv/Makefile
diff -c test/tom-csv/Makefile:1.1 test/tom-csv/Makefile:1.2
*** test/tom-csv/Makefile:1.1   Sat May 22 20:46:04 2021
--- test/tom-csv/Makefile       Sat May 22 20:53:24 2021
***************
*** 1,12 ****
  MYLIB = T
  TOM = "test"
! test:
  define installt
        @echo "Installing $@ in  $(TOM) ..." \ ;
        @echo "... done." 
  endef
  
! install:test
  ifdef MYLIB
        $(installt)
  endif
--- 1,12 ----
  MYLIB = T
  TOM = "test"
! hello:
  define installt
        @echo "Installing $@ in  $(TOM) ..." \ ;
        @echo "... done." 
  endef
  
! install:hello
  ifdef MYLIB
        $(installt)
  endif
Index: test/tom-csv/hello.c
diff -c test/tom-csv/hello.c:1.1 test/tom-csv/hello.c:1.2
*** test/tom-csv/hello.c:1.1    Sat May 22 20:46:04 2021
--- test/tom-csv/hello.c        Sun May 23 10:49:36 2021
***************
*** 2,5 ****
--- 2,6 ----
  int main()
  {
        printf("hele");
+       printf("hello world");
  }

将其他人修改的从版本库提过来

[tom@suse-tom junk1]$cvs update -Pd test/tom-csv
cvs update: Updating test/tom-csv
U test/tom-csv/hello.c
[tom@suse-tom junk1]$
远程CVS

cvs具备在不事先挂载文件系统的情况下跨网络操作的能力

使用远程CVS pserver
[tom@ton ~]$cvs login
Logging in to :pserver:tom@192.168.3.109:2401/home/tom/cvs
CVS password:

同本地的操作一样,加上-z3选项以强制执行数据压缩,可以节约网络带宽。

[tom@ton ~]$cvs -z3 checkout test/tom-csv
cvs checkout: Updating test/tom-csv
U test/tom-csv/Makefile
U test/tom-csv/hello.c

他使用的是RSH协议远程访问,不安全,容易受窃听攻击。

通过ssh 远程 CVS
[tom@ton ~]$export CVRROOT=:ext:tom@192.168.3.109:/home/tom/cvs

同时可以用RSA认证来简化输入密码>配置ssh密钥对认证及scp、ftp等文件传输

命令
$ cvs co project-x						#从cVS下载源码到本地
$ cvs diff -u							#相当于diff -u repository/ local/
$ cvs up -C modified_file				#撤消对文件的修改
$ cvs ci -m "Describe change"			#保存本地源码到CVS

$ vi newfile_added
$ cvs add newfile_added

$ cvs ci -m "Added newfile_added"
$ cvs up								#从CVS合并最新版本
#生成所有在 CVS里新创建的子目录,使用"cvs up -d -P"代替"cvs up"
#注意以"C filename"开头的行,这表示在更新过程中,产生了冲突,未修改的本地代码文件被重命名为.#filename.version'.
#在 filename里面查找"<<<<<<<"和">>>>>>>",可以找到发生冲突的地方
$ cvs tag Release-1						#添加release tag
$ cvs tag -d Release-1					#移除release tag
$ cvs ci-m "more comments"
$ cvs tag Release-1						#重新添加release tag

$ cvs co -r Release-initial -d old project-x  	#得到原始版本到old目录
$ cvs tag -b Release-initial-bugfixes		 	#创建分支(-b)标签...现在可以在老版本工作(Tag=sticky)
$ cvs update -d -P								#源代码树现在有粘滞标签"Release-initial-bugfixes",在这个分支下工作
$ cvs up -d -P									#同步这个分支下其它人修改的文件
$ cvs ci -m "check into this branch"
$ cvs update -kk -A -d -P						#删除粘滞标签,忽略从主干的更新,...不扩展关键字
$ cvs update -kk -j Release-initial-bugfixes	#从 Release-initial-bugfixes 分支移植到主干,不扩展关键字,使用编辑器修改冲突
$ cvs ci -m "merge Release-initial-bugfixes"
$ tar -cvzf old-project-x.tar.gz old 			#产生文档,-j选项生成bz2格式的压缩包
$ cvs release -d old							#删除本地源码(可选)

应该记住的几个选项(用作 cvs命令行的第一个参数):
-n					虚拟运行,无实际效果
-t					显示cvs活动步骤的信息
从CVS 获得最新版本

tomorrow

$ cvs ex -D tomorrow module_name
为项目添加别名(本地服务器)
$su - admin							#staff用户组成员
$ export CVSROOT=/var/lib/cvs
$ cvs co CVSROOT/modules
$ cd CVSROOT
$ echo "px -a project-x" >>modules
$ cvs ci -m "Now px is an alias for project-x"
$cvs release -d .
$ exit							#按 Ctr1-D从su返回
$cvs co -d project px			#从 CVS检出 project-x(别名:px) 到目录 project

常见问题及解决方法
仓库中的文件权限

CVS不会覆盖当前仓库中的文件,而是用另一个文件替换它。因此,对仓库目录的写权限是很危险的权限。所以在新建仓库时,请运行下面的命令,确保权限合适。

#cd /var/lib/cvs
#chown -R root:src	repository
#chmod -R ug+rwX	repository
#chmod	2775		repository				#如果需要,当前目录和子目录
执行标记(execution bit)

当文件被别人取走后会保留执行标记,任何时候你遇到外出文件存在执行权限问题,可用下面的命令在CVS仓库中修改文件权限。

#chmod ugo-x filename
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值