When multi-person jointly develops a large project, the maintenance and version maintenance of the source code is a distressed thing. Due to multi-person development, each developer has a copy of this project, so if you want to manually maintain the same file. Multi-person revision is a very difficult thing. In addition, the version of the item you need is not the latest version of the current development, if you reserve a backup for each version is almost impossible for this purpose. A functional software is available on the Linux platform: CVS. As we all know, Linux's development has benefited from the development of the Internet. Most software is commonly developed in the Internet. Most of these software use CVS, such as DEBAN Linux development, KDE development, and SourceForg A development project. Correctly skilled with CVS is a Linux programmer's basic quality. CVs can not only maintain source code, in fact, all text files can be managed using CVS, of course, can also manage binary files, just need special command options. CVS saves files in a repository (repository), the file saved in the warehouse is not a copy of each version, but can be retroiled from any version to the main control information of some of the code of the initial version, which will save A large amount of storage space. The warehouse can not only be built on this unit, but also on the network. In addition, CVS supports version branches (TAG), which can be derived from any version to develop, if necessary, you can merge this branch to the main development branch. CVS requires a software called RCS (revised control system). It is specifically that CVS mainly manages changes in the directory in the development project, and RCS focuses on the change of one file management. If you want to use the network's CVS, you also need RSH or your own built-in CVS-Server. RSH is a communication platform for CVS customers. If secure information is required, you can use SSH, which can be used to specify: Export CVS_RSH = RSH Use RSH Export CVS_RSH = SSH to use SSH RCS before using CVS, first introduce the method of use of RCS first. As mentioned earlier, RCS is managed for a particular file, and the commonly used commands are Co and Ci. RCS uses the RCS directory in the forward working path to store management files. CI (Check IN) Adds the source code into the RCS source code repository, each of which adds the file in the Code Base. After each modify the file again, the version of this file is incremented to 1.2, 1.3. ....... Co (Check Out) Remove the source file from the RCS source warehouse, the default version is the latest version, if you need a specified version, you need to specify using the -R option.
For example: $ mkdir RCS establishes a RCS source warehouse editing a file, such as hello.c #include
In RCS, support keywords similar to macros, these keywords are replaced by RCS with specific information, such as $ ID $ Keywords: / * $ ID * / #include
If your CVSROOT environment variable already exists, you can use the CVS -D option to specify a CVS repository different from CVSROOT. Then initialize the CVS warehouse, establish some of the files and information required for CVS maintenance, and CVS stores this information in the cvsroot directory of the CVS warehouse home directory. These files, in addition to modules, other files do not manually modify, the module file defines the location of the CVS export module in the CVS warehouse, which is very convenient to export a deep directory from the CVS warehouse. After CVS init, we use CVS Import to import the directory structure of the development project that needs to be maintained into the CVS warehouse, as follows: After building a directory structure of the project, the current TestPRJ directory is like this: [Kerberos @ Power ZHYF] $ Tree Testprj Testprj | - Admin | - DOC | - Include | - Libs `- SRC | - Include` - Main 7 Director, 0 Files CVS IMPORT has three parameters: The first is This directory tree is a module name in the CVS warehouse, the second is a flag of the publisher, and the third is the version tag (TAG) of this item. Below, we import TestPRJ into the CVS warehouse and use the TestPRJ module name. [Kerberos @ POWER TESTPRJ] $ CVS IMPORT TESTPRJ KERBEROS INITVER After executing the command, CVS calls the editor specified by cvseditor to allow you to enter the log. If the cvseditor is not defined, the default call vi can be used to specify your own use. editor. After entering the log, CVS imports the current directory structure into the CVS repository and uses the TestPRJ name, when exporting the file, you can use CVS CO TestPRJ to export.
"/ Tmp / cvscVxZnW" 5L, 242C written cvs import: Importing / home / zhyf / cvsroot / testprj / admin cvs import: Importing / home / zhyf / cvsroot / testprj / libs cvs import: Importing / home / zhyf / cvsroot / testprj / src cvs import: Importing / home / zhyf / cvsroot / testprj / src / include cvs import: Importing / home / zhyf / cvsroot / testprj / src / main cvs import: Importing / home / zhyf / cvsroot / testprj / doc cvs import : Importing / home / zhyf / cvsroot / testprj / include no conflicits created by this import looks the structure in the cvsroot directory is the same as the TestPRJ: ../cvsroot | - cvsroot | | - CheckoutList | | - CheckoutList , V | ........................... CVS warehouse information, omitted .. | ........... .............. `- TestPRJ | - Admin | - DOC | - Include | - Libs` - src | - include` The structure of the module is the same as our own TestPRJ's directory structure. Thus, when you need to use these source code again, you can use the CVS CO module name to export directory trees and files.
Export any directory with write permission: [Kerberos @ Power Testprj] $ CD .. [Kerberos @ Power ZHYF] $ RM -RF TestPRJ Delete TestPRJ Directory [Kerberos @ Power ZHYF] $ CVS CO TestPRJ Re-export CVS Checkout: Updating Testprj cvs checkout: Updating testprj / admin cvs checkout: Updating testprj / doc cvs checkout: Updating testprj / include cvs checkout: Updating testprj / libs cvs checkout: Updating testprj / src cvs checkout: Updating testprj / src / include cvs checkout: Updating testprj / SRC / Main [Kerberos @ Power ZHYF] $ Tree Testprj Testprj | - CVS | | - Entries | | - Repository | `- Root | - Admin |` - CVS | | - ENTRIES | Repository | `- root | - doc |` - cvs | | - entries | | - repository | `- root | - include |` - cvs | | - entries | | - Repository | `- root | - libs |` - cvs | | - entries | | - repository | `- root` - src | - cvs | | - entries | | - repository | ` Root | - Include | `- CVS | | - Entries | | - Repository |` - Root `- Main` - cvs | - ENTRIES | - Repository `- root cvs in each directory Below, a directory called CVS is established. In addition, the structure of the directory is the same, in fact, CVS The record is stored some information about the directory structure in the warehouse. The entries contains subdirectory in these directorys, and Respository contains the relative positions of this directory in the warehouse, and root contains the absolute path of the exported module home directory. The CVS import command is only used when the project is imported into the CVS repository. If you need to join the directory or join the file, use the cvs add command to join, and then use the CVS Commit Submit, the file or directory is truly added to CVS. Warehouse.
We can copy the hello.c file you just edited to TestPRJ / SRC / Main / then use: [Kerberos @ Power ZHYF] $ cvs add testprj / src / main / hello.c cvs address: scheduling file `testprj / src /main/hello.c 'for addition cvs add: use' cvs commit 'to add this file permanently using cvs commit to commit changes [kerberos @ power zhyf] $ cvs commit cvs commit: Examining testprj cvs commit: Examining testprj / admin cvs commit : Examining testprj / doc cvs commit: Examining testprj / include cvs commit: Examining testprj / libs cvs commit: Examining testprj / src cvs commit: Examining testprj / src / include cvs commit: Examining testprj / src / main RCS file: / home / ZHYF / CVSROOT / TESTPRJ / SRC / Main / Hello.c, V Done Checking in TestPRJ / SRC / Main / Hello.c; /Home/zhyf/cvsroot/testprj/src/main/hello.c <- hello .c initial revision: 1.1 Manage a single file using RCS DONE TESTPRJ / SRC / Main / Hello.c Since the CVS is managed by the RCS, the knowledge we speak, the knowledge we speak can also be used here, the only difference is the order. The previously defined is CVS, such as CVS CI, CVS CO, CVS Diff, or using the -R option when exported, specifies the version of the exported file. In the source code file, the keywords of RCS can also be used. For non-ASCII files, such as binary executables, bitmaps and other files, we cannot use CVS ADD to join the CVS repository, because CVS is only a change in the ASCII code comparison file, so for binary files, if you use CVS AddD The command will destroy the full file, and when you join the binary, you want to specify the -kb parameter. If you have modified the already file, use CVS CI, CVS Commit to submit a modification. Another situation is to export the files modified by others, instead of covering the modifications yourself, you can use the CVS Update command, this command will automatically compare the latest files in the CVS warehouse in the CVS warehouse and the current modification time of the current file. When CVS Update and CVS CI, you have conflicted with others, and CVS prompts you. CVS will use the ">>>>>>" or "<<<<<<<" tag in the file, and you can negotiate with others to manually modify this code. If you want to delete a file in the warehouse, you must first remove the local exported file, then use the CVS Remove file name, CVS Commit to delete. In fact, CVS will not really delete these files. If you want to get these files, you only need, you can use the CVS Co -r to specify the version export before deleting.
Sometimes, in order to export deep catalogs or files in the CVS warehouse have to enter a long path, this is annoying, you can export in the cvsroot directory in the CVS warehouse, modify the modules file, define this directory or file as a module, submit a modification You can export directly using the CVS CO module name directly. The version control function of CVS is mainly reflected on TAG. The role of the tag is like a version of all files at the same time. When you need to export these versions, you can export different files at a time, which is often used when the project has reached a certain goal. There is only one parameter of the cvs tag command: tagname. For example: CVS tag release_1.0_beta, if this version is required, you only need to use cvs co -r release_1.0_beta to export this version. Or use CVS Diff -R to generate a Patch file and use CVS log -r to view this version of the log. Another very important role of tags is to generate branches and merge branches. Usually, when our project is developed to a certain level, it is necessary to explore whether a development path is valid. At this time, we need to do a test, but the development of this trial cannot affect the main development branch of the project, so we You can generate a branch development, and the main development branch can continue, both do not conflict, in the future, if the branch is valid, it can also merge branches into the main development branch. Create a CVS branch: After the CVS Tag -b branch tagname establishes a branch, it does not affect the files currently from the CVS warehouse, you need to re-export branch branch_ver: cvs co -R branch marker name module name, we It can be done as usual for branch development. If this branch is successful, we can combine it with the main branch: CVS Update -j branch tagname CVS Commit can merge the development branch into the main branch. . The above is the operation of the local CVS warehouse. If you use the network CVS warehouse, you only need to use the CVS_RSH environment variable to specify the communication shell, and the CVS warehouse is set to the network warehouse. There are two of the servers on the CVS warehouse on the web: EXT and DSERVER. For the latter, you need to verify the user before the CVS operation is performed. The latter uses rlogin verification and does not need to be explicitly logged. Such as: EXT CVS server uses export cvsroot =: ext: kerberos @ PiWer: / home / repository or cvs -d: ext: Kerberos @ PiWER: / Home / Repository CVS CO PlatoON DERSER CVS server Using export cvsroot =: pserver: anonymous @ Anoncvs.kde.org:/home/kde CVS login CVS CO KDEBASE Some common CVS command options -d specifies the path of the CVS warehouse - Zn is transmitted after the Gzip is transmitted, and automatically decompressed locally. n is a compressed level usually 1 to 4, usually used in the case where the transmission speed of the server is slow. -X Communication for servers use encryption algorithm, only several common GUI tools that are valid CVS under the use of Kerberos verification system: Lincvs (Figure 1), is a CVS client tool for XWindow, a popular one, function It is also very powerful. Figure 1 LINCVS CERVISIA (Figure 2), a KDE-based CVS GUI tool, using KDE readers easy to get started. Figure 2 Cervisia Note: The setting of environment variable in the article is under Bash, other shell Use different commands