[Reprinted] use of CVS

Source: Internet
Author: User
Tags bug tracking system ssh port ssh server version control system
Author: chelong chedong@bigfoot.com

Last Updated: 13:50:00

Copyright statement: You can reprint it at will. When you reprint it, be sure to indicate the original source and author information.

Keywords: CVs Cvsweb cvstrac wincvs cvsroot

Overview: CVS is a C/S system. Multiple developers use a central version control system to record file versions to ensure file synchronization. The working mode is as follows:

CVS server (file version Library)
/|/
(Same step for Version)
/|/
Developer 1 developer 2 Developer 3

The main content of this article: You can select 2, 6 for beginners, And the CVS administrator needs to know more, finally, we briefly introduced the use of CVS clients in windows, the selection of remote user authentication, and the integration with the Bug Tracking System and other development environments.

Initialize the CVS environment: Set up the administrator of the CVS Environment
Routine Use of CVS: the most commonly used CVS command in daily development, developer Administrator
Branch development of CVS: The project is administrator Based on Different progress and target concurrency
CVS user authentication: Remote User Authentication through SSH, secure, simple Administrator
Cvsweb: CVS Web access interface greatly improves code version comparison Efficiency Administrator
CVS Tag: add $ header $ to code comments to facilitate tracking of developers in the development process
CVS vs VSS: Comparison between CVs and virsual sourcesafe, developer Administrator
Wincvs: Set wincvs Authentication through SSH
Group collaborative development of CVS: the development environment is set up at the Development Group level. cvstrac is used to implement CVS user management on the web interface and integrated BUG Tracking and Wiki communication.
20% of a system's functions often meet 80% of the requirements, and CVS is no exception. The following are the most common features of CVs, and may not reach 20% of all its command options, more functions can be used in the actual application process. You can learn how much you want to use. From time to time, let's look back and see what we often get.

CVS environment Initialization
================

Environment setting: Specifies the path of the CVS library cvsroot
Tcsh
Setenv cvsroot/path/to/cvsroot
Bash
Cvsroot =/path/to/cvsroot; export cvsroot

The remote CVS server settings are also described below:
Cvsroot =: ext: $ USER@test.server.address # port:/path/to/cvsroot cvs_rsh = SSH; export cvsroot cvs_rsh

Initialization: the initialization of the CVS version library.
CVS init

First import of a project
CVS import-M "write some comments here" project_name vendor_tag release_tag
After execution: all source files and directories will be imported to the/path/to/cvsroot/project_name directory.
Vender_tag: developer tag
Release_tag: Version release tag

Export Project: Export Code from the CVS Library
CVS checkout project_name
CVs will create the project_name directory and export the source code of the latest version to the corresponding directory. Check out in this checkout and virvual sourcesafe is not a concept. The check out in virvual sourcesafe is CVS update and check in is CVS commit.

Routine Use of CVS
==================

Note: after the first export, instead of Synchronizing files through CVS checkout, you need to go to the project_name directory exported by CVS checkout project_name for version synchronization of specific files (ADD, modify, delete) operation.

Synchronize files to the latest version
CVS update
If no file name is specified, CVs will synchronize the files in all subdirectories. You can also specify a file name/directory for synchronization.
CVS update file_name
It is recommended that you do this once a day before starting work or importing your work to the CVS repository, and develop the habit of "Synchronize and modify", which is different from virvual sourcesafe, CVS does not have the concept of File Locking. All conflicts are resolved before commit. If someone else modifies them and commit them to the CVS database, CVs will notify you of file conflicts and automatically use
>>>>>>
Content on CVS server
<
Content in your file
>>>>>>
Mark the conflict content.
Version conflicts are generally caused by modifying one file by multiple people, but such project management problems should not be solved by CVS.

Confirm to write the modification to the CVS Library
CVS commit-M "write some comments here" file_name

Note: many actions of CVs are confirmed and modified through CVS commit. It is best to modify only one file at a time. Before confirming the modification, you also need to enter the modification notes to help other developers understand the reasons for the modification. If you directly confirm 'cvs commit file_name 'without writing-M "Comments", CVs will automatically call the system's default text editor (usually VI) to write comments.
The quality of comments is very important: So not only do you have to write, but you also have to write something meaningful: to make it easier for other developers to understand.
It is difficult for other developers to quickly understand bad comments, such as-M "bug fixed" or-m ""
Good comments can even be used in Chinese:-M "added email address verification during user registration"

Modify a version comment: it is a good habit to confirm that only one file is sent to the CVS library at a time, but sometimes you forget to specify the file name and comment multiple files to the CVS library as well, the following command allows you to modify comments of a certain version of a file:
CVS admin-M 1.3: "write some comments here" file_name

