comparison contrib/vim/hgcommand.txt @ 2591:61f2008cd6bf

Addition of CVScommand vim script as a base for HGcommand
author "Mathieu Clabaut <mathieu.clabaut@gmail.com>"
date Mon, 10 Jul 2006 23:39:08 +0200
parents
children 457846f400e8
comparison
equal deleted inserted replaced
2576:6a961a54f953 2591:61f2008cd6bf
1 *cvscommand.txt* CVSCommand
2
3 For instructions on installing this file, type
4 :help add-local-help
5 inside Vim.
6
7 Author: Bob Hiestand <bob.hiestand@gmail.com>
8 Credits: Benji Fisher's excellent MatchIt documentation
9
10 ==============================================================================
11 1. Contents *cvscommand-contents*
12
13 Installation : |cvscommand-install|
14 CVSCommand Intro : |cvscommand|
15 CVSCommand Manual : |cvscommand-manual|
16 Customization : |cvscommand-customize|
17 SSH "integration" : |cvscommand-ssh|
18 Bugs : |cvscommand-bugs|
19
20 ==============================================================================
21
22 2. CVSCommand Installation *cvscommand-install*
23
24 The CVSCommand plugin comprises two files, cvscommand.vim and cvscommand.txt
25 (this file). In order to install the plugin, place the cvscommand.vim file
26 into a plugin' directory in your runtime path (please see |add-global-plugin|
27 and |'runtimepath'|.
28
29 CVSCommand may be customized by setting variables, creating maps, and
30 specifying event handlers. Please see |cvscommand-customize| for more
31 details.
32
33 This help file can be included in the VIM help system by copying it into a
34 'doc' directory in your runtime path and then executing the |:helptags|
35 command, specifying the full path of the 'doc' directory. Please see
36 |add-local-help| for more details.
37
38 ==============================================================================
39
40 3. CVSCommand Intro *cvscommand*
41 *cvscommand-intro*
42
43 The CVSCommand plugin provides global ex commands for manipulating
44 CVS-controlled source files. In general, each command operates on the current
45 buffer and accomplishes a separate cvs function, such as update, commit, log,
46 and others (please see |cvscommand-commands| for a list of all available
47 commands). The results of each operation are displayed in a scratch buffer.
48 Several buffer variables are defined for those scratch buffers (please see
49 |cvscommand-buffer-variables|).
50
51 The notion of "current file" means either the current buffer, or, in the case
52 of a directory buffer, the file on the current line within the buffer.
53
54 For convenience, any CVSCommand invoked on a CVSCommand scratch buffer acts as
55 though it was invoked on the original file and splits the screen so that the
56 output appears in a new window.
57
58 Many of the commands accept revisions as arguments. By default, most operate
59 on the most recent revision on the current branch if no revision is specified
60 (though see |CVSCommandInteractive| to prompt instead).
61
62 Each CVSCommand is mapped to a key sequence starting with the <Leader>
63 keystroke. The default mappings may be overridden by supplying different
64 mappings before the plugin is loaded, such as in the vimrc, in the standard
65 fashion for plugin mappings. For examples, please see
66 |cvscommand-mappings-override|.
67
68 The CVSCommand plugin may be configured in several ways. For more details,
69 please see |cvscommand-customize|.
70
71 ==============================================================================
72
73 4. CVSCommand Manual *cvscommand-manual*
74
75 4.1 CVSCommand commands *cvscommand-commands*
76
77 CVSCommand defines the following commands:
78
79 |:CVSAdd|
80 |:CVSAnnotate|
81 |:CVSCommit|
82 |:CVSDiff|
83 |:CVSEdit|
84 |:CVSEditors|
85 |:CVSGotoOriginal|
86 |:CVSLog|
87 |:CVSRevert|
88 |:CVSReview|
89 |:CVSStatus|
90 |:CVSUnedit|
91 |:CVSUpdate|
92 |:CVSVimDiff|
93 |:CVSWatch|
94 |:CVSWatchAdd|
95 |:CVSWatchOn|
96 |:CVSWatchOff|
97 |:CVSWatchRemove|
98 |:CVSWatchers|
99
100 :CVSAdd *:CVSAdd*
101
102 This command performs "cvs add" on the current file. Please note, this does
103 not commit the newly-added file.
104
105 :CVSAnnotate *:CVSAnnotate*
106
107 This command performs "cvs annotate" on the current file. If an argument is
108 given, the argument is used as a revision number to display. If not given an
109 argument, it uses the most recent version of the file on the current branch.
110 Additionally, if the current buffer is a CVSAnnotate buffer already, the
111 version number on the current line is used.
112
113 If the |CVSCommandAnnotateParent| variable is set to a non-zero value, the
114 version previous to the one on the current line is used instead. This allows
115 one to navigate back to examine the previous version of a line.
116
117 The filetype of the CVSCommand scratch buffer is set to 'CVSAnnotate', to take
118 advantage of the bundled syntax file.
119
120
121 :CVSCommit[!] *:CVSCommit*
122
123 If called with arguments, this performs "cvs commit" using the arguments as
124 the log message.
125
126 If '!' is used with no arguments, an empty log message is committed.
127
128 If called with no arguments, this is a two-step command. The first step opens
129 a buffer to accept a log message. When that buffer is written, it is
130 automatically closed and the file is committed using the information from that
131 log message. The commit can be abandoned if the log message buffer is deleted
132 or wiped before being written.
133
134 Alternatively, the mapping that is used to invoke :CVSCommit (by default
135 <Leader>cc) can be used in the log message buffer to immediately commit. This
136 is useful if the |CVSCommandCommitOnWrite| variable is set to 0 to disable the
137 normal commit-on-write behavior.
138
139 :CVSDiff *:CVSDiff*
140
141 With no arguments, this performs "cvs diff" on the current file against the
142 current repository version.
143
144 With one argument, "cvs diff" is performed on the current file against the
145 specified revision.
146
147 With two arguments, cvs diff is performed between the specified
148 revisions of the current file.
149
150 This command uses the 'CVSCommandDiffOpt' variable to specify diff options.
151 If that variable does not exist, then 'wbBc' is assumed. If you wish to have
152 no options, then set it to the empty string.
153
154 :CVSEdit *:CVSEdit*
155
156 This command performs "cvs edit" on the current file. Yes, the output buffer
157 in this case is almost completely useless.
158
159 :CVSEditors *:CVSEditors*
160
161 This command performs "cvs edit" on the current file.
162
163 :CVSGotoOriginal *:CVSGotoOriginal*
164
165 This command returns the current window to the source buffer, if the current
166 buffer is a CVS command output buffer.
167
168 :CVSGotoOriginal!
169
170 Like ":CVSGotoOriginal" but also executes :bufwipeout on all CVS command
171 output buffers for the source buffer.
172
173 :CVSLog *:CVSLog*
174
175 Performs "cvs log" on the current file.
176
177 If an argument is given, it is passed as an argument to the "-r" option of
178 "cvs log".
179
180 :CVSRevert *:CVSRevert*
181
182 Replaces the current file with the most recent version from the repository in
183 order to wipe out any undesired changes.
184
185 :CVSReview *:CVSReview*
186
187 Retrieves a particular version of the current file. If no argument is given,
188 the most recent version of the file on the current branch is retrieved.
189 Otherwise, the specified version is retrieved.
190
191 :CVSStatus *:CVSStatus*
192
193 Performs "cvs status" on the current file.
194
195 :CVSUnedit *:CVSUnedit*
196
197 Performs "cvs unedit" on the current file. Again, yes, the output buffer here
198 is basically useless.
199
200 :CVSUpdate *:CVSUpdate*
201
202 Performs "cvs update" on the current file. This intentionally does not
203 automatically reload the current buffer, though vim should prompt the user to
204 do so if the underlying file is altered by this command.
205
206 :CVSVimDiff *:CVSVimDiff*
207
208 With no arguments, this prompts the user for a revision and then uses vimdiff
209 to display the differences between the current file and the specified
210 revision. If no revision is specified, the most recent version of the file on
211 the current branch is used.
212
213 With one argument, that argument is used as the revision as above. With two
214 arguments, the differences between the two revisions is displayed using
215 vimdiff.
216
217 With either zero or one argument, the original buffer is used to perform the
218 vimdiff. When the other buffer is closed, the original buffer will be
219 returned to normal mode.
220
221 Once vimdiff mode is started using the above methods, additional vimdiff
222 buffers may be added by passing a single version argument to the command.
223 There may be up to 4 vimdiff buffers total.
224
225 Using the 2-argument form of the command resets the vimdiff to only those 2
226 versions. Additionally, invoking the command on a different file will close
227 the previous vimdiff buffers.
228
229 :CVSWatch *:CVSWatch*
230
231 This command takes an argument which must be one of [on|off|add|remove]. The
232 command performs "cvs watch" with the given argument on the current file.
233
234 :CVSWatchAdd *:CVSWatchAdd*
235
236 This command is an alias for ":CVSWatch add"
237
238 :CVSWatchOn *:CVSWatchOn*
239
240 This command is an alias for ":CVSWatch on"
241
242 :CVSWatchOff *:CVSWatchOff*
243
244 This command is an alias for ":CVSWatch off"
245
246 :CVSWatchRemove *:CVSWatchRemove*
247
248 This command is an alias for ":CVSWatch remove"
249
250 :CVSWatchers *:CVSWatchers*
251
252 This command performs "cvs watchers" on the current file.
253
254 4.2 Mappings *cvscommand-mappings*
255
256 By default, a mapping is defined for each command. These mappings execute the
257 default (no-argument) form of each command.
258
259 <Leader>ca CVSAdd
260 <Leader>cn CVSAnnotate
261 <Leader>cc CVSCommit
262 <Leader>cd CVSDiff
263 <Leader>ce CVSEdit
264 <Leader>ci CVSEditors
265 <Leader>cg CVSGotoOriginal
266 <Leader>cG CVSGotoOriginal!
267 <Leader>cl CVSLog
268 <Leader>cr CVSReview
269 <Leader>cs CVSStatus
270 <Leader>ct CVSUnedit
271 <Leader>cu CVSUpdate
272 <Leader>cv CVSVimDiff
273 <Leader>cwv CVSWatchers
274 <Leader>cwa CVSWatchAdd
275 <Leader>cwn CVSWatchOn
276 <Leader>cwf CVSWatchOff
277 <Leader>cwf CVSWatchRemove
278
279 *cvscommand-mappings-override*
280
281 The default mappings can be overriden by user-provided instead by mapping to
282 <Plug>CommandName. This is especially useful when these mappings collide with
283 other existing mappings (vim will warn of this during plugin initialization,
284 but will not clobber the existing mappings).
285
286 For instance, to override the default mapping for :CVSAdd to set it to '\add',
287 add the following to the vimrc:
288
289 nmap \add <Plug>CVSAdd
290
291 4.3 Automatic buffer variables *cvscommand-buffer-variables*
292
293 Several buffer variables are defined in each CVSCommand result buffer. These
294 may be useful for additional customization in callbacks defined in the event
295 handlers (please see |cvscommand-events|).
296
297 The following variables are automatically defined:
298
299 b:cvsOrigBuffNR *b:cvsOrigBuffNR*
300
301 This variable is set to the buffer number of the source file.
302
303 b:cvscmd *b:cvscmd*
304
305 This variable is set to the name of the cvs command that created the result
306 buffer.
307 ==============================================================================
308
309 5. Configuration and customization *cvscommand-customize*
310 *cvscommand-config*
311
312 The CVSCommand plugin can be configured in two ways: by setting configuration
313 variables (see |cvscommand-options|) or by defining CVSCommand event handlers
314 (see |cvscommand-events|). Additionally, the CVSCommand plugin provides
315 several option for naming the CVS result buffers (see |cvscommand-naming|) and
316 supported a customized status line (see |cvscommand-statusline| and
317 |cvscommand-buffer-management|).
318
319 5.1 CVSCommand configuration variables *cvscommand-options*
320
321 Several variables affect the plugin's behavior. These variables are checked
322 at time of execution, and may be defined at the window, buffer, or global
323 level and are checked in that order of precedence.
324
325
326 The following variables are available:
327
328 |CVSCommandAnnotateParent|
329 |CVSCommandCommitOnWrite|
330 |CVSCommandCVSExec|
331 |CVSCommandDeleteOnHide|
332 |CVSCommandDiffOpt|
333 |CVSCommandDiffSplit|
334 |CVSCommandEdit|
335 |CVSCommandEnableBufferSetup|
336 |CVSCommandInteractive|
337 |CVSCommandNameMarker|
338 |CVSCommandNameResultBuffers|
339 |CVSCommandSplit|
340
341 CVSCommandAnnotateParent *CVSCommandAnnotateParent*
342
343 This variable, if set to a non-zero value, causes the zero-argument form of
344 CVSAnnotate when invoked on a CVSAnnotate buffer to go to the version previous
345 to that displayed on the current line. If not set, it defaults to 0.
346
347 CVSCommandCommitOnWrite *CVSCommandCommitOnWrite*
348
349 This variable, if set to a non-zero value, causes the pending cvs commit
350 to take place immediately as soon as the log message buffer is written.
351 If set to zero, only the CVSCommit mapping will cause the pending commit to
352 occur. If not set, it defaults to 1.
353
354 CVSCommandCVSExec *CVSCommandCVSExec*
355
356 This variable controls the executable used for all CVS commands If not set,
357 it defaults to "cvs".
358
359 CVSCommandDeleteOnHide *CVSCommandDeleteOnHide*
360
361 This variable, if set to a non-zero value, causes the temporary CVS result
362 buffers to automatically delete themselves when hidden.
363
364 CVSCommandDiffOpt *CVSCommandDiffOpt*
365
366 This variable, if set, determines the options passed to the diff command of
367 CVS. If not set, it defaults to 'wbBc'.
368
369 CVSCommandDiffSplit *CVSCommandDiffSplit*
370
371 This variable overrides the |CVSCommandSplit| variable, but only for buffers
372 created with |:CVSVimDiff|.
373
374 CVSCommandEdit *CVSCommandEdit*
375
376 This variable controls whether the original buffer is replaced ('edit') or
377 split ('split'). If not set, it defaults to 'edit'.
378
379 CVSCommandEnableBufferSetup *CVSCommandEnableBufferSetup*
380
381 This variable, if set to a non-zero value, activates CVS buffer management
382 mode see (|cvscommand-buffer-management|). This mode means that two buffer
383 variables, 'CVSRevision' and 'CVSBranch', are set if the file is
384 CVS-controlled. This is useful for displaying version information in the
385 status bar.
386
387 CVSCommandInteractive *CVSCommandInteractive*
388
389 This variable, if set to a non-zero value, causes appropriate commands (for
390 the moment, only |:CVSReview|) to query the user for a revision to use instead
391 of the current revision if none is specified.
392
393 CVSCommandNameMarker *CVSCommandNameMarker*
394
395 This variable, if set, configures the special attention-getting characters
396 that appear on either side of the cvs buffer type in the buffer name. This
397 has no effect unless |CVSCommandNameResultBuffers| is set to a true value. If
398 not set, it defaults to '_'.
399
400 CVSCommandNameResultBuffers *CVSCommandNameResultBuffers*
401
402 This variable, if set to a true value, causes the cvs result buffers to be
403 named in the old way ('<source file name> _<cvs command>_'). If not set
404 or set to a false value, the result buffer is nameless.
405
406 CVSCommandSplit *CVSCommandSplit*
407
408 This variable controls the orientation of the various window splits that
409 may occur (such as with CVSVimDiff, when using a CVS command on a CVS
410 command buffer, or when the |CVSCommandEdit| variable is set to 'split'.
411 If set to 'horizontal', the resulting windows will be on stacked on top of
412 one another. If set to 'vertical', the resulting windows will be
413 side-by-side. If not set, it defaults to 'horizontal' for all but
414 CVSVimDiff windows.
415
416 5.2 CVSCommand events *cvscommand-events*
417
418 For additional customization, CVSCommand can trigger user-defined events.
419 Event handlers are provided by defining User event autocommands (see
420 |autocommand|, |User|) in the CVSCommand group with patterns matching the
421 event name.
422
423 For instance, the following could be added to the vimrc to provide a 'q'
424 mapping to quit a CVSCommand scratch buffer:
425
426 augroup CVSCommand
427 au CVSCommand User CVSBufferCreated silent! nmap <unique> <buffer> q: bwipeout<cr>
428 augroup END
429
430 The following hooks are available:
431
432 CVSBufferCreated This event is fired just after a cvs command
433 result buffer is created and filled with the
434 result of a cvs command. It is executed within
435 the context of the CVS command buffer. The
436 CVSCommand buffer variables may be useful for
437 handlers of this event (please see
438 |cvscommand-buffer-variables|).
439
440 CVSBufferSetup This event is fired just after CVS buffer setup
441 occurs, if enabled.
442
443 CVSPluginInit This event is fired when the CVSCommand plugin
444 first loads.
445
446 CVSPluginFinish This event is fired just after the CVSCommand
447 plugin loads.
448
449 CVSVimDiffFinish This event is fired just after the CVSVimDiff
450 command executes to allow customization of,
451 for instance, window placement and focus.
452
453 5.3 CVSCommand buffer naming *cvscommand-naming*
454
455 By default, the buffers containing the result of CVS commands are nameless
456 scratch buffers. It is intended that buffer variables of those buffers be
457 used to customize the statusline option so that the user may fully control the
458 display of result buffers.
459
460 If the old-style naming is desired, please enable the
461 |CVSCommandNameResultBuffers| variable. Then, each result buffer will receive
462 a unique name that includes the source file name, the CVS command, and any
463 extra data (such as revision numbers) that were part of the command.
464
465 5.4 CVSCommand status line support *cvscommand-statusline*
466
467 It is intended that the user will customize the |'statusline'| option to
468 include CVS result buffer attributes. A sample function that may be used in
469 the |'statusline'| option is provided by the plugin, CVSGetStatusLine(). In
470 order to use that function in the status line, do something like the
471 following:
472
473 set statusline=%<%f\ %{CVSGetStatusLine()}\ %h%m%r%=%l,%c%V\ %P
474
475 of which %{CVSGetStatusLine()} is the relevant portion.
476
477 The sample CVSGetStatusLine() function handles both CVS result buffers and
478 CVS-managed files if CVSCommand buffer management is enabled (please see
479 |cvscommand-buffer-management|).
480
481 5.5 CVSCommand buffer management *cvscommand-buffer-management*
482
483 The CVSCommand plugin can operate in buffer management mode, which means that
484 it attempts to set two buffer variables ('CVSRevision' and 'CVSBranch') upon
485 entry into a buffer. This is rather slow because it means that 'cvs status'
486 will be invoked at each entry into a buffer (during the |BufEnter|
487 autocommand).
488
489 This mode is disabled by default. In order to enable it, set the
490 |CVSCommandEnableBufferSetup| variable to a true (non-zero) value. Enabling
491 this mode simply provides the buffer variables mentioned above. The user must
492 explicitly include those in the |'statusline'| option if they are to appear in
493 the status line (but see |cvscommand-statusline| for a simple way to do that).
494
495 ==============================================================================
496
497 6. SSH "integration" *cvscommand-ssh*
498
499 The following instructions are intended for use in integrating the
500 cvscommand.vim plugin with an SSH-based CVS environment.
501
502 Familiarity with SSH and CVS are assumed.
503
504 These instructions assume that the intent is to have a message box pop up in
505 order to allow the user to enter a passphrase. If, instead, the user is
506 comfortable using certificate-based authentication, then only instructions
507 6.1.1 and 6.1.2 (and optionally 6.1.4) need to be followed; ssh should then
508 work transparently.
509
510 6.1 Environment settings *cvscommand-ssh-env*
511
512 6.1.1 CVSROOT should be set to something like:
513
514 :ext:user@host:/path_to_repository
515
516 6.1.2 CVS_RSH should be set to:
517
518 ssh
519
520 Together, those settings tell CVS to use ssh as the transport when
521 performing CVS calls.
522
523 6.1.3 SSH_ASKPASS should be set to the password-dialog program. In my case,
524 running gnome, it's set to:
525
526 /usr/libexec/openssh/gnome-ssh-askpass
527
528 This tells SSH how to get passwords if no input is available.
529
530 6.1.4 OPTIONAL. You may need to set SSH_SERVER to the location of the cvs
531 executable on the remote (server) machine.
532
533 6.2 CVS wrapper program *cvscommand-ssh-wrapper*
534
535 Now you need to convince SSH to use the password-dialog program. This means
536 you need to execute SSH (and therefore CVS) without standard input. The
537 following script is a simple perl wrapper that dissasociates the CVS command
538 from the current terminal. Specific steps to do this may vary from system to
539 system; the following example works for me on linux.
540
541 #!/usr/bin/perl -w
542 use strict;
543 use POSIX qw(setsid);
544 open STDIN, '/dev/null';
545 fork and do {wait; exit;};
546 setsid;
547 exec('cvs', @ARGV);
548
549 6.3 Configuring cvscommand.vim *cvscommand-ssh-config*
550
551 At this point, you should be able to use your wrapper script to invoke CVS with
552 various commands, and get the password dialog. All that's left is to make CVS
553 use your newly-created wrapper script.
554
555 6.3.1 Tell cvscommand.vim what CVS executable to use. The easiest way to do this
556 is globally, by putting the following in your .vimrc:
557
558 let CVSCommandCVSExec=/path/to/cvs/wrapper/script
559
560 6.4 Where to go from here *cvscommand-ssh-other*
561
562 The script given above works even when non-SSH CVS connections are used,
563 except possibly when interactively entering the message for CVS commit log
564 (depending on the editor you use... VIM works fine). Since the cvscommand.vim
565 plugin handles that message without a terminal, the wrapper script can be used
566 all the time.
567
568 This allows mixed-mode operation, where some work is done with SSH-based CVS
569 repositories, and others with pserver or local access.
570
571 It is possible, though beyond the scope of the plugin, to dynamically set the
572 CVS executable based on the CVSROOT for the file being edited. The user
573 events provided (such as CVSBufferCreated and CVSBufferSetup) can be used to
574 set a buffer-local value (b:CVSCommandCVSExec) to override the CVS executable
575 on a file-by-file basis. Alternatively, much the same can be done (less
576 automatically) by the various project-oriented plugins out there.
577
578 It is highly recommended for ease-of-use that certificates with no passphrase
579 or ssh-agent are employed so that the user is not given the password prompt
580 too often.
581
582 ==============================================================================
583 9. Tips *cvscommand-tips*
584
585 9.1 Split window annotation, by Michael Anderson
586
587 :nmap <Leader>cN :vs<CR><C-w>h<Leader>cn:vertical res 40<CR>
588 \ggdddd:set scb<CR>:set nowrap<CR><C-w>lgg:set scb<CR>
589 \:set nowrap<CR>
590
591 This splits the buffer vertically, puts an annotation on the left (minus the
592 header) with the width set to 40. An editable/normal copy is placed on the
593 right. The two versions are scroll locked so they move as one. and wrapping
594 is turned off so that the lines line up correctly. The advantages are...
595
596 1) You get a versioning on the right.
597 2) You can still edit your own code.
598 3) Your own code still has syntax highlighting.
599
600 ==============================================================================
601
602 8. Known bugs *cvscommand-bugs*
603
604 Please let me know if you run across any.
605
606 CVSUnedit may, if a file is changed from the repository, provide prompt text
607 to determine whether the changes should be thrown away. Currently, that text
608 shows up in the CVS result buffer as information; there is no way for the user
609 to actually respond to the prompt and the CVS unedit command does nothing. If
610 this really bothers anyone, please let me know.
611
612 CVSVimDiff, when using the original (real) source buffer as one of the diff
613 buffers, uses some hacks to try to restore the state of the original buffer
614 when the scratch buffer containing the other version is destroyed. There may
615 still be bugs in here, depending on many configuration details.
616
617 vim:tw=78:ts=8:ft=help