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