Full analysis of CVS installation configuration and operation command under Linux

Time:2021-5-3

Before introducing the CVS command, let’s talk about something else
As previously said, in addition to the Leyuan file, the warehouse also includes a series of management files. Located at $cvsroot / cvsroot
Modify the management file method is equivalent to the source code file, using CVS command extraction and modification
The purpose of each file is described below:

Checkoutlist supports other management files in cvsroot directory, and allows setting information for various CVS commands
Commitinfo when the CVS commit command is executed, this file specifies the command to be executed when the file is submitted
Cvsweepers defines a wrapper that is executed when a file is registered or retrieved
Editinfo allows you to execute scripts after log information is recorded before the commit command starts
History tracks all commands that affect the warehouse
LogInfo is similar to coimmitinfo, only executed after the file is submitted
Modules allows you to define a symbol for a group of files, otherwise you must define a symbol for each file to be referenced
Specifies the partial pathname (relative to $cvsroot)
Nitify controls notifications from / “watch /” / “watch /” by / “CVS watch add /” and / “CVS edit /”
set up
Rcsinfo specifies a template for commit log replies
Taginfo defines the program to be executed after any “tag /” operation

Installation of CVS server
By default, CVS is installed in RedHat Linux. This can be done by running CVS on the Linux command line

Copy code

The code is as follows:

rpm –q cvs

If the version information of CVS appears, the installation is successful.
CVS server installation package can be downloaded from many places on the Internet, or from CVS official website. According to the system you are using, download the corresponding version and then install it. Because our project is to use CVS server for version management under RedHat Linux, this article will mainly introduce it based on RedHat Linux. First, download the RPM package of the CVS server. Of course, you can also download other packages, such as the source package, and then install them by using the following command:

Copy code

The code is as follows:

rpm -ivh cvs-1.11.7-1.i386.rpm

Configuration of CVS server
       The first thing after installation is to configure the configuration file of CVS server to make it work normally. First, add cvsp server to the / etc / services file to make it a Linux service, that is, the entry of CVS server routine. The configuration is as follows:
cvspserver          2401/tcp                           # cvs client/server operations
cvspserver          2401/udp                          # cvs client/server operations
If the above two lines already exist in the file, there is no need to add them.

Configure xinetd and start CVS verification server with xinetd
Enter the / etc / xinetd.d/ directory, and then edit a text file. The name must be consistent with the entry name cvspserver in / etc / services. Therefore, cvspserver is used as the file name. The contents of the file are as follows:

Copy code

The code is as follows:

service cvspserver
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/bin/cvs
server_args = -f –allow-root=/usr/cvsroot pserver
log_on_failure += USERID
}

After editing the file, test whether the cvsp server service is configured successfully.
implement

Copy code

The code is as follows:

/etc/init.d/xinetd restart

Restart the service. After successful startup, execute the following statement to verify whether the service starts normally:

Copy code

The code is as follows:

telnet localhost 2401

If the following words appear:
Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.
Enter hi to continue to output the following words
cvs [pserver aborted]: bad auth protocol start: hi
Connection closed by foreign host.
The above phenomenon indicates that the CVS user authentication server has been configured successfully.
If the following words appear, it means that the configuration is not successful. Please check the above configuration again:
Trying 127.0.0.1…
telnet: connect to address 127.0.0.1: Connection refused

Environment variables of CVS

CVS uses several environment variables

Full pathname of the root directory of cvsroot warehouse
If cvsread is set, it indicates that all files are set to read-only during checkout
Cvsbin CVS uses many RCS commands to specify the path of RCS tool
Cvseditor specifies the editor that users use to write log information
CVS_ The name of the shell used by RSH to start a remote CVS server
CVS_ Server determines the name of / “CVS server /”, and the default is CVs
Cvswrappers cvswrapper script, used to specify the wrapper file name

keyword
A technique for managing source files is called / “keyword replacement /”. After each operation of / “CVS commit /”
Some keywords in the source file are replaced with available words

