Use CVS for project development management

xiaoxiao2021-03-06  19

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 int main (void) {printf ("Hello World / N"); return 0;} then add it to In the RCS warehouse: [Kerberos @ Power ZHYF] $ CI Hello.c RCS / Hello.c, V <- hello.c Enter Description, Terminated with single '.' Or end of file: NOTE: this is not the log message >> The Inital Verion. Enter information about file changes >>. End information Initial Revision: 1.1 Initial version is 1.1 DONE [Kerberos @ Power ZHYF] $ When the file is added to the source code warehouse, RCS will automatically delete file. If you need to modify the file, remove it from the warehouse: [Kerberos @ Power ZHYF] $ Co Hello.c RCS / Hello.c, V -> Hello.c Revision 1.1 DONE This time, the removed file is read-only, if needed Editing the file, you need to remove the file lock to prevent conflicts with others. Plock and remove the -L (LOCK) option. [Kerberos @ Power ZHYF] $ co -l hello.c rcs / hello.c, v -> Hello.c Remove Hello.c from the RCS warehouse, the file in the warehouse is ended at V. Revision 1.1 (Locked) Indicates that there is a chain to remove DONE, we can modify and edit the file. For example: #include int main (void) {Printf ("Hello World / N"); Printf ("CheckoutwithLock / N"); add code return 0;} [kerberos @ Power ZHYF] $ CI Hello .c rcs / hello.c, v <- hello.c new revision: 1.2; Previous Revision: 1.1 Re-add to the warehouse, file version is incremented to 1.2 Enter log message, Terminated with single '.' or end of file:> > Check out with lock and modified it. >>. DONE If you need the previous Hello.c, it is 1.1 version, you can use -r to specify the version of the removal file: [Kerberos @ Power ZHYF] $ Co -L - R1.1 Hello.c Hello.c, V -> Hello.c Revision 1.1 (Locked) Remove the 1.1 version DONE can attempt to use two lockout, this time, RCS will prompt the message. [Kerberos @ Power ZHYF] $ co -l hello.c Hello.c, V -> Hello.c Revision 1.1 (Locked) Writable Hello.c exists; remove it? [NY] (n) Overwrite the current Hello. c If you answer n, remove the failure, the answer is that the option to override the current file and -l is -u, remove unlocked files for work. -f is forced to cover files in the RCS warehouse while CI, enhances the current files at CO.

In RCS, support keywords similar to macros, these keywords are replaced by RCS with specific information, such as $ ID $ Keywords: / * $ ID * / #include int main (Void) {Printf ("Hello World / N"); Printf ("CheckoutwithLock / N"); return 0;} CI, then take it, the file will become: / * $ ID: Hello.c, v 1.3 2001 / 02/22 16:16:58 Kerberos Exp Kerberos $ * / #include int main (void) {Printf ("Hello World / N"); Printf ("Check Out with Lock / N"); Return 0;} $ ID $ keyword is replaced with file name, version, time, author, and code nature. If you use the -l option, you will add the name of the login user later. In addition to the $ ID $ keyword, RCS also supports the keywords commonly used below: $ log $: The modification log information you provide. $ Author $: Store the author of this version. $ Locker $: This version of the locks $ State $: This version of the status Exp (Test version), Stabe, REL (release). The default is exp $ DATE $: The version is deposited Using the UTC time format. $ REVISION $: This version of the version number $ rcsfile $: RCS File Name $ Name $: Retrieve this version of the symbol name $ Header $: equivalent $ SOURCE $$ Revision $$ Date $ $ Author $$ State $$ Locker $$ There is a DIFF tool in UNIX / Linux to compare the difference between two files, and RCSDiff can compare the files between different versions, without having to remove files, such as: rcsdiff Hello .c compares the difference between the latest version of the Hello.c file and the RCS warehouse. Rcsdiff -r1.1 Hello.c compares the difference between the Hello.c file and the Hello.c version of the version. Rcsdiff -r1.2 -r1.1 compares the difference between the Hello.c files and 1.2 versions. Use this command to make it easy to make a patch file between any versions. In addition, there are other uncommon-use RCS commands, readers can refer to more detailed information. Use the following we will talk about the use and management of CVS. Before using CVS, you must specify the root path of the CVS, unlike the RCS working in the RCS directory in the working directory. There are two ways to specify the CVS path, one is specified using the CVS-D option, such as: cvs -d / home / kerberos / cvsroot specifies the path to the CVS warehouse. The other is specified using a cvsroot environment variable (under Bash): EXPORT CVSROOT = / home / kerberos / cvsroot No matter what way, whenever a terminal session is re-opened, the path to the CVS warehouse must be reset, you can put the above The latter adds to the .bashrc file in its actual directory, so that the terminal session is turned on, it does not need to be reset (this is true for other environment variables).

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

转载请注明原文地址:https://www.9cbs.com/read-39946.html

New Post(0)