CVS笔记

    技术2022-05-11  16

    一、CVS基本概念 1、 Repository CVS服务器端文件仓库 2、 Sandbox 用户本地文件仓库 3、 Tag 标记,用来标识不同的版本 4、 Branch 分支,可以分为主分支与次分支,两者可以独立开发(能commit到Repository)        Usage:        重大版本,除bug,独立开发 5、HEAD 当前Repository的库 6、BASE 相对于Sandbox的Repository库文件 7、Sticky When a file in a sandbox has a persistent state that is not the default state in the repository, the persistent state is said to be sticky. 凡是用tag、revision number和date来checkout,update的的文件或目录(这些叫sticky)不能commit都HEAD中。   二、操作 1、初始化库 Cvs init 2、设置CVSROOT environment variable 如本地的Repository的path为set CVSROOT=D:/CVSREPO/XXXX 3、建库 在要上传的目录上 CVS import . –C 5、 登录 CVS –d :访问的协议:用户名@密码:服务器地址:库路径 Eg: CVS –d :pserver:ricky@XXX:localhost:/CVSREPOR/XXXX 6、 从Repository装载至Sandbox Cd 至要checkout的sandbox 目录 Cvs checkout TAG名 Eg Cvs co 7、 加用户 CVS passwd –a用户名 –r 与系统帐号的alias 8、 改权限 CVS chacl –R(递归) –r (特定的branch)(default)用户名: [r|w|c|n](权限)目录名 9、 同步 CVS update 。 第一次check out后,就要用update,先update,再修改。 正确的通过 CVS 恢复旧版本的方法 如果用 cvs update -r1.2 file.name 这个命令是给 file.name 加一个 STICK TAG "1.2" ,虽然你的本意只是想将它恢复到 1.2 版本 正确的恢复版本的方法是: cvs update -p -r1.2 file_name >file_name cvs update -r revision -p > filename 如果不小心已经加成 STICK TAG 的话:用 cvs update -A 解决 取回过去版本方法 STEP 1: CVS LOG,查看过去的TAG STEP2:update sandbox文件 Calling cvs update with the -r or -D options downloads a static, unchangeable copy of the file or files to the sandbox. Such files can be useful to view past data, but changes to these files cannot be committed to the repository. The static files have a mark, called a sticky tag or a sticky date, in the Entries file in the CVS subdirectory of the current sandbox directory. The command cvs update -A removes the sticky tags or dates and replaces the files with the latest revision from the repository. CVS attempts to merge any changes you have made to the sandbox copy into the copy it retrieves from the repository. If you make changes to a static revision and want to commit the changed file to the repository as a new revision, create a backup of the changed file, use cvs update -A to clear the sticky state, replace the file that update created with the backup, and then cvs commit the file.   10、            提交 Cvs commit filename | directory 11、            删除 CVS rm filename | directory 12、            增加 CVS add filename | directory 13、            标记 CVS tag TAG名 cvs tag determines which files and revisions to mark based on your sandbox, but it marks them based on the revision that was most recently synchronized with the repository. If changes have occured in the sandbox since the files were last synchronized with the repository, those changes will not be reflected in the tagged revisions. The -c command option to cvs tag allows you to check whether your sandbox files have been modified and not committed before you tag the files. If cvs tag -c finds uncommitted changes, it will stop without tagging any files. If you want to tag the revision in the repository, without the uncommitted changes, omit the -c and rerun the cvs tag command. If you want to tag the revision in the sandbox, commit your changes before rerunning cvs tag. 建Branch,先commit,再在tag加参数-b Good advice: Tagging before branching It is good practice to tag the trunk just before splitting off a branch, because this makes it easier to merge the changes back later. To be absolutely certain that the revisions tagged with the prebranch tag are the revisions used as the base of the branch, use cvs rtag -r pre-branch-tag -b branch-tag project to create the branch. This command uses the prebranch tag to specify the revisions the branch is created from Branch creation occurs in the repository, not the sandbox. To edit the branch revisions of the files, you need to check out a branch sandbox or use update to alter the current sandbox to the branch. 14、项目发布导出不带CVS目录的源文件 做开发的时候你可能注意到了,每个开发目录下,CVS都创建了一个CVS/目录。里面有文件用于记录当前目录和CVS库之间的对应信息。但项目发布的时候你一般不希望把文件目录还带着含有CVS信息的CVS目录吧,这个一次性的导出过程使用cvs export命令,不过export只能针对一个TAG或者日期导出,比如: cvs export -r release1 project_name cvs export -D 20021023 project_name cvs export -D now project_name 15、分支例子 cvs tag release_1_0   开始一个新的里程碑: cvs commit -r 2 标记所有文件开始进入2.x的开发   注意:CVS里的revsion和软件包的发布版本可以没有直接的关系。但所有文件使用和发布版本一致的版本号比较有助于维护。   版本分支的建立 在开发项目的2.x版本的时候发现1.x有问题,但2.x又不敢用,则从先前标记的里程碑:release_1_0导出一个分支 release_1_0_patch cvs rtag -b -r release_1_0 release_1_0_patch proj_dir     一些人先在另外一个目录下导出release_1_0_patch这个分支:解决1.0中的紧急问题, cvs checkout -r release_1_0_patch 而其他人员仍旧在项目的主干分支2.x上开发   在release_1_0_patch上修正错误后,标记一个1.0的错误修正版本号 cvs tag release_1_0_patch_1   如果2.0认为这些错误修改在2.0里也需要,也可以在2.0的开发目录下合并release_1_0_patch_1中的修改到当前代码中: cvs update -j release_1_0_patch_1   16、合并分支和主分支(trunk) Advice: When you merge a branch, it is good practice to tag the branch at the merge point. 三、属性 CVS port 2401

     

     

    cvs中的branch和tag辨析 branch“分支”指不同需求或功能差异很大的同一系统的不同产品线,每一个新的产品线都可以演化成新的产品,branch一般在产生新的产品线的时候创建。 tag“标记”经过QA人员测试之后的,确认达到要求时才创建的类似历史记录的标记,tag是记录版本历史的里程碑,tag是不可修改的。

    我们checkout时指定版本的branch,可以取出该分支的最新的代码,进行修改之后,可以commit回cvs中去。 我们checkout时指定版本的tag,可以取出创建该标记时刻的代码,从该tag中取出的代码是反映历史的、不可修改的。

    一个系统可以包含多个tag和branch,tag只能属于某个branch,一个branch可以包含多个tag。

    默认的branch是Main,分支Main最新代码的tag是默认的Head标签。新的branch可以创建新的自定义名称,新的tag可以创建新的自定义名称。


    最新回复(0)