Part 1 configure the CVS server (in version 1.10)
Author: Wu yanxi Email: Yanxi-Wu@21cn.com
1. CVs brief and install the CVS server:
CVS is a popular and excellent version management and control tool. It is favored by most developers and systems, and is also used to manage other daily documents (such as Word workers ). Composition Files. This section briefly introduces the installation, configuration, and usage of the CVS server to help you use cvs for version management and control as soon as possible.
2. Install the CVS server
The CVS server version can be downloaded from many places on the Internet or from the official website of CVS. Download the corresponding version based on your system and install it. Most people use the CVS server for Version Management in Linux, and RedHat Linux is one of the most popular Linux distributions. Therefore, this article will focus on Redhat Linux. First, download the RPM package of the CVS server. Of course, you can also download packages of other methods, such as the source Program Package, which is one of the advantages of Linux. Run the following command to install the SDK:
Rpm-IVH cvs-1.10.8-3.i386.rpm
3. Configure the/etc/services file:
The first thing after installation is to configure the configuration file of the CVS server so that it can work properly. First, add the cvspserver to the services file to make it the entry to a Linux service, that is, the CVS server routine. The configuration is as follows:
Cvspserver 2401/tcp # CVS client/server operations
Cvspserver 2401/udp # CVS client/server operations
4. Configure xinetd and use xinetd to start the CVS server:
Enter/etc/xinetd. d/directory, and then edit a text file. The name must be the same as that in/etc/services. Therefore, cvspserver is used as the file name. The file content is as follows:
Service cvspserver
{
Disable = No
Socket_type = stream
Wait = No
User = root
ENV = home =
Server =/usr/bin/CVS
Server_args =-f -- allow-root =/home/cvsroot pserver // specify the authentication method as pserver. Note:-F
}
Note: The names of A and service must be the same as those of the CVS service in the/etc/service file;
B. Env = home = The purpose of this line is to solve the read/root/generated when performing some CVS operations /. cvsignore file error. The above env line indicates that the environment variable home is left blank when the CVS service is running, although the user executing CVS is root, however, because the environment variable home is not available, CVs will not read/root /. cvsignore file.
5. Configure the owner and group of the CVS user and cvsroot:
First, create a user group CVs, which can be named by groupadd or addgroup, or you can directly edit the/etc/group file to add this group, and then add a user cvsroot, then modify the/etc/passwd file so that the default group of the cvsroot user is the CVS group, rather than the cvsroot group (that is, the modification ). Create the cvsroot directory in the/Home Directory (you can also create it in another directory you like), and then modify the owner and attributes of/home/cvsroot:
# Chown cvsroot. CVS/home/cvsroot
# Chmod 771/home/cvsroot
6. initialize:
Another important thing after installing the CVS server is to initialize the root directory of the CVS server. The CVS projects created in the future will be created under this directory. The command used is as follows:
# CVS-D/home/cvsroot init
In this way, the directory/home/cvsroot becomes the root directory of the CVS server, and the directories created later will be stored in this directory by default.
7. log on to the CVS server (in Linux or other UNIX systems ):
A. Use the following syntax for remote Logon:
# CVS-D: pserver: cvsroot @ host:/home/cvsroot Login
CVS password: // enter your cvsroot password;
If no other prompt is displayed, the logon is successful. Otherwise, modify the prompt accordingly. The following describes the syntax of the logon command:
Pserver indicates that the pserver method is used for user logon authentication. Generally, CVS servers use this method.
Of course, you can also use other methods. For details, refer to the relevant materials;
: Cvsroot indicates the user name to log on to. It can be used as long as it is a member of the CVS group, for example, Cather;
@ Host indicates the server to log on to. It can be a DNS name or an IP address, for example, 10.104.1.204;
:/Home/cvsroot indicates the directory of CVS on the server, or it can be another directory (by your
Specifies the directory used for init initialization );
Tip: You can also put the export cvsroot =: pserver: jchuang@192.168.0.8:/home/cvsroot sentence straight
It is written in the user's initialization file (for example,. bash_profile), so that each time you log on, you only need to enter:
# CVS Login
Enter a password to log on to the CVS server.
B. For local logon, you can directly write the export cvsroot =/home/cvsroot statement in the user's initial
The initial file is shown in. bash_profile.
8. Add a new project module to CVS
Generally, we already have one or more projects, so that we can use the following steps to generate a new CVS project. Place a project file in CVS for version control, which is called import in CVS terminology ). We can see from the name that some preparations need to be made before the import.
The basic requirement for input operations is to have a "clean" directory structure. "Clean" means that all files that do not require version control are removed (such as compiled files and backup files ). This is important if the project has started for a while. Some files in the directory may not be placed under version control, but you want to put them here. In this case, you need to remove them before entering them, and then move it back.
Note that CVS deems that the empty directory does not exist. To add a directory that does not contain files but does not contain subdirectories, you need to create a dummy file under it. We recommend that you create a file named readme.txt with a brief description of the directory.
Enter the directory of an existing project, such as cvstest:
$ CD cvstest
Run the following command to import the project file to the CVS Repository:
$ CVS import-M "This Is A cvstest project" cvstest v_0_0_1 start
Description: import is one of the CVS commands, indicating to input the project file to the CVS warehouse.
-The string following the M parameter is the description text to describe the project. If the-M parameter is not added, CVs will automatically run an Editor (usually VI, however, you can change the environment variable editor to the editor you like to use. You can enter information. cvstest is the project name (actually the repository name, it will be stored in the warehouse named after this name on the CVS server)
V_0_0_1 is the total mark of this branch. Useless (or not commonly used)
Start indicates the input level mark of each import Identity file, which is useless.
In this way, a CVS module named cvstest is created under the/home/cvsroot directory specified by the user. Then, we can delete the file of this test project, test how to obtain files from the repository. Article .
(Note: This section mainly references "CVS server Quick Guide" from http://linuxaid.com.cn he Weiping ")
9. Check the corresponding modules on the local CVS server:
A. Run the following command on the computer where the CVS server is located:
# CVS checkout STW
In this way, the STW project module is checkout to the current directory.
B. If you are remotely running Linux or other UNIX systems, you can use the preceding command after logging on to MySQL 7th.
So that the corresponding project module is checkout to the current directory.
In addition, if you run the checkout command on Windows, you can use wincvs. You also need to perform other configurations on wincvs. The configuration method of wincvs is described in the next section.
Part 2 configuration and usage of wincvs
1. wincvs introduction:
Wincvs is a client software of CVS. It runs on Windows and is used to log on to the CVS server on Windows and perform operations and management related to CVS. Many enterprises currently use Linux/Unix as servers and windows as clients. Therefore, the combination of wincvs and the CVS server will constitute one of the most powerful version control and management systems.
2. Download and install wincvs;
The latest wincvs can be from http://sourceforge.net/project/showfiles.php? Group_id = 10072 address download to, you can also download to the latest or another version of wincvs on the http://sourceforge.net/project.
Download the corresponding version and install it according to the Wizard. If you want to use CVs, it should be okay to install this wincvs!
3. Configure wincvs:
A. For general options, select Admin-> preferences ..., The following page is displayed:
1. Authentication: used to configure the authentication method of the CVS server. You can select other authentication methods from the drop-down list. However, you only need to select the default pserver mode, note that the authentication method must be the same as that specified in the CVS server configuration;
2. Path: used to configure the main directory path of CVS on the server, that is, the directory for CVS Initialization on the server, such as/home/cvsroot;
3. Host address: used to configure the address of the server where the CVS server is located. It can be an IP address or DNS name, for example, 10.104.1.204;
4. User name: used to configure the username to use wincvs to log on to the CVS server, for example, cvsyxwu. The administrator must add the user to the CVS user group for logon;
V. cvsroot: This option generally does not require modification. When you enter the preceding options, the system automatically generates the corresponding content of this option based on your input.
B. Set Global Options. On the previous interface, select "globals ":
This configuration item mainly focuses on the following options:
First, do not select checkout read-only. OtherwiseSource codeThe user is not allowed
Modify, and this option is selected by default;
Second, do not select prune (remove) empty directories. Otherwise, the empty directory is automatically deleted;
Third, if there are no special requirements for general configuration, set dirty files support, supply control when adding
Select from the TCP/IP compression option;
4. log on to the server:
Select Admin> login. The following dialog box is displayed, asking the user to enter the logon password.
After entering the password, select "OK". If the configuration of the CVS server and wincvs is correct, the following prompt will be displayed in the CVS status bar:
CVS-Z9-D: pserver: cvsyxwu@10.104.1.204:/home/cvsroot Login
Logging in to: pserver: cvsyxwu@10.104.1.204: 2401/home/cvsroot
* ***** CVS exited normally with code 0 *****
Code 0 indicates that the logon is correct. If an error occurs, it is code 1, and you need to modify it according to the error prompt.
5. Check out the corresponding modules on the CVS server:
First, select the directory where the checkout module is to be stored in modules in workspace;
2. Select create-> checkout modeles. The following dialog box is displayed:
Among them, Module name and path on the server is the directory to store the checkout content, which is input by the user; and local folder to checkout to is the directory selected by the first user.
6. Submit the file to the CVS server after modification.
A) Only one user can modify the file.
Use your favorite editor to modify the file generated by checkout. The modified file will be red before it is submitted, for example, example. h file:
Select the red file example. h, right-click and select the "Commit selection" option. If no other user has modified the option and submitted it to the CVS server, the example will be executed normally. submit the H file to the CVS server and restore the icon to the original color.
B) When two or more users modify different parts of the same file
In this case, both user a and user B Checkout the file example. h. The content is as follows:
Int callby (INT count)
{
Printf ("excelstor! \ N ");
}
Void main (INT argv, char * argc)
{
// Added by my CVS
Printf ("I am Cather \ n ");
}
Int mainexample ()
{
Printf ("OK \ n ");
}
Then, user a is modified to the following and submitted to the CVS server (usually normal ):
Int callby (INT count)
{// Add
Printf ("excelstor! \ N ");
}
Void main (INT argv, char * argc)
{
// Added by my CVS
Printf ("I am Cather \ n ");
}
Int mainexample ()
{// Add
Printf ("OK \ n ");
}
Then modify user B to the following:
Int callby (INT count)
{// Add
Printf ("excelstor! \ N ");
}
Void main (INT argv, char * argc)
{
// Modified
Printf ("I am Cather \ n ");
}
Int mainexample ()
{// Add
Printf ("OK \ n ");
}
When user B selects "Commit selection", the following message is displayed:
CVS server: up-to-date check failed for 'example. H'
CVS [server aborted]: Correct abve Errors First!
This indicates that a user has modified the same file example. h and submitted it to the CVS server.
You must first select "Update selection" for the local example. h and example. H files on the CVS server.
Synchronization and merge. Select "OK" without selecting any options. The following figure is displayed:
CVS-Z9 update example. H (in directory c: \ my CVS \ STW \ SRC \)
RCS file:/home/cvsroot/STW/src/example. H, V
Retrieving Revision 1.5
Retrieving revision 1.6
Merging differences between 1.5 and 1.6 into example. h
M example. h
****** CVS exited normally with code 0 ******
indicates that the modification between user B and user a has been merged successfully, and the file example is also used. the H icon is also red, and the merged file is stored on user B's local machine. To update to the CVS server, you must also select example. h. Right-click and select "Commit selection" to submit the modified results of user a and user B to the CVS server. Note: M indicates that the file has been modified.
C) when two or more users modify the same part of the same file
This is because both user a and user B have downloaded the file example. h. Content:
void main (INT argv, char * argc)
{< br> printf ("I am Cather \ n ");
}< br> then user a changes the file to the following and submits it to the CVS server (normally, the file will be submitted normally):
void main (INT argv, char * argc)
{< br> printf ("I am Cather \ n");
printf ("I am pat \ n ");
}< br> then user B changes the file to the following:
void main (INT argv, char * argc)
{< br> printf ("I am Cather \ n");
printf ("I Love You Cather \ n ");
}< br> If user B selects "Commit selection" to submit the Modification result to the CVS server, the following error message is displayed:
CVS-Z9 commit-M "update in 11: 20" example. H (in directory c: \ my CVS \ STW \ SRC \)
CVS server: up-to-date check failed for 'example. h'
CVS [server aborted]: Correct abve Errors First!
* ***** CVS exited normally with code 1 *****
It indicates that the modification of user B conflicts with that of other users. In this case, select "Update selection". The following prompt is displayed:
CVS-Z9 update example. H (in directory c: \ my CVS \ STW \ SRC \)
RCS file:/home/cvsroot/STW/src/example. H, V
Retrieving revision 1.9
Retrieving revision 1.10
Merging differences between 1.9 and 1.10 into example. h
Rcsmerge: Warning: conflicts during merge
CVS server: Conflicts found in example. h
C example. h
* ***** CVS exited normally with code 0 *****
C In front of example. h indicates that there is a conflict with other users' modifications, and the file icon will display a "C", as shown below:
Double-click example. h to display the content of example. H, as follows:
Void main (INT argv, char * argc)
{
Printf ("I am yanxi \ n ");
Printf ("I am Cather \ n ");
<Example. h
Printf ("I Love You yanxi, too! \ N "); // This part is your Modification
========
Printf ("I Love You Cather! \ N "); // This part is modified by other users.
>>>>>>>> 1.10
}
In this case, you should negotiate with user a to determine the final modification. For example, you can change it:
Void main (INT argv, char * argc)
{
Printf ("I am yanxi \ n ");
Printf ("I am Cather \ n ");
Printf ("I Love You yanxi, too! \ N "); // This part is your Modification
Printf ("I Love You Cather! \ N "); // This part is modified by other users.
}
Select "Commit selection" for submission. The following prompt message is displayed:
CVS-Z9 commit-M "update in 11: 20" example. H (in directory c: \ my CVS \ STW \ SRC \)
Checking in example. h;
/Home/cvsroot/STW/src/example. H, v <-- Example. h
New Revision: 1.11; previous revision: 1.10
Done
* ***** CVS exited normally with code 0 *****
Indicates that user a and user's modifications have been merged successfully.
In this way, the problems encountered when submitting files to the CVS server are basically the same. You need to modify the files based on the actual problems encountered.
7. Add a new file to the CVS server
After adding a file locally, submit it to the server. Select the file, click "add", add the file, and select "Commit selection" from the context menu.
, Select the file example. h. bak, because example. h. bak is currently not a CVS file. In this case, the "Add button" is changed from "not available" to "available". Therefore, "noncvs file" is displayed in the status, and "Add button" is selected for example. h. the Bak icon turns red and adds a letter as follows:
Select example. H. Bak, right-click, and select "Commit selection" to submit the example. H. Bak file to the CVS server to become a CVS file.
8. Conclusion
Here, you can basically configure a practical CVS server and wincvs client for yourself or your company to use cvs for system development or version management and control of other documents.