$auto $user name
Time of $data $registration
The first part of the $header $standard contains the full pathname, date, and author of the RCS
$ID $is the same as $header $except RCS file name is incomplete
$log $contains the full pathname, version number, date, author and log information provided at the time of submission
$rcsfile $contains the file name of RCS, not the path name
Version number assigned by $revision $
The full name of the $source $RCS file
The state of the version allocated by $state $is allocated by CVS admin – S

Example:
Before CVS commit, in main. C
static char *rcsid=/”$Id$/”;
After executing CVS commit
Main. C changed to:
static char *rcsid=/”$Id: main.c,v 1.2 1999/04/29 15:10:14 trimblef Exp$/”;

Let’s start with CVs commands
We have taken the data of the following warehouse as an example
$CVSROOT
–CVSROOT
–project
–src
–main
–main.c
–main.h
–print
–print.c
–print.h
–term
–term.c
–term.h

CVS checkout command

Extract the specified file from the warehouse to the current directory, establish the same structure, and create the CVS directory
example

Copy code

The code is as follows:

bash$ cvs checkout project
bash$ cvs checkout project/src/main

For convenience, we can create an abbreviation for a directory by modifying the
Modules file. (complete with CVs command, of course)

Copy code

The code is as follows:

cvs checkout CVSROOT/modules
cd CVSROOT
vi modules

We add the

Copy code

The code is as follows:

src project/src
print project/src/print

cvs commit
In the future, we can use CVS checkout print instead
cvs checkout project/src/print

The default of CVS checkout command is to get the latest version. We can also get an old version

Copy code

The code is as follows:

cvs checkout -r 1.1 print

Print version 1.1 of the code out
See the output of CVS – H checkout for the detailed usage of CVS checkout

CVS commit command
After modifying the file, submit it to the warehouse with CVs commit

Copy code

The code is as follows:

cvs commit -m /”Update by xxxxx/” project
cvs commit -m /”Update main.c/” main.c

After submitting, the current version number will be updated. For example, the original version number is 1.1, and the current version number is 1.2
The main trunk of the warehouse
-If the – M option is not specified, in the environment variable cvseditor
The editor specified in is called (VI is the default), prompting you to type text and modify record comments

CVS update

CVS allows multiple people to modify a file at the same time
Suppose you are modifying a part of the file. Now you want to merge and update your local copy (checkout) and
The changes made by another person (already in the warehouse) can be updated with CVs

Copy code

The code is as follows:

cvs update

CVS tag , CVS rtag

Creating a branch allows users to modify some files without affecting the trunk (when commit)
Creating a branch first creates a tag for some files to be modified. The tag is a symbol assigned to a file or a group of files. In the life cycle of source code, files that make up a group of modules are assigned the same tag

Create tag: execute CVS tag in the working directory
Example: create a label for SRC:

Copy code

The code is as follows:

cvs checkout src
cvs tag release-1-0

After the label is created, you can create a branch for it:

Copy code

The code is as follows:

cvs rtag -b -r release-1-0 release-1-0-path print

-B: create branch
-R release-1-0: Specifies the label that exists
Releases-1-0-patch: branches
Print: module name

merge
Use CVS update – J option to merge changes on branch with local file copy

Copy code

The code is as follows:

cvs update -j release-1-0 print.c

cvs release
After making necessary modifications to the source file, you can use CVS release to delete the local working copy
And inform other developers that this module is no longer used

Copy code

The code is as follows:

cvs release -d print

-D: delete
Print: Directory

conflict
Because CVS allows multiple people to modify the same file at the same time, conflicts are inevitable
When modifying the same line of the same file at the same time
At this time, if CVS update is used, CVS will detect the existence of conflict, and it will update the conflicting code
Use / “< < < < < < < /”, / “> > > > > > > > > > > /” to mark. At this time, you need to handle this code manually
After the developer negotiates the conflict and modifies the file, it can be submitted with CVs commit

Recommended Today

Large scale distributed storage system: Principle Analysis and architecture practice.pdf

Focus on “Java back end technology stack” Reply to “interview” for full interview information Distributed storage system, which stores data in multiple independent devices. Traditional network storage system uses centralized storage server to store all data. Storage server becomes the bottleneck of system performance and the focus of reliability and security, which can not meet […]