manpagez: man pages & more
info emacs
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

23.8.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 master version from which you started editing.

C-u C-x v = file <RET> oldvers <RET> newvers <RET>

Compare the specified two versions of file.

C-x v g

Display the file with per-line version information and 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 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 master version from which you started editing the file (this is not necessarily the latest 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 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 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.

The buffer produced by C-x v = supports the commands of Compilation mode (see section Compilation Mode), such as C-x ` and C-c C-c, in both the “old” and “new” text, and they always find the corresponding locations in the current work file. (Older versions are not, in general, present as files on your disk.)

For some back ends, you can display the file annotated with per-line version information and using colors to enhance the visual appearance, with the command M-x vc-annotate. It creates a new buffer (the “annotate buffer”) displaying the file's text, with each part colored to show how old it is. Text colored red is new, blue means old, and intermediate colors indicate intermediate ages. By default, the color is scaled over the full range of ages, such that the oldest changes are blue, and the newest changes are red.

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 the time span in days the color range should cover.

From the annotate buffer, these and other color scaling options are available from the ‘VC-Annotate’ menu. In this buffer, you can also use the following keys to browse the annotations of past revisions, view diffs, or view log entries:

P

Annotate the previous revision, that is to say, the revision before the one currently annotated. A numeric prefix argument is a repeat count, so C-u 10 P would take you back 10 revisions.

N

Annotate the next revision—the one after the revision currently annotated. A numeric prefix argument is a repeat count.

J

Annotate the revision indicated by the current line.

A

Annotate the revision before the one indicated by the current line. This is useful to see the state the file was in before the change on the current line was made.

D

Display the diff between the current line's revision and the previous revision. This is useful to see what the current line's revision actually changed in the file.

L

Show the log of the current line's revision. This is useful to see the author's description of the changes in the revision on the current line.

W

Annotate the workfile version–the one you are editing. If you used P and N to browse to other revisions, use this key to return to your current version.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2024
Individual documents may contain additional copyright information.