Use CVS to manage your own procedures

xiaoxiao2021-03-06  15

From: http://www.china-pub.com Yao Ji Feng

Everyone who writes a program may have had such an experience: some modifications to the prepared program. After a few days, we may find that the last revision has led to other contradictions, and even compile cannot pass, but then we have It's hard to find where I have just changed. Generally speaking, we always want your own complete record of the process of developing the next program, and record every improvement and adjustment of this program. Perhaps we can use the backup method to solve this problem, so we build a backup directory, regularly or unregistered to put your source program to put your own program, and the entire hard drive is full by these files. This is certainly exaggerated, but this mechanism brings us that it is obvious. Further, now the development of a software product, a man's single gun is difficult to complete. It may be included in several, dozens of or even hundreds of programmers cooperative development. How to manage the source code? The method of solving the problem is to use CVS. CVS - Concurrent Versions System is a version control management system that is currently the most widely used system. From GFTP to GTK to KDE, you can almost see its trail in every source of free software you are familiar with (below we will know, its trace refers to a subdirectory called CVS). Similarly, you can also see the CVS system in almost every Linux release. It can be said that if there is a loss of CVS, many of the many multi-person collaboration, freely developed software will slow down their own development. What functions have cvs that make it so powerful? What can I do in CVS? As mentioned above, CVS is first a version management system that allows you to keep every version of the software development process, including who, when, what modifications, and why do such modifications. This feature is very similar to the previously popular version management system RCS (Revision Control System) and SCCS (Source Code Control System) of Linux and UNIX. But the function of CVS is far from this. Its biggest feature is its concurrency, which supports the development of distributed projects. Today, this feature is too important in the Internet swept. Small to an office interior to develop an OA system, large to the KDE group uses the Internet to develop new version of KDE, CVS can be exhibited. After a programmer develops a new version of the module, a quick version of the fastener allows each member of the development group to share their latest results through CVS. Even the CVS allows multiple programmers to simultaneously modify the same source program file through a specific mechanism. In addition, the CVS enhanced directory structure and good processing of binary files make it far better than other version management systems. Finally, it must be mentioned that CVS is based on RCS development. 2. How to get CVS? CVS is almost included in all Linux release versions, such as Redhat, Turbo Linux, Slackware, and Domestic Red Flag, Xteam Linux, etc. You can try to knock down the CVS command. In most cases, a bunch of information starting with USAGE: CVS, prompting you how to use CVS, which means that you have already had CVS on your machine, just regret that it has been Not discovered and utilized. If you are not lucky, you will see a message such as CVS: Command Not Found. This means that your machine does not have CVS installed. At this point you have two options. First, find your Linux installation disk, where CVS is installed there. For example, in Linux installed using RPM (in several release versions described above, in addition to Slackware, others) release, find cvs ***. Rpm, install with the RPM command.

The second way is to some site CVS source code, and then follow the inside of the guide to install, the reader required to access the site www.cyclic.com/ or http://www.loria.fr/~molli/cvs- INDEX.html. 3. Basic Usage of CVS In this section, let's learn some basic methods of use of CVS. Now we assume that CVS has been installed, and we plan to manage a software that you are developing, the software is called Netants, which is stored in a directory called Netants on the hard disk, and there is a file Netants.c, Netants .h, http.c, http.h and makefile. We did not cooperate with it to develop this software, nor did you use Internet or intranet to develop this software. Perhaps it is just an amateur work, trying to write a better download tool that is better than the network ants under Windows. 3.1 Initializing CVS We first want to use the command is cvs init, which is used to initialize the CVS system. As we have seen, all CVS commands start with CVS and then keep up with commands, parameters, and some options later. The initialization CVS system is mainly to create a source storage library used for CVS (Repository). When you create it, you need to specify this source storage library in that directory. There are two ways to specify the directory. First, use the "-d" option to specify, for example: -d / usr / local / cvsroot. Another more convenient method is to set a environment variable called CVSROOT in the shell. Users using CSH or TCSH can use command setENV to set, add the next line to the file .csh rc or file. Titenv cvsroot / usr / local / cvsroot Using SH or BASH users need to file .profile or Document. Add the following two lines: cvsroot = / usr / local / cvsroot export cvsRoot After setting the environment variable cvsroot, we run the command cvs init, and CVS will build some of the files you need under the specified directory, after we use Any item of CVS management will be stored under this directory by CVS. But don't pay attention to: Never try to modify files in this directory. This directory is managed by CVS yourself, and the rash change may cause you to lose your part or all of the source code or other resources managed by CVS. 3.2 Importing Projects To CVS After the initialization end, we must truly start using CVS to manage your own program network ants. In the first step, we will manage this project to manage. Use the following CVS's import command to import the source program into the source repository of the CVS: CD Netants CVS Import -m "Start My Project: Netants" Netants Yoyo Start This command seems complicated and needs to explain. Import is the import command of CVS. In the default, it is looped to import all files (including subdirectory) in the current directory to the source code library (ie, cvsroot specified directory). -m "Start My Project: Netants" tells CVS your description of this step. This is CVS forced demand, if you do not use this -m "string" option, CVS will pop up a text editor (if you do not specify, it is generally VI under Linux, and under Windows Yes Notepad, let you enter some explanations.