Add File
After creating a new file, for example, touch new_file
CVS add new_file
Note: For images, Word documents, and other non-plain text projects, use the CVS add-B Option to import files in binary format. Otherwise, files may be damaged.
For example:
CVS add-B new_file.gif
CVS add-B readme.doc

Then confirm the modification and comment out
CVS ci-M "write some comments here"

Delete an object
After a source file is physically deleted, for example, RM file_name
Cvs rm file_name
Then confirm the modification and comment out
CVS ci-M "write some comments here"
The method for merging the preceding two steps is as follows:
CVS Rm-F file_name
CVS ci-M "why delete file"
Note: Many CVS commands are abbreviated to commit => Ci; update => up; checkout => Co/get; remove => RM;

Add directory
CVS add dir_name

View modification history
CVS log file_name
CVS history file_name

View differences between different versions of the current file
CVS diff-r1.3-r1.5 file_name
View the differences between the current file (which may have been modified) and the corresponding file in the library
CVS diff file_name
The CVS Web interface provides a more convenient way to locate the differences between file modification and version comparison. For specific installation settings, see the Cvsweb usage later.

The correct method to restore the old version through CVS:
If CVS Update-r1.2 file. Name is used
This command adds a stick tag to file. Name: "1.2", although you only want to restore it to version 1.2.
The correct method to restore the version is: CVs Update-p-r1.2 file_name> file_name
If you have accidentally added the stick tag, use CVS Update-a to solve the problem.

Rename a mobile file/File
CVS does not include CVS move or CVS rename, because these two operations can be implemented by first CVS remove old_file_name and then CVS add new_file_name.

Delete/move a directory
The most convenient method is to allow the Administrator to directly move and delete the corresponding directories in the cvsroot (because the subdirectories of a CVS project are independent, they can all be used as new independent projects under the $ cvsroot directory: similar to a tree, in fact, any shard can survive independently). After modifying the directory, ask its developers to re-export the project CVS checkout project_name or use CVS Update-DP for synchronization.

Project release export source files without the CVS directory
During development, you may notice that CVS creates a CVS/directory under each Development Directory. There are files used to record the corresponding information between the current directory and the CVS library. However, when a project is released, you generally do not want to include the file directory with the CVS directory containing CVS information. This one-time export process uses the CVS Export command, however, export can only be exported for one tag or date, for example:
CVS export-r release1 project_name
CVS export-D 20021023 project_name
CVS export-D now project_name

CVS branch: synchronous development of multiple branch projects
==================================

Confirm version milestones: multiple files have different version numbers. When a project reaches a certain stage, you can specify a milestone version number for all files to export the project according to the milestone version number, it is also the basis for the development of multiple branch projects.
CVS tag release_1_0

Start a new milestone:
CVS commit-R 2 mark all files and start development in 2.x

Note: The revsion in CVS does not have a direct relationship with the released version of the software package. However, it is easier to maintain the version of all files with the same version as the released version.

Build a version Branch
When the 2.x version of the Development Project is found to have a problem with 1.x, but 2.x does not dare to use it, export a branch release_1_0_patch from the milestone marked earlier: release_1_0
CVS rtag-B-r release_1_0 release_1_0_patch proj_dir

Some people first export the release_1_0_patch branch in another directory: solve the urgent problem in 1.0,
CVS checkout-r release_1_0_patch
Others are still developed on the main branch 2. x of the project.

Correct the error on release_1_0_patch and mark a 1.0 Error Correction version.
CVS tag release_1_0_patch_1

If 2.0 thinks that these errors are also required to be modified in 2.0, you can also merge the changes in release_1_0_patch_1 in the Development Directory of 2.0 to the current code:
CVS Update-J release_1_0_patch_1

Remote Authentication of CVS: Remote Access to CVS through SSH
======================================

It is difficult to use pserver-based Remote Authentication in CVS. You need to define the server and user group, user name, and password, which is insecure, therefore, it is better to authenticate the local account and transmit it over ssh. You can set the content in the/etc/profile of the client:
Cvsroot =: ext: $ USER@test.server.address # port:/path/to/cvsroot cvs_rsh = SSH; export cvsroot cvs_rsh
All local users of all clients can map to corresponding accounts with the same name on the CVS server.

If the ssh port on the server where CVS is located is not the default 22, or is inconsistent with the default ssh port on the client and the CVS server, it is sometimes set:
: Ext: $ USER@test.server.address # port:/path/to/cvsroot

The error message is as follows:
SSH: Test. server. Address # port: Name or service not known
CVS [checkout aborted]: End of file from server (consult abve messages if any)

