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可以创建新的自定义名称。
不知不觉工作已经超过一年多了。在这其中参加了公司很多项目的开发与实施,频繁的使用着CVS这一工具。这篇文章就是想记录一下自己对CVS的一点使用心得,希望可以给刚刚接触这个工具的后来者一点帮助。同时也是抛砖引玉,可以在与大家交流的过程中提高自我。
2. Branches
-
- cvs tag //需要check out 模块做为当前工作目录
- cvs rtag //不需要工作目录, 直接远程操作建立branch.
-
- cvs rtag -b Branchname my_module
- cvs rtag -r Tagname -b Branchname my_module
- cvs tag -b Branchname
- cvs update -r Branchname
- cvs commit
2.1.1 rtag
To create a branch from the main trunk of my_module at the revision that was last committed, use the commandTo create a branch from a tagged revision of my_module, use the command
Both commands immediately create a branch in the repository without requiring a cvs commit to enact. You do not need to be in a checked-out working directory to do this.
2.1.2 tag
If you are in a working directory, you can create a new branch in the branch or trunk from which you checked out your working directory (not including the changes you've made to your working directory since the last commit) by using the commandLike rtag, the change is immediate, and does not wait for a commit command.
Your working directory remains on the old branch, at a point after the branch you just created. To move your working directory to the new branch, use the command
When you are finished making changes to your working directory, save it as the next revision on the new branch with2.1.3 Both rtag and tag
Note that both rtag and tag work directly on the repository and take effect immediately without a commit command. Rtag takes effect at the specified place (the end of the main trunk by default), while tag takes effect at the place where the working directory was checked out or last committed.
-
- cvs checkout -r Branchname my_module
- To check out the latest revision of a branch to work on, use the command When you do a cvs commit, the changes are merged in on the branch from which they were checked out.
- Note that branch names refer to the latest revision of the branch they are on, not the state they were in when the branch was created.
- cvs tag //需要check out 模块做为当前工作目录
2.1 Creating a Branch
Branches can be added to the repository tree in order to allow different development paths to be tried, or to add parallel development of code to different base versions. To create a branch, you can use or with the -b option.Do not be fooled! Even though the same commands can be used to create tags, branches are completely different than tags.
2.2 Checking Out a Branch to Work On
2.3 General
3. Tags
-
-
- cvs rtag Tagname my_module
- cvs rtag -r Branchname Tagname my_module
- cvs tag Tagname
- In order to name the current end of the main trunk of a module, use the command In order to name the current end of a branch of a module, use the command
Otherwise, to name the code that your working directory was checked out from (without the changes you made to your working directory since the last commit), use the command
-
- cvs checkout -r Tagname my_module
- cvs rtag -r Tagname NewBranchname my_module
cvs update -r NewBranchname
Finish changes to the working directory, then
cvs commit
- cvs checkout -r NewBranchname my_module
- You can check out tagged versions of code with the command
This creates a working directory with the code as it was when the tag was created. While branch names refer to the latest code at the end of a branch (and as such, are dynamic), tag names refer to the static version of code that existed upon the tag's creation. As a result, you cannot commit changes back into the tree at the tagged place that you checked them out from.
If desired, a new branch can be created at the place the tag was applied, then changes can be committed into the new branch as follows:
To access this version of the code again later (along with any changes that were made by others since you last accessed it), use
-
- A tag provides a means to name a certain revision of the code, or take a "snapshot" of it at a certain point in time. This tag only applies a named handle to the code at that point in time, it does not create a new branch of code.
3.1 Creating a Tag
3.2 Using a Tagged version of code
4. Merging branches
-
- cvs add filename
- cvs checkout -r BranchToMergeTo -j TagOrBranch1 -j TagOrBranch2 my_module
4.1 Using Update
cvs update -j TagOrBranch1 -j TagOrBranch2 my_moduleThe above command will locate the differences between TagOrBranch1 and TagOrBranch2. Of the lines that are different between them, the lines in TagOrBranch2 will be patched, or merged, into the sources in your working directory.
An annoying problem that I have not yet solved is that new files that appear in TagOrBranch2 but not in TagOrBranch1 do not get created by the merge. The only thing I know of to get these files into the new version is to checkout TagOrBranch2, copy the files into the merged working directory, and do
4.2 Using Checkout
cvs checkout -j TagOrBranch1 -j TagOrBranch2 my_moduleThe above command will locate the differences between TagOrBranch1 and TagOrBranch2. Of the lines that are different between them, the lines in TagOrBranch2 will be patched, or merged, into the latest revision on the main trunk of my_module.
In order to have these differences merged into a different branch, and then have that branch checked out, use
Like update, file that were created between TagOrBranch1 and TagOrBranch2 do not get created automatically.