Commit 45ca30f2 authored by Karl Berry's avatar Karl Berry

move more advanced vc info to emacs-xtra.texi

parent 14e6dc54
2006-04-11 Karl Berry <karl@gnu.org>
* emacs-xtra.texi, emacs.texi (Dired under VC, VC Dired Commands,
Remote Repositories, Version Backups, Local Version Control,
Snapshots, Making and Using Snapshots, Snapshot Caveats,
Miscellaneous Commands and Features of VC, Change Logs and VC,
Renaming VC Work Files and Master Files,
Inserting Version Control Headers, Customizing VC, General Options,
Options for RCS and SCCS, Options specific for CVS): move all
these nodes to emacs-xtra.texi, for brevity.
* cmdargs.texi, files.texi: change cross-references.
2006-04-11 Reiner Steib <Reiner.Steib@gmx.de>
* gnus.texi, gnus-faq.texi, message.texi: Gnus v5.10.8 is released.
......
......@@ -551,7 +551,7 @@ The name of an interpreter used to parse and execute programs run from
inside Emacs.
@item SMTPSERVER
The name of the outgoing mail server. Used by the SMTP library
(@pxref{Top,,Sending mail via SMTP,smtpmail}).
(@pxref{Top,,,Sending mail via SMTP,smtpmail}).
@cindex background mode, on @command{xterm}
@item TERM
The type of the terminal that Emacs is using. This variable must be
......
......@@ -57,12 +57,14 @@ license to the document, as described in section 6 of the license.
@menu
* Introduction:: What documentation belongs here?
* Autorevert:: Auto Reverting non-file buffers.
* Subdir switches:: Subdirectory switches in Dired.
* Subdir Switches:: Subdirectory switches in Dired.
* Advanced Calendar/Diary Usage:: Advanced Calendar/Diary customization.
* Emerge:: A convenient way of merging two versions
of a program.
* Picture Mode:: Editing pictures made up of characters
using the quarter-plane screen model.
* Advanced VC Usage:: Advanced VC (version control) features.
* Fortran:: Fortran mode and its special features.
* MS-DOG::
* Index::
......@@ -273,7 +275,7 @@ for the buffer reliably assures that all information in the buffer is
completely up to date (or will be after @code{auto-revert-interval}
seconds).
@node Subdir switches
@node Subdir Switches
@chapter Subdirectory Switches in Dired
You can insert subdirectories with specified @code{ls} switches in
......@@ -1889,6 +1891,887 @@ other modes. @kbd{C-c C-y} (@code{picture-yank-rectangle}) inserts
@kbd{C-c C-x} (@code{picture-yank-rectangle-from-register}) does
likewise for the rectangle found in a specified register.
@node Advanced VC Usage
@chapter Advanced VC Usage
Commonly used features of Emacs' version control (VC) support are
described in the main Emacs manual (@pxref{Version Control,,,emacs,
the Emacs Manual}). This chapter describes more advanced VC usage.
@menu
* VC Dired Mode:: Listing files managed by version control.
* VC Dired Commands:: Commands to use in a VC Dired buffer.
* Remote Repositories:: Efficient access to remote CVS servers.
* Snapshots:: Sets of file versions treated as a unit.
* Miscellaneous VC:: Various other commands and features of VC.
* Customizing VC:: Variables that change VC's behavior.
@end menu
@node VC Dired Mode
@section Dired under VC
@cindex PCL-CVS
@pindex cvs
@cindex CVS Dired Mode
The VC Dired Mode described here works with all the version control
systems that VC supports. Another more powerful facility, designed
specifically for CVS, is called PCL-CVS. @xref{Top, , About PCL-CVS,
pcl-cvs, PCL-CVS --- The Emacs Front-End to CVS}.
@kindex C-x v d
@findex vc-directory
When you are working on a large program, it is often useful to find
out which files have changed within an entire directory tree, or to view
the status of all files under version control at once, and to perform
version control operations on collections of files. You can use the
command @kbd{C-x v d} (@code{vc-directory}) to make a directory listing
that includes only files relevant for version control.
@vindex vc-dired-terse-display
@kbd{C-x v d} creates a buffer which uses VC Dired Mode. This looks
much like an ordinary Dired buffer (@pxref{Dired,,,emacs, the
Emacs Manual}); however, normally it shows only the noteworthy files
(those locked or not up-to-date). This is called @dfn{terse display}.
If you set the variable @code{vc-dired-terse-display} to @code{nil},
then VC Dired shows all relevant files---those managed under version
control, plus all subdirectories (@dfn{full display}). The command
@kbd{v t} in a VC Dired buffer toggles between terse display and full
display (@pxref{VC Dired Commands}).
@vindex vc-dired-recurse
By default, VC Dired produces a recursive listing of noteworthy or
relevant files at or below the given directory. You can change this by
setting the variable @code{vc-dired-recurse} to @code{nil}; then VC
Dired shows only the files in the given directory.
The line for an individual file shows the version control state in the
place of the hard link count, owner, group, and size of the file. If
the file is unmodified, in sync with the master file, the version
control state shown is blank. Otherwise it consists of text in
parentheses. Under RCS and SCCS, the name of the user locking the file
is shown; under CVS, an abbreviated version of the @samp{cvs status}
output is used. Here is an example using RCS:
@smallexample
@group
/home/jim/project:
-rw-r--r-- (jim) Apr 2 23:39 file1
-r--r--r-- Apr 5 20:21 file2
@end group
@end smallexample
@noindent
The files @samp{file1} and @samp{file2} are under version control,
@samp{file1} is locked by user jim, and @samp{file2} is unlocked.
Here is an example using CVS:
@smallexample
@group
/home/joe/develop:
-rw-r--r-- (modified) Aug 2 1997 file1.c
-rw-r--r-- Apr 4 20:09 file2.c
-rw-r--r-- (merge) Sep 13 1996 file3.c
@end group
@end smallexample
Here @samp{file1.c} is modified with respect to the repository, and
@samp{file2.c} is not. @samp{file3.c} is modified, but other changes
have also been checked in to the repository---you need to merge them
with the work file before you can check it in.
@vindex vc-stay-local
@vindex vc-cvs-stay-local
In the above, if the repository were on a remote machine, VC would
only contact it when the variable @code{vc-stay-local} (or
@code{vc-cvs-stay-local}) is nil (@pxref{CVS Options}). This is
because access to the repository may be slow, or you may be working
offline and not have access to the repository at all. As a
consequence, VC would not be able to tell you that @samp{file3.c} is
in the ``merge'' state; you would learn that only when you try to
check-in your modified copy of the file, or use a command such as
@kbd{C-x v m}.
In practice, this is not a problem because CVS handles this case
consistently whenever it arises. In VC, you'll simply get prompted to
merge the remote changes into your work file first. The benefits of
less network communication usually outweigh the disadvantage of not
seeing remote changes immediately.
@vindex vc-directory-exclusion-list
When VC Dired displays subdirectories (in the ``full'' display mode),
it omits some that should never contain any files under version control.
By default, this includes Version Control subdirectories such as
@samp{RCS} and @samp{CVS}; you can customize this by setting the
variable @code{vc-directory-exclusion-list}.
You can fine-tune VC Dired's format by typing @kbd{C-u C-x v d}---as in
ordinary Dired, that allows you to specify additional switches for the
@samp{ls} command.
@node VC Dired Commands
@section VC Dired Commands
All the usual Dired commands work normally in VC Dired mode, except
for @kbd{v}, which is redefined as the version control prefix. You can
invoke VC commands such as @code{vc-diff} and @code{vc-print-log} by
typing @kbd{v =}, or @kbd{v l}, and so on. Most of these commands apply
to the file name on the current line.
The command @kbd{v v} (@code{vc-next-action}) operates on all the
marked files, so that you can lock or check in several files at once.
If it operates on more than one file, it handles each file according to
its current state; thus, it might lock one file, but check in another
file. This could be confusing; it is up to you to avoid confusing
behavior by marking a set of files that are in a similar state. If no
files are marked, @kbd{v v} operates on the file in the current line.
If any files call for check-in, @kbd{v v} reads a single log entry,
then uses it for all the files being checked in. This is convenient for
registering or checking in several files at once, as part of the same
change.
@findex vc-dired-toggle-terse-mode
@findex vc-dired-mark-locked
You can toggle between terse display (only locked files, or files not
up-to-date) and full display at any time by typing @kbd{v t}
(@code{vc-dired-toggle-terse-mode}). There is also a special command
@kbd{* l} (@code{vc-dired-mark-locked}), which marks all files currently
locked (or, with CVS, all files not up-to-date). Thus, typing @kbd{* l
t k} is another way to delete from the buffer all files except those
currently locked.
@node Remote Repositories
@section Remote Repositories
@cindex remote repositories (CVS)
A common way of using CVS is to set up a central CVS repository on
some Internet host, then have each developer check out a personal
working copy of the files on his local machine. Committing changes to
the repository, and picking up changes from other users into one's own
working area, then works by direct interactions with the CVS server.
One difficulty is that access to the CVS server is often slow, and
that developers might need to work off-line as well. VC is designed
to reduce the amount of network interaction necessary.
@menu
* Version Backups:: Keeping local copies of repository versions.
* Local Version Control:: Using another version system for local editing.
@end menu
@node Version Backups
@subsection Version Backups
@cindex version backups
@cindex automatic version backups
When VC sees that the CVS repository for a file is on a remote
machine, it automatically makes local backups of unmodified versions
of the file---@dfn{automatic version backups}. This means that you
can compare the file to the repository version (@kbd{C-x v =}), or
revert to that version (@kbd{C-x v u}), without any network
interactions.
The local copy of the unmodified file is called a @dfn{version
backup} to indicate that it corresponds exactly to a version that is
stored in the repository. Note that version backups are not the same
as ordinary Emacs backup files (@pxref{Backup,,,emacs, the Emacs
Manual}). But they follow a similar naming convention.
For a file that comes from a remote CVS repository, VC makes a
version backup whenever you save the first changes to the file, and
removes it after you have committed your modified version to the
repository. You can disable the making of automatic version backups by
setting @code{vc-cvs-stay-local} to @code{nil} (@pxref{CVS Options}).
@cindex manual version backups
The name of the automatic version backup for version @var{version}
of file @var{file} is @code{@var{file}.~@var{version}.~}. This is
almost the same as the name used by @kbd{C-x v ~} (@pxref{Old
Versions,,,emacs, the Emacs Manual}), the only difference being
the additional dot (@samp{.}) after the version number. This
similarity is intentional, because both kinds of files store the same
kind of information. The file made by @kbd{C-x v ~} acts as a
@dfn{manual version backup}.
All the VC commands that operate on old versions of a file can use
both kinds of version backups. For instance, @kbd{C-x v ~} uses
either an automatic or a manual version backup, if possible, to get
the contents of the version you request. Likewise, @kbd{C-x v =} and
@kbd{C-x v u} use either an automatic or a manual version backup, if
one of them exists, to get the contents of a version to compare or
revert to. If you changed a file outside of Emacs, so that no
automatic version backup was created for the previous text, you can
create a manual backup of that version using @kbd{C-x v ~}, and thus
obtain the benefit of the local copy for Emacs commands.
The only difference in Emacs's handling of manual and automatic
version backups, once they exist, is that Emacs deletes automatic
version backups when you commit to the repository. By contrast,
manual version backups remain until you delete them.
@node Local Version Control
@subsection Local Version Control
@cindex local version control
@cindex local back end (version control)
When you make many changes to a file that comes from a remote
repository, it can be convenient to have version control on your local
machine as well. You can then record intermediate versions, revert to
a previous state, etc., before you actually commit your changes to the
remote server.
VC lets you do this by putting a file under a second, local version
control system, so that the file is effectively registered in two
systems at the same time. For the description here, we will assume
that the remote system is CVS, and you use RCS locally, although the
mechanism works with any combination of version control systems
(@dfn{back ends}).
To make it work with other back ends, you must make sure that the
``more local'' back end comes before the ``more remote'' back end in
the setting of @code{vc-handled-backends} (@pxref{Customizing VC}). By
default, this variable is set up so that you can use remote CVS and
local RCS as described here.
To start using local RCS for a file that comes from a remote CVS
server, you must @emph{register the file in RCS}, by typing @kbd{C-u
C-x v v rcs @key{RET}}. (In other words, use @code{vc-next-action} with a
prefix argument, and specify RCS as the back end.)
You can do this at any time; it does not matter whether you have
already modified the file with respect to the version in the CVS
repository. If possible, VC tries to make the RCS master start with
the unmodified repository version, then checks in any local changes
as a new version. This works if you have not made any changes yet, or
if the unmodified repository version exists locally as a version
backup (@pxref{Version Backups}). If the unmodified version is not
available locally, the RCS master starts with the modified version;
the only drawback to this is that you cannot compare your changes
locally to what is stored in the repository.
The version number of the RCS master is derived from the current CVS
version, starting a branch from it. For example, if the current CVS
version is 1.23, the local RCS branch will be 1.23.1. Version 1.23 in
the RCS master will be identical to version 1.23 under CVS; your first
changes are checked in as 1.23.1.1. (If the unmodified file is not
available locally, VC will check in the modified file twice, both as
1.23 and 1.23.1.1, to make the revision numbers consistent.)
If you do not use locking under CVS (the default), locking is also
disabled for RCS, so that editing under RCS works exactly as under
CVS.
When you are done with local editing, you can commit the final version
back to the CVS repository by typing @kbd{C-u C-x v v cvs @key{RET}}.
This initializes the log entry buffer (@pxref{Log Buffer,,,emacs, the
Emacs Manual}) to contain all the log entries you have recorded in the
RCS master; you can edit them as you wish, and then commit in CVS by
typing @kbd{C-c C-c}. If the commit is successful, VC removes the RCS
master, so that the file is once again registered under CVS only.
(The RCS master is not actually deleted, just renamed by appending
@samp{~} to the name, so that you can refer to it later if you wish.)
While using local RCS, you can pick up recent changes from the CVS
repository into your local file, or commit some of your changes back
to CVS, without terminating local RCS version control. To do this,
switch to the CVS back end temporarily, with the @kbd{C-x v b} command:
@table @kbd
@item C-x v b
Switch to another back end that the current file is registered
under (@code{vc-switch-backend}).
@item C-u C-x v b @var{backend} @key{RET}
Switch to @var{backend} for the current file.
@end table
@kindex C-x v b
@findex vc-switch-backend
@kbd{C-x v b} does not change the buffer contents, or any files; it
only changes VC's perspective on how to handle the file. Any
subsequent VC commands for that file will operate on the back end that
is currently selected.
If the current file is registered in more than one back end, typing
@kbd{C-x v b} ``cycles'' through all of these back ends. With a
prefix argument, it asks for the back end to use in the minibuffer.
Thus, if you are using local RCS, and you want to pick up some recent
changes in the file from remote CVS, first visit the file, then type
@kbd{C-x v b} to switch to CVS, and finally use @kbd{C-x v m
@key{RET}} to merge the news (@pxref{Merging,,,emacs, the Emacs
Manual}). You can then switch back to RCS by typing @kbd{C-x v b}
again, and continue to edit locally.
But if you do this, the revision numbers in the RCS master no longer
correspond to those of CVS. Technically, this is not a problem, but
it can become difficult to keep track of what is in the CVS repository
and what is not. So we suggest that you return from time to time to
CVS-only operation, by committing your local changes back to the
repository using @kbd{C-u C-x v v cvs @key{RET}}.
@node Snapshots
@section Snapshots
@cindex snapshots and version control
A @dfn{snapshot} is a named set of file versions (one for each
registered file) that you can treat as a unit. One important kind of
snapshot is a @dfn{release}, a (theoretically) stable version of the
system that is ready for distribution to users.
@menu
* Making Snapshots:: The snapshot facilities.
* Snapshot Caveats:: Things to be careful of when using snapshots.
@end menu
@node Making Snapshots
@subsection Making and Using Snapshots
There are two basic commands for snapshots; one makes a
snapshot with a given name, the other retrieves a named snapshot.
@table @code
@kindex C-x v s
@findex vc-create-snapshot
@item C-x v s @var{name} @key{RET}
Define the last saved versions of every registered file in or under the
current directory as a snapshot named @var{name}
(@code{vc-create-snapshot}).
@kindex C-x v r
@findex vc-retrieve-snapshot
@item C-x v r @var{name} @key{RET}
For all registered files at or below the current directory level, select
whatever versions correspond to the snapshot @var{name}
(@code{vc-retrieve-snapshot}).
This command reports an error if any files are locked at or below the
current directory, without changing anything; this is to avoid
overwriting work in progress.
@end table
A snapshot uses a very small amount of resources---just enough to record
the list of file names and which version belongs to the snapshot. Thus,
you need not hesitate to create snapshots whenever they are useful.
You can give a snapshot name as an argument to @kbd{C-x v =} or
@kbd{C-x v ~} (@pxref{Old Versions,,,emacs, the Emacs Manual}).
Thus, you can use it to compare a snapshot against the current files,
or two snapshots against each other, or a snapshot against a named
version.
@node Snapshot Caveats
@subsection Snapshot Caveats
@cindex named configurations (RCS)
VC's snapshot facilities are modeled on RCS's named-configuration
support. They use RCS's native facilities for this, so
snapshots made using RCS through VC are visible even when you bypass VC.
With CVS, Meta-CVS, and Subversion, VC also uses the native
mechanism provided by that back end to make snapshots and retrieve them
(@dfn{tags} for CVS and Meta-CVS, @dfn{copies} for Subversion).
@c worded verbosely to avoid overfull hbox.
For SCCS, VC implements snapshots itself. The files it uses contain
name/file/version-number triples. These snapshots are visible only
through VC.
There is no support for VC snapshots using GNU Arch yet.
A snapshot is a set of checked-in versions. So make sure that all the
files are checked in and not locked when you make a snapshot.
File renaming and deletion can create some difficulties with snapshots.
This is not a VC-specific problem, but a general design issue in version
control systems that no one has solved very well yet.
If you rename a registered file, you need to rename its master along
with it (the command @code{vc-rename-file} does this automatically). If
you are using SCCS, you must also update the records of the snapshot, to
mention the file by its new name (@code{vc-rename-file} does this,
too). An old snapshot that refers to a master file that no longer
exists under the recorded name is invalid; VC can no longer retrieve
it. It would be beyond the scope of this manual to explain enough about
RCS and SCCS to explain how to update the snapshots by hand.
Using @code{vc-rename-file} makes the snapshot remain valid for
retrieval, but it does not solve all problems. For example, some of the
files in your program probably refer to others by name. At the very
least, the makefile probably mentions the file that you renamed. If you
retrieve an old snapshot, the renamed file is retrieved under its new
name, which is not the name that the makefile expects. So the program
won't really work as retrieved.
@node Miscellaneous VC
@section Miscellaneous Commands and Features of VC
This section explains the less-frequently-used features of VC.
@menu
* Change Logs and VC:: Generating a change log file from log entries.
* Renaming and VC:: A command to rename both the source and master
file correctly.
* Version Headers:: Inserting version control headers into working files.
@end menu
@node Change Logs and VC
@subsection Change Logs and VC
If you use RCS or CVS for a program and also maintain a change log
file for it (@pxref{Change Log,,,emacs, the Emacs Manual}), you
can generate change log entries automatically from the version control
log entries:
@table @kbd
@item C-x v a
@kindex C-x v a
@findex vc-update-change-log
Visit the current directory's change log file and, for registered files
in that directory, create new entries for versions checked in since the
most recent entry in the change log file.
(@code{vc-update-change-log}).
This command works with RCS or CVS only, not with any of the other
back ends.
@item C-u C-x v a
As above, but only find entries for the current buffer's file.
@item M-1 C-x v a
As above, but find entries for all the currently visited files that are
maintained with version control. This works only with RCS, and it puts
all entries in the log for the default directory, which may not be
appropriate.
@end table
For example, suppose the first line of @file{ChangeLog} is dated
1999-04-10, and that the only check-in since then was by Nathaniel
Bowditch to @file{rcs2log} on 1999-05-22 with log text @samp{Ignore log
messages that start with `#'.}. Then @kbd{C-x v a} visits
@file{ChangeLog} and inserts text like this:
@iftex
@medbreak
@end iftex
@smallexample
@group
1999-05-22 Nathaniel Bowditch <nat@@apn.org>
* rcs2log: Ignore log messages that start with `#'.
@end group
@end smallexample
@iftex
@medbreak
@end iftex
@noindent
You can then edit the new change log entry further as you wish.
Some of the new change log entries may duplicate what's already in
ChangeLog. You will have to remove these duplicates by hand.
Normally, the log entry for file @file{foo} is displayed as @samp{*
foo: @var{text of log entry}}. The @samp{:} after @file{foo} is omitted
if the text of the log entry starts with @w{@samp{(@var{functionname}):
}}. For example, if the log entry for @file{vc.el} is
@samp{(vc-do-command): Check call-process status.}, then the text in
@file{ChangeLog} looks like this:
@iftex
@medbreak
@end iftex
@smallexample
@group
1999-05-06 Nathaniel Bowditch <nat@@apn.org>
* vc.el (vc-do-command): Check call-process status.
@end group
@end smallexample
@iftex
@medbreak
@end iftex
When @kbd{C-x v a} adds several change log entries at once, it groups
related log entries together if they all are checked in by the same
author at nearly the same time. If the log entries for several such
files all have the same text, it coalesces them into a single entry.
For example, suppose the most recent check-ins have the following log
entries:
@flushleft
@bullet{} For @file{vc.texinfo}: @samp{Fix expansion typos.}
@bullet{} For @file{vc.el}: @samp{Don't call expand-file-name.}
@bullet{} For @file{vc-hooks.el}: @samp{Don't call expand-file-name.}
@end flushleft
@noindent
They appear like this in @file{ChangeLog}:
@iftex
@medbreak
@end iftex
@smallexample
@group
1999-04-01 Nathaniel Bowditch <nat@@apn.org>
* vc.texinfo: Fix expansion typos.
* vc.el, vc-hooks.el: Don't call expand-file-name.
@end group
@end smallexample
@iftex
@medbreak
@end iftex
Normally, @kbd{C-x v a} separates log entries by a blank line, but you
can mark several related log entries to be clumped together (without an
intervening blank line) by starting the text of each related log entry
with a label of the form @w{@samp{@{@var{clumpname}@} }}. The label
itself is not copied to @file{ChangeLog}. For example, suppose the log
entries are:
@flushleft
@bullet{} For @file{vc.texinfo}: @samp{@{expand@} Fix expansion typos.}
@bullet{} For @file{vc.el}: @samp{@{expand@} Don't call expand-file-name.}
@bullet{} For @file{vc-hooks.el}: @samp{@{expand@} Don't call expand-file-name.}
@end flushleft
@noindent
Then the text in @file{ChangeLog} looks like this:
@iftex
@medbreak
@end iftex
@smallexample
@group
1999-04-01 Nathaniel Bowditch <nat@@apn.org>
* vc.texinfo: Fix expansion typos.
* vc.el, vc-hooks.el: Don't call expand-file-name.
@end group
@end smallexample
@iftex
@medbreak
@end iftex
A log entry whose text begins with @samp{#} is not copied to
@file{ChangeLog}. For example, if you merely fix some misspellings in
comments, you can log the change with an entry beginning with @samp{#}
to avoid putting such trivia into @file{ChangeLog}.
@node Renaming and VC
@subsection Renaming VC Work Files and Master Files
@findex vc-rename-file
When you rename a registered file, you must also rename its master
file correspondingly to get proper results. Use @code{vc-rename-file}
to rename the source file as you specify, and rename its master file
accordingly. It also updates any snapshots (@pxref{Snapshots}) that
mention the file, so that they use the new name; despite this, the
snapshot thus modified may not completely work (@pxref{Snapshot
Caveats}).
Some back ends do not provide an explicit rename operation to their
repositories. After issuing @code{vc-rename-file}, use @kbd{C-x v v}
on the original and renamed buffers and provide the necessary edit
log.
You cannot use @code{vc-rename-file} on a file that is locked by
someone else.
@node Version Headers
@subsec