[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

M.7.4 Examining And Comparing Old Versions

One of the convenient features of version control is the ability to examine any version of a file, or compare two versions.

C-x v ~ version RET
Examine version version of the visited file, in a buffer of its own.

C-x v =
Compare the current buffer contents with the latest checked-in version of the file.

C-u C-x v = file RET oldvers RET newvers RET
Compare the specified two versions of file.

C-x v g
Display the result of the CVS annotate command using colors.

To examine an old version in its entirety, visit the file and then type C-x v ~ version RET (vc-version-other-window). This puts the text of version version in a file named `filename.~version~', and visits it in its own buffer in a separate window. (In RCS, you can also select an old version and create a branch from it. See section M.7.6 Multiple Branches of a File.)

It is usually more convenient to compare two versions of the file, with the command C-x v = (vc-diff). Plain C-x v = compares the current buffer contents (saving them in the file if necessary) with the last checked-in version of the file. C-u C-x v =, with a numeric argument, reads a file name and two version numbers, then compares those versions of the specified file. Both forms display the output in a special buffer in another window.

You can specify a checked-in version by its number; an empty input specifies the current contents of the work file (which may be different from all the checked-in versions). You can also specify a snapshot name (see section M.7.8 Snapshots) instead of one or both version numbers.

If you supply a directory name instead of the name of a registered file, this command compares the two specified versions of all registered files in that directory and its subdirectories.

C-x v = works by running a variant of the diff utility designed to work with the version control system in use. When you invoke diff this way, in addition to the options specified by diff-switches (see section M.9 Comparing Files), it receives those specified by vc-diff-switches, plus those specified for the specific back end by vc-backend-diff-switches. For instance, when the version control back end is RCS, diff uses the options in vc-rcs-diff-switches. The `vc...diff-switches' variables are nil by default.

Unlike the M-x diff command, C-x v = does not try to locate the changes in the old and new versions. This is because normally one or both versions do not exist as files when you compare them; they exist only in the records of the master file. See section M.9 Comparing Files, for more information about M-x diff.

For CVS-controlled files, you can display the result of the CVS annotate command, using colors to enhance the visual appearance. Use the command M-x vc-annotate to do this. It creates a new buffer to display file's text, colored to show how old each part is. Text colored red is new, blue means old, and intermediate colors indicate intermediate ages. By default, the time scale is 360 days, so that everything more than one year old is shown in blue.

When you give a prefix argument to this command, it uses the minibuffer to read two arguments: which version number to display and annotate (instead of the current file contents), and a stretch factor for the time scale. A stretch factor of 0.1 means that the color range from red to blue spans the past 36 days instead of 360 days. A stretch factor greater than 1 means the color range spans more than a year.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on April 2, 2002 using texi2html