]> code.delx.au - gnu-emacs/blob - doc/emacs/vc1-xtra.texi
More updates for VC documentation.
[gnu-emacs] / doc / emacs / vc1-xtra.texi
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).
7
8 @node Miscellaneous VC
9 @subsection Miscellaneous Commands and Features of VC
10
11 This section explains the less-frequently-used features of VC.
12
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
20
21 @node Change Logs and VC
22 @subsubsection Change Logs and VC
23
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.
33
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
46
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}).
55
56 @item C-u C-x v a
57 As above, but only find entries for the current buffer's file.
58 @end table
59
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:
65
66 @iftex
67 @medbreak
68 @end iftex
69 @smallexample
70 @group
71 1999-05-22 Nathaniel Bowditch <nat@@apn.org>
72
73 * rcs2log: Ignore log messages that start with `#'.
74 @end group
75 @end smallexample
76 @iftex
77 @medbreak
78 @end iftex
79
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:
86
87 @iftex
88 @medbreak
89 @end iftex
90 @smallexample
91 @group
92 1999-05-06 Nathaniel Bowditch <nat@@apn.org>
93
94 * vc.el (vc-do-command): Check call-process status.
95 @end group
96 @end smallexample
97 @iftex
98 @medbreak
99 @end iftex
100
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.
106
107 @node Renaming and VC
108 @subsubsection Renaming VC Work Files and Master Files
109 @cindex renaming version-controlled files
110
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
116
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.
123
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.
129
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.
134
135 @node Revision Tags
136 @subsubsection Revision Tags
137 @cindex revision tag
138 @cindex tags for version control
139
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.
147
148 There are two basic commands for tags; one makes a tag with a given
149 name, the other retrieves a named tag.
150
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}).
158
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}).
166
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
171
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.
182
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.
187
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.
203
204 @node Version Headers
205 @subsubsection Inserting Version Control Headers
206
207 Sometimes it is convenient to put version identification strings
208 directly into working files. Certain special strings called
209 @dfn{version headers} are replaced in each successive version by the
210 number of that version, the name of the user who created it, and other
211 relevant information. All of the back ends that VC supports have such
212 a mechanism, except GNU Arch.
213
214 VC does not normally use the information contained in these headers.
215 The exception is RCS---with RCS, version headers are sometimes more
216 reliable than the master file to determine which version of the file
217 you are editing.
218
219 Searching for RCS version headers is controlled by the variable
220 @code{vc-consult-headers}. If it is non-@code{nil} (the default),
221 Emacs searches for headers to determine the version number you are
222 editing. Setting it to @code{nil} disables this feature.
223
224 Note that although CVS uses the same kind of version headers as RCS
225 does, VC never searches for these headers if you are using CVS,
226 regardless of the above setting.
227
228 @kindex C-x v h
229 @findex vc-insert-headers
230 You can use the @kbd{C-x v h} command (@code{vc-insert-headers}) to
231 insert a suitable header string.
232
233 @table @kbd
234 @item C-x v h
235 Insert headers in a file for use with your version-control system.
236 @end table
237
238 @vindex vc-@var{backend}-header
239 The default header string is @samp{@w{$}Id$} for RCS and
240 @samp{@w{%}W%} for SCCS. You can specify other headers to insert by
241 setting the variables @code{vc-@var{backend}-header} where
242 @var{backend} is @code{rcs} or @code{sccs}.
243
244 Instead of a single string, you can specify a list of strings; then
245 each string in the list is inserted as a separate header on a line of
246 its own.
247
248 It may be necessary to use apparently-superfluous backslashes when
249 writing the strings that you put in this variable. For instance, you
250 might write @code{"$Id\$"} rather than @code{"$Id@w{$}"}. The extra
251 backslash prevents the string constant from being interpreted as a
252 header, if the Emacs Lisp file containing it is maintained with
253 version control.
254
255 @vindex vc-comment-alist
256 Each header is inserted surrounded by tabs, inside comment delimiters,
257 on a new line at point. Normally the ordinary comment
258 start and comment end strings of the current mode are used, but for
259 certain modes, there are special comment delimiters for this purpose;
260 the variable @code{vc-comment-alist} specifies them. Each element of
261 this list has the form @code{(@var{mode} @var{starter} @var{ender})}.
262
263 @vindex vc-static-header-alist
264 The variable @code{vc-static-header-alist} specifies further strings
265 to add based on the name of the buffer. Its value should be a list of
266 elements of the form @code{(@var{regexp} . @var{format})}. Whenever
267 @var{regexp} matches the buffer name, @var{format} is inserted as part
268 of the header. A header line is inserted for each element that matches
269 the buffer name, and for each string specified by
270 @code{vc-@var{backend}-header}. The header line is made by processing the
271 string from @code{vc-@var{backend}-header} with the format taken from the
272 element. The default value for @code{vc-static-header-alist} is as follows:
273
274 @example
275 @group
276 (("\\.c$" .
277 "\n#ifndef lint\nstatic char vcid[] = \"\%s\";\n\
278 #endif /* lint */\n"))
279 @end group
280 @end example
281
282 @noindent
283 It specifies insertion of text of this form:
284
285 @example
286 @group
287
288 #ifndef lint
289 static char vcid[] = "@var{string}";
290 #endif /* lint */
291 @end group
292 @end example
293
294 @noindent
295 Note that the text above starts with a blank line.
296
297 If you use more than one version header in a file, put them close
298 together in the file. The mechanism in @code{revert-buffer} that
299 preserves markers may not handle markers positioned between two version
300 headers.
301
302 @node Customizing VC
303 @subsection Customizing VC
304
305 @vindex vc-handled-backends
306 The variable @code{vc-handled-backends} determines which version
307 control systems VC should handle. The default value is @code{(RCS CVS
308 SVN SCCS Bzr Git Hg Mtn Arch)}, so it contains all the version systems
309 that are currently supported. If you want VC to ignore one or more of
310 these systems, exclude its name from the list. To disable VC entirely,
311 set this variable to @code{nil}.
312
313 The order of systems in the list is significant: when you visit a file
314 registered in more than one system, VC uses the system that comes
315 first in @code{vc-handled-backends} by default. The order is also
316 significant when you register a file for the first time, see
317 @iftex
318 @ref{Registering,,,emacs, the Emacs Manual},
319 @end iftex
320 @ifnottex
321 @ref{Registering},
322 @end ifnottex
323 for details.
324
325 @menu
326 * General VC Options:: Options that apply to multiple back ends.
327 * RCS and SCCS:: Options for RCS and SCCS.
328 * CVS Options:: Options for CVS.
329 @end menu
330
331 @node General VC Options
332 @subsubsection General Options
333
334 @vindex vc-make-backup-files
335 Emacs normally does not save backup files for source files that are
336 maintained with version control. If you want to make backup files even
337 for files that use version control, set the variable
338 @code{vc-make-backup-files} to a non-@code{nil} value.
339
340 @vindex vc-keep-workfiles
341 Normally the work file exists all the time, whether it is locked or
342 not. If you set @code{vc-keep-workfiles} to @code{nil}, then checking
343 in a new version with @kbd{C-x v v} deletes the work file; but any
344 attempt to visit the file with Emacs creates it again. (With CVS, work
345 files are always kept.)
346
347 @vindex vc-follow-symlinks
348 Editing a version-controlled file through a symbolic link can be
349 dangerous. It bypasses the version control system---you can edit the
350 file without locking it, and fail to check your changes in. Also,
351 your changes might overwrite those of another user. To protect against
352 this, VC checks each symbolic link that you visit, to see if it points
353 to a file under version control.
354
355 The variable @code{vc-follow-symlinks} controls what to do when a
356 symbolic link points to a version-controlled file. If it is @code{nil},
357 VC only displays a warning message. If it is @code{t}, VC automatically
358 follows the link, and visits the real file instead, telling you about
359 this in the echo area. If the value is @code{ask} (the default), VC
360 asks you each time whether to follow the link.
361
362 @vindex vc-suppress-confirm
363 If @code{vc-suppress-confirm} is non-@code{nil}, then @kbd{C-x v v}
364 and @kbd{C-x v i} can save the current buffer without asking, and
365 @kbd{C-x v u} also operates without asking for confirmation. (This
366 variable does not affect @kbd{C-x v c}; that operation is so drastic
367 that it should always ask for confirmation.)
368
369 @vindex vc-command-messages
370 VC mode does much of its work by running the shell commands for the
371 appropriate backend. If @code{vc-command-messages} is non-@code{nil}, VC
372 displays messages to indicate which shell commands it runs, and
373 additional messages when the commands finish.
374
375 @vindex vc-path
376 You can specify additional directories to search for version control
377 programs by setting the variable @code{vc-path}. These directories
378 are searched before the usual search path. It is rarely necessary to
379 set this variable, because VC normally finds the proper files
380 automatically.
381
382 @node RCS and SCCS
383 @subsubsection Options for RCS and SCCS
384
385 @cindex non-strict locking (RCS)
386 @cindex locking, non-strict (RCS)
387 By default, RCS uses locking to coordinate the activities of several
388 users, but there is a mode called @dfn{non-strict locking} in which
389 you can check-in changes without locking the file first. Use
390 @samp{rcs -U} to switch to non-strict locking for a particular file,
391 see the @code{rcs} manual page for details.
392
393 When deducing the version control state of an RCS file, VC first
394 looks for an RCS version header string in the file (@pxref{Version
395 Headers}). If there is no header string, VC normally looks at the
396 file permissions of the work file; this is fast. But there might be
397 situations when the file permissions cannot be trusted. In this case
398 the master file has to be consulted, which is rather expensive. Also
399 the master file can only tell you @emph{if} there's any lock on the
400 file, but not whether your work file really contains that locked
401 version.
402
403 @vindex vc-consult-headers
404 You can tell VC not to use version headers to determine the file
405 status by setting @code{vc-consult-headers} to @code{nil}. VC then
406 always uses the file permissions (if it is supposed to trust them), or
407 else checks the master file.
408
409 @vindex vc-mistrust-permissions
410 You can specify the criterion for whether to trust the file
411 permissions by setting the variable @code{vc-mistrust-permissions}.
412 Its value can be @code{t} (always mistrust the file permissions and
413 check the master file), @code{nil} (always trust the file
414 permissions), or a function of one argument which makes the decision.
415 The argument is the directory name of the @file{RCS} subdirectory. A
416 non-@code{nil} value from the function says to mistrust the file
417 permissions. If you find that the file permissions of work files are
418 changed erroneously, set @code{vc-mistrust-permissions} to @code{t}.
419 Then VC always checks the master file to determine the file's status.
420
421 VC determines the version control state of files under SCCS much as
422 with RCS. It does not consider SCCS version headers, though. Thus,
423 the variable @code{vc-mistrust-permissions} affects SCCS use, but
424 @code{vc-consult-headers} does not.
425
426 @node CVS Options
427 @subsubsection Options specific for CVS
428
429 @vindex vc-cvs-global-switches
430 You can specify additional command line options to pass to all CVS
431 operations in the variable @code{vc-cvs-global-switches}. These
432 switches are inserted immediately after the @code{cvs} command, before
433 the name of the operation to invoke.
434
435 @vindex vc-stay-local
436 @vindex vc-cvs-stay-local
437 @cindex remote repositories (CVS)
438 When using a CVS repository on a remote machine, VC can try keeping
439 network interactions to a minimum. This is controlled by the variable
440 @code{vc-cvs-stay-local}. There is another variable,
441 @code{vc-stay-local}, which enables the feature also for other back
442 ends that support it, including CVS. In the following, we will talk
443 only about @code{vc-cvs-stay-local}, but everything applies to
444 @code{vc-stay-local} as well.
445
446 If @code{vc-cvs-stay-local} is @code{t} (the default), VC determines
447 the version control status of each file using only the entry in the
448 local CVS subdirectory and the information returned by previous CVS
449 commands. As a consequence, if you have modified a file and somebody
450 else has checked in other changes, you will not be notified of the
451 conflict until you try to commit.
452
453 If you change @code{vc-cvs-stay-local} to @code{nil}, VC queries the
454 remote repository @emph{before} it decides what to do in
455 @code{vc-next-action} (@kbd{C-x v v}), just as it does for local
456 repositories.
457
458 You can also set @code{vc-cvs-stay-local} to a regular expression
459 that is matched against the repository host name; VC then stays local
460 only for repositories from hosts that match the pattern.
461
462 @cindex automatic version backups
463 When using a remote repository, Emacs normally makes @dfn{automatic
464 version backups} of the original versions of each edited file. These
465 local backups are made whenever you save the first changes to a file,
466 and they are removed after you commit your changes to the repository.
467 (Note that these are not the same as ordinary Emacs backup files;
468 @iftex
469 @pxref{Backup,,,emacs, the Emacs Manual}.)
470 @end iftex
471 @ifnottex
472 @pxref{Backup}.)
473 @end ifnottex
474 Commands like @kbd{C-x v =} and @kbd{C-x v u} make use of automatic
475 version backups, if possible, to avoid having to access the network.
476
477 Setting @code{vc-cvs-stay-local} to @code{nil} disables the making
478 of automatic version backups.
479
480 @cindex manual version backups
481 Automatic version backups have names of the form
482 @w{@code{@var{file}.~@var{version}.~}}. This is similar to the name
483 that @kbd{C-x v ~} saves old versions to
484 @iftex
485 (@pxref{Old Revisions,,,emacs, the Emacs Manual}),
486 @end iftex
487 @ifnottex
488 (@pxref{Old Revisions}),
489 @end ifnottex
490 except for the additional dot (@samp{.}) after the version. The
491 relevant VC commands can use both kinds of version backups. The main
492 difference is that the ``manual'' version backups made by @kbd{C-x v
493 ~} are not deleted automatically when you commit.
494
495 @cindex locking (CVS)
496 CVS does not use locking by default, but there are ways to enable
497 locking-like behavior using its @env{CVSREAD} or @dfn{watch} feature;
498 see the CVS documentation for details. If that case, you can use
499 @kbd{C-x v v} in Emacs to toggle locking, as you would for a
500 locking-based version control system (@pxref{VC With A Locking VCS}).