Netants is the path name when this project is stored by CVS, that is, CVS will create a directory of $ cvsroot / Netants and store files for this project in this directory. Of course, it is not the original storage, CVS will do one Fan. The last two strings set two tags (tags), and now there is nothing, but they are also required for CVS, so we add these two parameters. When you perform this command, CVS automatically sets all file versions to 1.1, which is the lowest version it thinks. The following is the display information after executing the above command: n Netants / Netants.c n Netants / http.c n Netants / http.h n Netants / Netants.h N Netants / Makefile No Conflicts Created by this import n Represents New, CVS success Loading these files did not find conflicts. The above command is slightly longer, and it is a bit cumbersome, I believe in me, CVS is not always like this, this "cumbersome" relative to it is completely negligible. 3.3 Exporting the project from CVS, we hand over your Netants' project to cvs to manage, now we can delete the original Netants directory of our code (of course, you should be done again. Backup and hope to be the last time). We have to develop, build a directory, what is called, it is called Worktmp. We entered this directory, execute the command CVS Checkout Netants, we will see the following information: CVS Checkout: Updating Netants U N N N N N N N N N N N N N N N N N N N N N N N Netants.c u Netants / Netants.h CVS creates a directory called Netants in the current directory, and our original code files have appeared in this directory, and there is more directory named CVS. The directory CVS is stored below some text files, records the location of CVSROOT, and this project corresponds to some information such as the directory in the source code library. 3.4 Save the Modified to CVS Now, we started a hard work programming. After dozens of minutes, hours and even days, we have made a big changes to the original code, and now I have to pay a paragraph. We submit the modified content to cvs, so we need to execute the command cvs commit -m "Made Some Useful Changes on Some File", we will see some prompt information, it scans and compare this directory Existing files and original files saved in the source library, modified files will be updated, and have a new version number: 1.2. -m parameter is as mentioned earlier, in order to do not want it to start a text editor to let yourself enter. If we only modify one of two files, we can attach the file name on the above command so that CVS will only compare, update the specified file. Note that the backup of yourself is different, and the CVS only saves the difference between different versions and does not save all versions. Now, if you think that CVS is a bit safe. 3.5 Adding a file to the project One day, we have begun to consider the function of downloading our network ants with the FTP site download file, so we need to add two files in the original project: ftp.c and ftp.h.

