Add the bug number #10360 to the entry for 2011-12-23T14:51:51Z!eliz@gnu.org.
[emacs.git] / doc / emacs / vc1-xtra.texi
blob8df5bfbd551682bb34c834042e2697eebf1a4909
1 @c This is part of the Emacs manual.
2 @c Copyright (C) 2004-2011  Free Software Foundation, Inc.
3 @c See file emacs.texi for copying conditions.
4 @c
5 @c This file is included either in vc-xtra.texi (when producing the
6 @c printed version) or in the main Emacs manual (for the on-line version).
8 @node Miscellaneous VC
9 @subsection Miscellaneous Commands and Features of VC
11   This section explains the less-frequently-used features of VC.
13 @menu
14 * Change Logs and VC::  Generating a change log file from log entries.
15 * Renaming and VC::     A command to rename both the source and master
16                           file correctly.
17 * Revision Tags::       Symbolic names for revisions.
18 * Version Headers::     Inserting version control headers into working files.
19 @end menu
21 @node Change Logs and VC
22 @subsubsection Change Logs and VC
24   If you use RCS or CVS for a program with a @file{ChangeLog} file
25 @iftex
26 (@pxref{Change Log,,,emacs, the Emacs Manual}),
27 @end iftex
28 @ifnottex
29 (@pxref{Change Log}),
30 @end ifnottex
31 you can generate change log entries from the version control log
32 entries of previous commits.
34   Note that this only works with RCS or CVS.  This procedure would be
35 particularly incorrect on a modern changeset-based version control
36 system, where changes to the @file{ChangeLog} file would normally be
37 committed as part of a changeset.  In that case, you should write the
38 change log entries first, then pull them into the @samp{*vc-log*}
39 buffer when you commit
40 @iftex
41 (@pxref{Log Buffer,,,emacs, the Emacs Manual}).
42 @end iftex
43 @ifnottex
44 (@pxref{Log Buffer}).
45 @end ifnottex
47 @table @kbd
48 @item C-x v a
49 @kindex C-x v a
50 @findex vc-update-change-log
51 Visit the current directory's @file{ChangeLog} file and, for
52 registered files in that directory, create new entries for versions
53 committed since the most recent change log entry
54 (@code{vc-update-change-log}).
56 @item C-u C-x v a
57 As above, but only find entries for the current buffer's file.
58 @end table
60   For example, suppose the first line of @file{ChangeLog} is dated
61 1999-04-10, and that the only check-in since then was by Nathaniel
62 Bowditch to @file{rcs2log} on 1999-05-22 with log entry @samp{Ignore
63 log messages that start with `#'.}.  Then @kbd{C-x v a} inserts this
64 @file{ChangeLog} entry:
66 @iftex
67 @medbreak
68 @end iftex
69 @smallexample
70 @group
71 1999-05-22  Nathaniel Bowditch  <nat@@apn.org>
73         * rcs2log: Ignore log messages that start with `#'.
74 @end group
75 @end smallexample
76 @iftex
77 @medbreak
78 @end iftex
80 @noindent
81 If the version control log entry specifies a function name (in
82 parenthesis at the beginning of a line), that is reflected in the
83 @file{ChangeLog} entry.  For example, if a log entry for @file{vc.el}
84 is @samp{(vc-do-command): Check call-process status.}, the
85 @file{ChangeLog} entry is:
87 @iftex
88 @medbreak
89 @end iftex
90 @smallexample
91 @group
92 1999-05-06  Nathaniel Bowditch  <nat@@apn.org>
94         * vc.el (vc-do-command): Check call-process status.
95 @end group
96 @end smallexample
97 @iftex
98 @medbreak
99 @end iftex
101   When @kbd{C-x v a} adds several change log entries at once, it
102 groups related log entries together if they all are checked in by the
103 same author at nearly the same time.  If the log entries for several
104 such files all have the same text, it coalesces them into a single
105 entry.
107 @node Renaming and VC
108 @subsubsection Renaming VC Work Files and Master Files
109 @cindex renaming version-controlled files
111 @table @kbd
112 @item M-x vc-rename-file
113 Prompt for two file names, @var{VAR} and @var{OLD}, and rename them in
114 the version-controlled working tree.
115 @end table
117 @findex vc-rename-file
118   If you wish to rename a registered file in a version-controlled
119 working tree, use the command @kbd{M-x vc-rename-file}.  This prompts
120 for two arguments: the file you wish to rename, followed by the new
121 name; then it performs the renaming through the version control
122 system.
124   On modern version control systems that have built-in support for
125 renaming, the renaming operation takes effect immediately in the
126 working tree, and takes effect in the repository when you commit the
127 renamed file.  The renamed file retains the full change history of the
128 original file.
130   On CVS and older version control systems, the @code{vc-rename-file}
131 command actually works by creating a copy of the old file under the
132 new name, registering it, and deleting the old file.  In this case,
133 the change history is not preserved.
135 @node Revision Tags
136 @subsubsection Revision Tags
137 @cindex revision tag
138 @cindex tags for version control
140   Most version control systems allow you to apply a @dfn{revision tag}
141 to a specific version of a version-controlled tree.  On modern
142 changeset-based version control systems, a revision tag is simply a
143 symbolic name for a particular revision.  On older file-based systems
144 like CVS, each tag is added to the entire set of version-controlled
145 files, allowing them to be handled as a unit.  Revision tags are
146 commonly used to identify releases that are distributed to users.
148   There are two basic commands for tags; one makes a tag with a given
149 name, the other retrieves a named tag.
151 @table @code
152 @kindex C-x v s
153 @findex vc-create-tag
154 @item C-x v s @var{name} @key{RET}
155 Define the working revision of every registered file in or under the
156 current directory as a tag named @var{name}
157 (@code{vc-create-tag}).
159 @kindex C-x v r
160 @findex vc-retrieve-tag
161 @item C-x v r @var{name} @key{RET}
162 For all registered files at or below the current directory level,
163 retrieve the tagged revision @var{name}. This command will switch to a
164 branch if @var{name} is a branch name and your VCS distinguishes
165 branches from tags.  (@code{vc-retrieve-tag}).
167 This command reports an error if any files are locked at or below the
168 current directory, without changing anything; this is to avoid
169 overwriting work in progress.
170 @end table
172   You can give a tag or branch name as an argument to @kbd{C-x v =} or
173 @kbd{C-x v ~}
174 @iftex
175 (@pxref{Old Revisions,,,emacs, the Emacs Manual}).
176 @end iftex
177 @ifnottex
178 (@pxref{Old Revisions}).
179 @end ifnottex
180 Thus, you can use it to compare a tagged version against the current files,
181 or two tagged versions against each other.
183   On SCCS, VC implements tags itself; these tags are visible only
184 through VC.  Most later systems (including CVS, Subversion, bzr, git,
185 and hg) have a native tag facility, and VC uses it where available;
186 those tags will be visible even when you bypass VC.
188   In a file-oriented VCS, when you rename a registered file you need
189 to rename its master along with it; the command @code{vc-rename-file}
190 will do this automatically.  If you are using SCCS, you must also
191 update the records of the tag, to mention the file by its new name
192 (@code{vc-rename-file} does this, too).  An old tag that refers to a
193 master file that no longer exists under the recorded name is invalid;
194 VC can no longer retrieve it.  It would be beyond the scope of this
195 manual to explain enough about RCS and SCCS to explain how to update
196 the tags by hand.  Using @code{vc-rename-file} makes the tag remain
197 valid for retrieval, but it does not solve all problems.  For example,
198 some of the files in your program probably refer to others by name.
199 At the very least, the makefile probably mentions the file that you
200 renamed.  If you retrieve an old tag, the renamed file is retrieved
201 under its new name, which is not the name that the makefile expects.
202 So the program won't really work as retrieved.
204 @node Version Headers
205 @subsubsection Inserting Version Control Headers
207   On Subversion, CVS, RCS, and SCCS, you can put certain special
208 strings called @dfn{version headers} into a work file.  When the file
209 is committed, the version control system automatically puts the
210 revision number, the name of the user who made the commit, and other
211 relevant information into the version header.
213 @vindex vc-consult-headers
214   VC does not normally use the information in the version headers.  As
215 an exception, when using RCS, Emacs uses the version header, if there
216 is one, to determine the file version, since it is often more reliable
217 than the RCS master file.  To inhibit using the version header this
218 way, change the variable @code{vc-consult-headers} to @code{nil}.
220 @kindex C-x v h
221 @findex vc-insert-headers
222 @vindex vc-@var{backend}-header
223   To insert a suitable header string into the current buffer, type
224 @kbd{C-x v h} (@code{vc-insert-headers}).  This command works only on
225 Subversion, CVS, RCS, and SCCS.  The variable
226 @code{vc-@var{backend}-header} contains the list of keywords to insert
227 into the version header; for instance, CVS uses @code{vc-cvs-header},
228 whose default value is @code{'("\$Id\$")}.  (The extra backslashes
229 prevent the string constant from being interpreted as a header, if the
230 Emacs Lisp file defining it is maintained with version control.)  The
231 @kbd{C-x v h} command inserts each keyword in the list on a new line
232 at point, surrounded by tabs, and inside comment delimiters if
233 necessary.
235 @vindex vc-static-header-alist
236   The variable @code{vc-static-header-alist} specifies further strings
237 to add based on the name of the buffer.  Its value should be a list of
238 elements of the form @code{(@var{regexp} . @var{format})}.  Whenever
239 @var{regexp} matches the buffer name, @var{format} is also inserted as
240 part of the version header.  A @samp{%s} in @var{format} is replaced
241 with the file's version control type.
243 @node Customizing VC
244 @subsection Customizing VC
246 @vindex vc-handled-backends
247   The variable @code{vc-handled-backends} determines which version
248 control systems VC should handle.  The default value is @code{(RCS CVS
249 SVN SCCS Bzr Git Hg Mtn Arch)}, so it contains all the version systems
250 that are currently supported.  If you want VC to ignore one or more of
251 these systems, exclude its name from the list.  To disable VC
252 entirely, set this variable to @code{nil}.
254   The order of systems in the list is significant: when you visit a
255 file registered in more than one system, VC uses the system that comes
256 first in @code{vc-handled-backends} by default.  The order is also
257 significant when you register a file for the first time
258 @iftex
259 (@pxref{Registering,,,emacs, the Emacs Manual}).
260 @end iftex
261 @ifnottex
262 (@pxref{Registering}).
263 @end ifnottex
265 @menu
266 * General VC Options::  Options that apply to multiple back ends.
267 * RCS and SCCS::        Options for RCS and SCCS.
268 * CVS Options::         Options for CVS.
269 @end menu
271 @node General VC Options
272 @subsubsection General Options
274 @vindex vc-make-backup-files
275   Emacs normally does not save backup files for source files that are
276 maintained with version control.  If you want to make backup files even
277 for files that use version control, set the variable
278 @code{vc-make-backup-files} to a non-@code{nil} value.
280 @vindex vc-follow-symlinks
281 @cindex symbolic links (and version control)
282   Editing a version-controlled file through a symbolic link may cause
283 unexpected results, if you are unaware that the underlying file is
284 version-controlled.  The variable @code{vc-follow-symlinks} controls
285 what Emacs does if you try to visit a symbolic link pointing to a
286 version-controlled file.  If the value is @code{ask} (the default),
287 Emacs asks for confirmation.  If it is @code{nil}, Emacs just displays
288 a warning message.  If it is @code{t}, Emacs automatically follows the
289 link and visits the real file instead.
291 @vindex vc-suppress-confirm
292   If @code{vc-suppress-confirm} is non-@code{nil}, then @kbd{C-x v v}
293 and @kbd{C-x v i} can save the current buffer without asking, and
294 @kbd{C-x v u} also operates without asking for confirmation.
296 @vindex vc-command-messages
297   VC mode does much of its work by running the shell commands for the
298 appropriate version control system.  If @code{vc-command-messages} is
299 non-@code{nil}, VC displays messages to indicate which shell commands
300 it runs, and additional messages when the commands finish.
302 @vindex vc-path
303   You can specify additional directories to search for version control
304 programs by setting the variable @code{vc-path}.  These directories
305 are searched before the usual search path.  It is rarely necessary to
306 set this variable, because VC normally finds the proper files
307 automatically.
309 @node RCS and SCCS
310 @subsubsection Options for RCS and SCCS
312 @cindex non-strict locking (RCS)
313 @cindex locking, non-strict (RCS)
314   By default, RCS uses locking to coordinate the activities of several
315 users, but there is a mode called @dfn{non-strict locking} in which
316 you can check-in changes without locking the file first.  Use
317 @samp{rcs -U} to switch to non-strict locking for a particular file,
318 see the @code{rcs} manual page for details.
320   When deducing the version control state of an RCS file, VC first
321 looks for an RCS version header string in the file (@pxref{Version
322 Headers}).  If there is no header string, VC normally looks at the
323 file permissions of the work file; this is fast.  But there might be
324 situations when the file permissions cannot be trusted.  In this case
325 the master file has to be consulted, which is rather expensive.  Also
326 the master file can only tell you @emph{if} there's any lock on the
327 file, but not whether your work file really contains that locked
328 version.
330 @vindex vc-consult-headers
331   You can tell VC not to use version headers to determine the file
332 status by setting @code{vc-consult-headers} to @code{nil}.  VC then
333 always uses the file permissions (if it is supposed to trust them), or
334 else checks the master file.
336 @vindex vc-mistrust-permissions
337   You can specify the criterion for whether to trust the file
338 permissions by setting the variable @code{vc-mistrust-permissions}.
339 Its value can be @code{t} (always mistrust the file permissions and
340 check the master file), @code{nil} (always trust the file
341 permissions), or a function of one argument which makes the decision.
342 The argument is the directory name of the @file{RCS} subdirectory.  A
343 non-@code{nil} value from the function says to mistrust the file
344 permissions.  If you find that the file permissions of work files are
345 changed erroneously, set @code{vc-mistrust-permissions} to @code{t}.
346 Then VC always checks the master file to determine the file's status.
348   VC determines the version control state of files under SCCS much as
349 with RCS.  It does not consider SCCS version headers, though.  Thus,
350 the variable @code{vc-mistrust-permissions} affects SCCS use, but
351 @code{vc-consult-headers} does not.
353 @node CVS Options
354 @subsubsection Options specific for CVS
356 @vindex vc-cvs-global-switches
357   You can specify additional command line options to pass to all CVS
358 operations in the variable @code{vc-cvs-global-switches}.  These
359 switches are inserted immediately after the @code{cvs} command, before
360 the name of the operation to invoke.
362 @vindex vc-stay-local
363 @vindex vc-cvs-stay-local
364 @cindex remote repositories (CVS)
365   When using a CVS repository on a remote machine, VC can try keeping
366 network interactions to a minimum.  This is controlled by the variable
367 @code{vc-cvs-stay-local}.  There is another variable,
368 @code{vc-stay-local}, which enables the feature also for other back
369 ends that support it, including CVS.  In the following, we will talk
370 only about @code{vc-cvs-stay-local}, but everything applies to
371 @code{vc-stay-local} as well.
373   If @code{vc-cvs-stay-local} is @code{t} (the default), VC determines
374 the version control status of each file using only the entry in the
375 local CVS subdirectory and the information returned by previous CVS
376 commands.  As a consequence, if you have modified a file and somebody
377 else has checked in other changes, you will not be notified of the
378 conflict until you try to commit.
380   If you change @code{vc-cvs-stay-local} to @code{nil}, VC queries the
381 remote repository @emph{before} it decides what to do in
382 @code{vc-next-action} (@kbd{C-x v v}), just as it does for local
383 repositories.
385   You can also set @code{vc-cvs-stay-local} to a regular expression
386 that is matched against the repository host name; VC then stays local
387 only for repositories from hosts that match the pattern.
389 @cindex automatic version backups
390   When using a remote repository, Emacs normally makes @dfn{automatic
391 version backups} of the original versions of each edited file.  These
392 local backups are made whenever you save the first changes to a file,
393 and they are removed after you commit your changes to the repository.
394 (Note that these are not the same as ordinary Emacs backup files;
395 @iftex
396 @pxref{Backup,,,emacs, the Emacs Manual}.)
397 @end iftex
398 @ifnottex
399 @pxref{Backup}.)
400 @end ifnottex
401 Commands like @kbd{C-x v =} and @kbd{C-x v u} make use of automatic
402 version backups, if possible, to avoid having to access the network.
404   Setting @code{vc-cvs-stay-local} to @code{nil} disables the making
405 of automatic version backups.
407 @cindex manual version backups
408   Automatic version backups have names of the form
409 @w{@code{@var{file}.~@var{version}.~}}.  This is similar to the name
410 that @kbd{C-x v ~} saves old versions to
411 @iftex
412 (@pxref{Old Revisions,,,emacs, the Emacs Manual}),
413 @end iftex
414 @ifnottex
415 (@pxref{Old Revisions}),
416 @end ifnottex
417 except for the additional dot (@samp{.}) after the version.  The
418 relevant VC commands can use both kinds of version backups.  The main
419 difference is that the ``manual'' version backups made by @kbd{C-x v
420 ~} are not deleted automatically when you commit.
422 @cindex locking (CVS)
423   CVS does not use locking by default, but there are ways to enable
424 locking-like behavior using its @env{CVSREAD} or @dfn{watch} feature;
425 see the CVS documentation for details.  If that case, you can use
426 @kbd{C-x v v} in Emacs to toggle locking, as you would for a
427 locking-based version control system (@pxref{VC With A Locking VCS}).