The solution is to make a script to specify port redirection (if alias is not available, the file cannot be found ):
Create a/usr/bin/ssh_cvs file:
#! /Usr/bin/sh
/Path/to/ssh-P 34567 "$ @"
Then: chmod + x/usr/bin/ssh_cvs
And cvs_rsh = ssh_cvs; export cvs_rsh

Note: Port refers to the SSH port of the corresponding server, not the CVS pserver Port

Cvsweb: Improves file browsing efficiency
======================================

Cvsweb is the CVS Web interface, which can greatly improve the efficiency of programmers in locating and modifying:
The sample can be seen: http://www.freebsd.org/cgi/cvsweb.cgi

Download Cvsweb: Cvsweb has evolved from the original version into a richer multi-functional interface version. This is my personal feeling that the installation settings are more convenient:
Http://www.spaghetti-code.de/software/linux/cvsweb/

Download and unpack:
Tar zxf Cvsweb. tgz
Put the configuration file Cvsweb. conf in a safe place (for example, in the same directory as Apache configuration ),
Modify: Cvsweb. cgi allows CGI to find the configuration file:
$ Config = $ ENV {'cvsweb _ config'} | '/path/to/Apache/CONF/Cvsweb. conf ';

Go to/path/to/Apache/conf and modify Cvsweb. conf:

Modify the cvsroot path settings:
% Cvsroot = (
'Development' => '/path/to/cvsroot', # <= Modify the local cvsroot
);
By default, deleted documents are not displayed:
"Hideattic" => "1", # <= The deleted document is not displayed by default.
You can also customize the description of the page header in the configuration file Cvsweb. conf. You can modify $ long_intro to the text you need.
Cvsweb cannot be opened to all users at will, so Web user authentication is required:
Mr. Cheng passwd:
/Path/to/Apache/bin/htpasswd-C Cvsweb. passwd user

Modify httpd. conf: add
<Directory "/path/to/Apache/cgi-bin/Cvsweb/">
Authname "CVS authorization"
Authtype basic
Authuserfile/path/to/Cvsweb. passwd
Require valid-user
</Directory>

CVS tags: Who? When?
================================

Adding $ ID $ to the comments at the beginning of a program file is a good habit. CVs can automatically update the content to the format of file_name version time user_name, such as cvs_card.txt, v 1.1 2002/04/05 04:24:12 chedong exp. You can learn about the last modification and modification time of the file.

Several common default files:
Default. php
<? PHP
/*
* Copyright (c) 2002 company name.
* $ Header $
*/

?>
==========================================
Default. Java: note the differences between the/* Start javadoc annotation and/** in the file header.
/*
* Copyright (c) 2002 mycompany name.
* $ Header $
*/

Package com. mycompany;

Import java .;

/**
* Comments here
*/
Public class default {
/**
* Comments here
* @ Param
* @ Return
*/
Public tostring (){

}
}
==========================================
Default. Pl:
#! /Usr/bin/perl-W
# Copyright (c) 2002 company name.
# $ Header $

# File comments here

Use strict;

CVS vs VSS
==============

CVS does not have the file lock mode. vss simultaneously records the file to be locked by the Export owner while checking out.

CVS update and commit, VSS is get_lastest_version and check in

The CVS corresponding to the checkout/undo check out of VSS is edit and unedit.

In CVs, the automatic update function is enabled by default, which also brings about a potential problem, if you do not use the-kb method to add binary files, the files may become invalid when CVS is automatically updated.

In virsual sourcesafe, this function is called keyword explaination. It is disabled by default and needs to be opened through opition, and the type of keyword scanning for source files is specified :*. TXT ,*. java ,*. HTML...

Tags common to both virsual sourcesafe and CVs are:
$ Header $
$ Author $
$ Date $
$ Revision $

Use common keywords whenever possible to ensure that code can be easily tracked in CVs and VSS.

Wincvs
======

Download:
CVS Windows Client: stable version 1.2
Http://www.wincvs.org/
SSH Windows Client
Http://www.networksimplicity.com/openssh/

After the above two software are installed:
Admin ==> preference settings of the wincvs Client
1. In the general menu
Set cvsroot: username@192.168.0.123:/home/cvsroot
Set authorization: Select SSH Server

2 Port
HOOK: Check for alternate RSH name
Set the ssh.exe path, which is installed in C:/program files/networksimplicity/ssh/ssh.exe by default.

Then you can use wincvs to perform the CVS operation. All operations will jump out of the command line window and require you to enter the authentication password on the server.