First, we build and edit, modify, generate these two files in the working directory, and then we use the command add command to add. CVS add ftp.c ftp.h At this point, the file is not really added, but it is equivalent to "registration", to make this process take effect, we still need to use the commit command: cvs commit ftp.c ftp.h - M "Add Two Files: ftp.c and ftp.h" At this point, CVS will add these two files to the project, and their version is initially 1.1.3.6 from the project to delete files In addition to adding, we Sometimes you may need to delete a file, for example, we find that the file Netants.h is actually not used. So, we do the following commands to complete the deletion: RM Netants.h CVS Remove Netants.h CVS Commit Netants.h -m "delete a file." To note that CVS just deletes the current version of Netants.h Its previous version still exists unless it happens to only version 1.1. 3.7 Setting a specific version number After a period of work, the program has begun to scale, forming a relatively stable version. At this time, Netants.c may already be a version 5.4, and http.c may be version 3.5, and we want to publish the current code for a version. At this point, we need to use the tag command. This command gives a version number of a given text form of a specified one or more files. The version number must begin with letters, which can contain numbers, underscores, and connection symbols (-). When we want to give all the files of the current project to the same version number, you may not specify file or path parameters, and CVS selects all files registered in the current directory (loop into the subdirectory). The following is an example: type command: CVS Tag Release0-1 Tip information: cvs tag: tagging. T makefile t ftp.c t ftp.h t http.c t http.h T Netants.c This is the current version of all files With a version called Release0-1. When we need this version, we use the -R (version code) parameter to get the specified version. For example, a command: cvs checkout -r release0-1 Netants will establish a Netants directory in the current directory and export all versions of the file that is release0-1. 3.8 Updating the file in the current working directory This is UPDATE, which will compare the files specified in the files and current directory in the CVS source code. If there is a higher version of the source file in the CVS source library, update the current The files in the directory. This feature is mainly used by multi-person cooperative development projects, allowing you to share the work of work in time. But it is another important purpose, which is equally applicable to single-developed projects. This use needs to use -j parameters, let's see the following example: CVS update -j 1.5 -j 1.3 Netants.c This command is in the current directory's Netants.c file, ignoring from version 1.3 to version 1.5 modify. There is no doubt that this is a very important feature for programmers. Because our modifications made to the program in a certain stage may be considered invalid and even errors now, this feature is well solved. In the update process, CVS performs an automatic merge process.

For example, the Netants.c file version in our working directory is 2.1, and we have made this file, and the CVS source library is version 2.2, when we execute the update command, CVS is not simple. The version 2.2 overrides version 2.1, but attempts to add a modification of the version 2.1 to version 2.2 to the file in the current directory. If it is conflict with the modification we have just made, CVS will ">>> > "Indicates that the user is expected to be modified by the conflict. CVS refuses to accept files that contain the above specific strings. The following is an example of a conflict: Netants.c: version number 2.2, saved in CVS ... getPartFile (); showfinished (); returnished (); return (a);} ... netants: version number 2.1 After we modified ... getPartfile (); return (b);} ... After we execute the command CVS Update Netants.c, new Netants.c: ... getPartFile (); showfinished (); >>>>>> 2.2 } ... Unless we make modifications and delete ">>>> ", Netants.c will not update the original version 2.2 when performing CVS Commit. 4. Other Functions of CVS CVS are of course more than what these contents mentioned above. These are only the basic functions of CVS, and CVS has many important functions. As mentioned above, support binary files, etc. Here we make a brief description of these functions. 4.1 CVS Network Working Mode CVS Network Function The CLIENT-Server structure is installed in both places. CVS works with RSH or password checking methods. Like the Client side, like the set environment variables CVSROOT, the user needs to set the new environment variable CVS_SERVER, indicating the path to the CVS on the Server, for example: / usr / local / cvsroot1. The CVS -D parameter specifies the path name, which can be used later: (Local or Server or EXT): indicates whether it is on the local or in the off-site server, the default is of course in local, as we used in initialization CVS. . The following command assumes that our CVS server is cvs.rdcps.ac.cn, the username is Crazyyao, the CVS source code library in the server / usr / local / cvsroot1 directory, our work items or Netants, we use RSH ways to export projects File: CVS -D: Server: Crazyyao@cvs.rdcps.ac.cn: / usr / local / cvsroot1 Checkout Netants When using password check methods, you need to modify the system file /etc/inetd.conf so that inetd knows how Assign, process requests and responses to CVS Server. CVS creates a password file called Passwd in the directory where the source code library is located, check the user. When using the password check, CVS supports anonymous login, and the CVS project super user can set access to files in the project. For details on how to configure CVS, please refer to the CVS documentation. 4.2 Branch of CVS and Fusion Function CVS Enhanced Directory Working Mode allows CVS to provide branch and fusion. Sometimes, when the project progresses to a certain extent, it may be necessary to temporarily interruption, do some other modifications and development. For example, our original version is 1.0, and it has been submitted to users, and now I'm developing 2.0.

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

New Post(0)