Tracking Changes in CVS
by Jennifer Vesperman06/14/2002
CVS, the Concurrent Versioning System, manages simultaneous development of files. It stores files in a central repository, and allows users to check out working copies of the files and commit changes back to the repository.
CVS maintains a record of the changes to each file, allowing the user to revert to a previous version, merge versions, and track changes. Change-tracking can be surprisingly useful, and is frequently underutilized.
This article builds on Introduction to CVS and CVS Administration. Some topics discussed there are used but not defined in this article.
annotate
cvs annotate displays the last change for each line of a file in the repository. For each line, it shows the revision number for the last change of each line, the user, the date, and the contents of the line. It is a quick way of discovering who made what changes when.
Annotate displays file data from the repository, not from the working directory, so changes that have not yet been committed will not be displayed.
Options to cvs annotate include:
-f- display files even if no matching tag or date can be found for the file (uses the latest revision).
-l- check only the current directory, do not go into subdirectories.
-R- go into subdirectories (default).
-D date- show the most recent revision before the date.
-r tag- display the revision identified with the tag.
Example 1
$ cvs annotate test.html
Annotations for test.html
***************
1.1 (jenn 30-Apr-02): <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
1.1 (jenn 30-Apr-02): "http://www.w3.org/TR/html4/strict.dtd">
1.1 (jenn 30-Apr-02): <html>
1.1 (jenn 30-Apr-02): <head>
1.4 (jenn 04-May-02): <title>Sample Article</title>
1.1 (jenn 30-Apr-02): </head>
1.1 (jenn 30-Apr-02): <body>
1.4 (jenn 04-May-02): <h1>Sample Article</h1>
1.1 (jenn 30-Apr-02): <p>
1.11 (jenn 07-May-02): Body text for the sample article.
1.1 (jenn 30-Apr-02): </p>
|
Related Reading CVS Pocket Reference |
diff
The command cvs diff compares two revisions of a file and displays the differences. The cvs diff output is very like the standard diff output. cvs rdiff is a variant that can be used to create a patch file that can be installed using the standard patch command.
cvs diff is usually called with at least one -r tag parameter. If called with a single tag, the current copy in the working directory is compared to the version in the repository. The cvs log command shows revision numbers that can be used as parameters to cvs diff.
Example 2
$ cvs diff -r 1.11 cvs_changes.html
Index: cvs_changes.html
===================================================================
RCS file: /home/cvs/oreilly/articles/cvs/cvs_changes.html,v
retrieving revision 1.11
diff -r1.11 cvs_changes.html
64a65
> The command <code>cvs diff</code> compares two
revisions of a file and displays the differences.
66a68
> <code>cvs diff</code> is usually called with at
least one <code>-r <var>tag</var></code> parameter.
71a74
history
Unlike most CVS functions, cvs history is not set up by default. To set it up, create a file called history in the CVSROOT directory of the repository. The CVS user (or whichever user runs CVS on your server) must be able to write to the file.
Example 3
(on the cvs repository server)
$ cd /home/cvs/CVSROOT
$ touch history
$ chmod g+w history
$ ls -la
drwxrwsr-x 4 root src 1024 May 16 01:04 .
drwxrwsr-x 35 root src 1024 Mar 20 18:01 ..
drwxrwsr-x 2 root src 1024 Sep 7 2001 Attic
-rw-rw-r-- 1 root src 0 May 16 01:04 history
-r--r--r-- 1 root src 403 Sep 26 2001 loginfo
Test the history file by committing a file, then running cvs history -c filename (the -c flag displays CVS commits). CVS will display a line that shows the one commit since the history file was created.
Example 4
$ cvs history -c test.html
M 2002-05-15 15:04 +0000 jenn 1.2 test.html oreilly/articles/cvs == <remote>
$
Once it is set up, cvs history can be used to show the history of the files and modules in the repository. File and module choices include a particular file or files, a module, or the modules in the current working directory.
The history file records commits, merges, conflicts, tagging, updates (to the working directory), additions, deletions, and modifications of files in the repository. Each of these can be recalled and displayed with the cvs history command.
cvs history will also display data for the user requesting the information, for all users, or for the current working copy. For widely distributed teams, there is an option to display times in a named time zone.
Example 5
$ cvs history -e -w -z EST test.html
M 2002-05-15 10:04 EST jenn 1.2 test.html oreilly/articles/cvs == <remote>
M 2002-05-15 10:41 EST jenn 1.3 test.html oreilly/articles/cvs == <remote>
In example 5, -e specifies showing all types of commits and updates, -w specifies showing only the changes that affect or come from the current working directory, and -z EST sets the time zone for display to EST.
Pages: 1, 2 |