Of course, if you think this is annoying, another way is to generate a public/private key pair without a password, and set CVS to use SSH Authentication Based on the Public Key/private key (in the general menu ).

Optional diff tool: examdiff
Download:
Http://www.prestosoft.com/examdiff/examdiff.htm
In the wincvs menu admin ==> preference, choose wincvs.
Selected: externel diff Program
And set the diff tool path, such as: C:/program files/ed16i/examdiff.exe
When diff is applied to a file, you need to select use externel diff in the lower right corner of the window for the first time.

Establish a group development environment based on CVs
======================================

As a group-level development environment, Version Control Systems and bug tracking systems all involve user authentication. How to easily integrate these systems is a very interesting thing. After all, we cannot expect a version control/BUG Tracking integration system that is as highly integrated as source offsite in Linux.

I personally disagree with remote user authentication in pserver mode. However, if most of the team members use Windows clients for development, it is still difficult to avoid cvsroot/passwd authentication in general, however, it is troublesome to manage CVS users. I was going to write a management interface using Perl myself until I found cvstrac, a web-based bug tracking system that is plug-in to the CVS system, it also includes the management of cvsroot/passwd files on the web interface, and even integrates the wikiwiki function.

Here we will first talk about user authentication in the pserver mode of CVS. The user authentication service of CVS is based on inetd:
Cvspserver stream tcp Nowait nobody/usr/bin/CVS CVs -- allow-root =/home/cvsroot pserver
Generally, port 2401

The CVS user database is based on the cvsroot/passwd file. The file format is as follows:
[Username]: [crypt_password]: [mapping_system_user]
Since the passwords are all encrypted using the UNIX standard crypt, the format of this passwd file is basically an extension of the Apache htpasswd format (one more system user ing field than the Apache passwd file ), therefore, this file can be used in the simplest way.
Apache/bin/htpasswd-B myname mypassword
Create. Note: The file created by using htpasswd does not have a field mapped to the System user.
For example:
New: gebvosup/zkl2
Setup: aisqunaaoy3qw
Test: hwepz/BX. redu

The purpose of ing system users is: you can create a dedicated CVS service account, such as CVS, and grant all permissions under the/home/cvsroot directory to this user, create different development user accounts in the passwd file, but the final file read and write permissions of the development user account are mapped to CVS users, this avoids the permission of multiple developers to read and write files of other users after creating files in SSH mode.

Further, You can map users to two groups of users, and use the permission settings of two users to avoid mutual access to files in two project groups.
New: gebvosup/zkl2: proj1
Setup: aisqunaaoy3qw: proj2
Test: hwepz/BX. redu: proj1

Cvstrac solves the problem of managing cvsroot/passwd. It also includes a bug tracking report system and integrated wikiwiki communication functions. It is installed using CGI and based on GNU Public License:

Installation Process

Download: http://www.cvstrac.org/unpack, copy to/usr/bin/cvstrac
Run the following command on the installed CVS server (assume that the CVS library has been initialized in/home/cvsroot using CVS init ):
Cvstrac init/home/cvsroot myproj
After running,/home/cvsroot will have a default myproj. DB Library
Create the following script cvstrac in the Apche/cgi-bin directory:
#! /Bin/sh
/Usr/bin/cvstrac cgi/home/cvsroot
Set the cvstrac executable.
Go to http://cvs.server.address/cgi-bin/cvstrac/myprojto enter the management interface.
Add the cvspserver service to inetd:
Cvspserver stream tcp Nowait nobody/usr/bin/CVS CVs -- allow-root =/home/cvsroot pserver
Note: the purpose of setting the user to nobody is the same as that of the Apache running user, this user must initialize the myproj generated by cvsroot/passwd and cvstrac under/home/cvsroot. DB has read and write permissions.
General users can also:
Http://cvs.server.address/cgi-bin/cvstrac/myproj
Change the logon password, record the bug report, and learn more about the usage details.

Use passwd file on server side mode to log on to wincvs.

Summary:

CVS + (wincvs/Cvsweb/cvstrac) is used to form a relatively complete cross-platform workgroup development environment.

Related Resources:

CVS home:
Http://www.cvshome.org/

Cvs faq:
Http://www.loria.fr /~ Molli/cvs-index.html

Related Websites:
Http://directory.google.com/Top/Computers/Software/Configuration_Management/Tools/Concurrent_Versions_System/

CVS free book:
Http://cvsbook.red-bean.com/

Quick query card of CVS command:
Http://www.refcards.com/about/cvs.html

Wincvs:
Http://www.wincvs.org/

Cvstrac: A web-based bug and patch-Set Tracking System for CVS
Http://www.cvstrac.org/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.