Initial import of my home directory
[home/.git] / .vim / doc / hgcommand.txt
1 *hgcommand.txt*   Mercurial vim integration                          v0.2
2
3
4                          HGCOMMAND REFERENCE MANUAL~
5
6
7 Author:  Mathieu Clabaut <mathieu.clabaut@gmail.com>
8 Credits:  Bob Hiestand <bob.hiestand@gmail.com>
9 Mercurial: http://www.selenic.com/mercurial
10    Mercurial (noted Hg) is a fast, lightweight Source Control Management
11    system designed for efficient handling of very large distributed projects.
12
13 ==============================================================================
14 1. Contents                                               *hgcommand-contents*
15
16         Installation            : |hgcommand-install|
17         HGCommand Intro         : |hgcommand|
18         HGCommand Manual        : |hgcommand-manual|
19         Customization           : |hgcommand-customize|
20         Bugs                    : |hgcommand-bugs|
21
22 ==============================================================================
23 2. HGCommand Installation                                  *hgcommand-install*
24
25    In order to install the plugin, place the hgcommand.vim file into a plugin'
26    directory in your runtime path (please see |add-global-plugin| and
27    |'runtimepath'|.
28
29    HGCommand may be customized by setting variables, creating maps, and
30    specifying event handlers.  Please see |hgcommand-customize| for more
31    details.
32
33                                                          *hgcommand-auto-help*
34    The help file is automagically generated when the |hgcommand| script is
35    loaded for the first time.
36
37 ==============================================================================
38
39 3. HGCommand Intro                                                 *hgcommand*
40                                                              *hgcommand-intro*
41
42    The HGCommand plugin provides global ex commands for manipulating
43    HG-controlled source files.  In general, each command operates on the
44    current buffer and accomplishes a separate hg function, such as update,
45    commit, log, and others (please see |hgcommand-commands| for a list of all
46    available commands).  The results of each operation are displayed in a
47    scratch buffer.  Several buffer variables are defined for those scratch
48    buffers (please see |hgcommand-buffer-variables|).
49
50    The notion of "current file" means either the current buffer, or, in the
51    case of a directory buffer, the file on the current line within the buffer.
52
53    For convenience, any HGCommand invoked on a HGCommand scratch buffer acts
54    as though it was invoked on the original file and splits the screen so that
55    the output appears in a new window.
56
57    Many of the commands accept revisions as arguments.  By default, most
58    operate on the most recent revision on the current branch if no revision is
59    specified (though see |HGCommandInteractive| to prompt instead).
60
61    Each HGCommand is mapped to a key sequence starting with the <Leader>
62    keystroke.  The default mappings may be overridden by supplying different
63    mappings before the plugin is loaded, such as in the vimrc, in the standard
64    fashion for plugin mappings.  For examples, please see
65    |hgcommand-mappings-override|.
66
67    The HGCommand plugin may be configured in several ways.  For more details,
68    please see |hgcommand-customize|.
69
70 ==============================================================================
71 4. HGCommand Manual                                         *hgcommand-manual*
72
73 4.1 HGCommand commands                                    *hgcommand-commands*
74
75    HGCommand defines the following commands:
76
77       |:HGAdd|
78       |:HGAnnotate|
79       |:HGCommit|
80       |:HGDiff|
81       |:HGGotoOriginal|
82       |:HGLog|
83       |:HGRevert|
84       |:HGReview|
85       |:HGStatus|
86       |:HGUpdate|
87       |:HGVimDiff|
88
89 :HGAdd                                                                *:HGAdd*
90
91    This command performs "hg add" on the current file.  Please note, this does
92    not commit the newly-added file.
93
94 :HGAnnotate                                                      *:HGAnnotate*
95
96    This command performs "hg annotate" on the current file.  If an argument is
97    given, the argument is used as a revision number to display.  If not given
98    an argument, it uses the most recent version of the file on the current
99    branch.  Additionally, if the current buffer is a HGAnnotate buffer
100    already, the version number on the current line is used.
101
102    If the |HGCommandAnnotateParent| variable is set to a non-zero value, the
103    version previous to the one on the current line is used instead.  This
104    allows one to navigate back to examine the previous version of a line.
105
106    The filetype of the HGCommand scratch buffer is set to 'HGAnnotate', to
107    take advantage of the bundled syntax file.
108
109
110 :HGCommit[!]                                                       *:HGCommit*
111
112    If called with arguments, this performs "hg commit" using the arguments as
113    the log message.
114
115    If '!' is used with no arguments, an empty log message is committed.
116
117    If called with no arguments, this is a two-step command.  The first step
118    opens a buffer to accept a log message.  When that buffer is written, it is
119    automatically closed and the file is committed using the information from
120    that log message.  The commit can be abandoned if the log message buffer is
121    deleted or wiped before being written.
122
123    Alternatively, the mapping that is used to invoke :HGCommit (by default
124    <Leader>hgc) can be used in the log message buffer to immediately commit.
125    This is useful if the |HGCommandCommitOnWrite| variable is set to 0 to
126    disable the normal commit-on-write behavior.
127
128 :HGDiff                                                              *:HGDiff*
129
130    With no arguments, this performs "hg diff" on the current file against the
131    current repository version.
132
133    With one argument, "hg diff" is performed on the current file against the
134    specified revision.
135
136    With two arguments, hg diff is performed between the specified revisions of
137    the current file.
138
139    This command uses the 'HGCommandDiffOpt' variable to specify diff options.
140    If that variable does not exist, then 'wbBc' is assumed.  If you wish to
141    have no options, then set it to the empty string.
142
143
144 :HGGotoOriginal                                              *:HGGotoOriginal*
145
146    This command returns the current window to the source buffer, if the
147    current buffer is a HG command output buffer.
148
149 :HGGotoOriginal!
150
151    Like ":HGGotoOriginal" but also executes :bufwipeout on all HG command
152    output buffers for the source buffer.
153
154 :HGLog                                                                *:HGLog*
155
156    Performs "hg log" on the current file.
157
158    If an argument is given, it is passed as an argument to the "-r" option of
159    "hg log".
160
161 :HGRevert                                                          *:HGRevert*
162
163    Replaces the current file with the most recent version from the repository
164    in order to wipe out any undesired changes.
165
166 :HGReview                                                          *:HGReview*
167
168    Retrieves a particular version of the current file.  If no argument is
169    given, the most recent version of the file on the current branch is
170    retrieved.  Otherwise, the specified version is retrieved.
171
172 :HGStatus                                                          *:HGStatus*
173
174    Performs "hg status" on the current file.
175
176 :HGUpdate                                                          *:HGUpdate*
177
178    Performs "hg update" on the current file.  This intentionally does not
179    automatically reload the current buffer, though vim should prompt the user
180    to do so if the underlying file is altered by this command.
181
182 :HGVimDiff                                                        *:HGVimDiff*
183
184    With no arguments, this prompts the user for a revision and then uses
185    vimdiff to display the differences between the current file and the
186    specified revision.  If no revision is specified, the most recent version
187    of the file on the current branch is used.
188
189    With one argument, that argument is used as the revision as above.  With
190    two arguments, the differences between the two revisions is displayed using
191    vimdiff.
192
193    With either zero or one argument, the original buffer is used to perform
194    the vimdiff.  When the other buffer is closed, the original buffer will be
195    returned to normal mode.
196
197    Once vimdiff mode is started using the above methods, additional vimdiff
198    buffers may be added by passing a single version argument to the command.
199    There may be up to 4 vimdiff buffers total.
200
201    Using the 2-argument form of the command resets the vimdiff to only those 2
202    versions.  Additionally, invoking the command on a different file will
203    close the previous vimdiff buffers.
204
205
206 4.2 Mappings                                              *hgcommand-mappings*
207
208    By default, a mapping is defined for each command.  These mappings execute
209    the default (no-argument) form of each command.
210
211       <Leader>hga HGAdd
212       <Leader>hgn HGAnnotate
213       <Leader>hgc HGCommit
214       <Leader>hgd HGDiff
215       <Leader>hgg HGGotoOriginal
216       <Leader>hgG HGGotoOriginal!
217       <Leader>hgl HGLog
218       <Leader>hgr HGReview
219       <Leader>hgs HGStatus
220       <Leader>hgu HGUpdate
221       <Leader>hgv HGVimDiff
222
223                                                  *hgcommand-mappings-override*
224
225    The default mappings can be overriden by user-provided instead by mapping
226    to <Plug>CommandName.  This is especially useful when these mappings
227    collide with other existing mappings (vim will warn of this during plugin
228    initialization, but will not clobber the existing mappings).
229
230    For instance, to override the default mapping for :HGAdd to set it to
231    '\add', add the following to the vimrc: >
232
233       nmap \add <Plug>HGAdd
234 <
235 4.3 Automatic buffer variables                    *hgcommand-buffer-variables*
236
237    Several buffer variables are defined in each HGCommand result buffer.
238    These may be useful for additional customization in callbacks defined in
239    the event handlers (please see |hgcommand-events|).
240
241    The following variables are automatically defined:
242
243 b:hgOrigBuffNR                                                *b:hgOrigBuffNR*
244
245    This variable is set to the buffer number of the source file.
246
247 b:hgcmd                                                              *b:hgcmd*
248
249    This variable is set to the name of the hg command that created the result
250    buffer.
251 ==============================================================================
252
253 5. Configuration and customization                       *hgcommand-customize*
254                                                             *hgcommand-config*
255
256    The HGCommand plugin can be configured in two ways:  by setting
257    configuration variables (see |hgcommand-options|) or by defining HGCommand
258    event handlers (see |hgcommand-events|).  Additionally, the HGCommand
259    plugin provides several option for naming the HG result buffers (see
260    |hgcommand-naming|) and supported a customized status line (see
261    |hgcommand-statusline| and |hgcommand-buffer-management|).
262
263 5.1 HGCommand configuration variables                      *hgcommand-options*
264
265    Several variables affect the plugin's behavior.  These variables are
266    checked at time of execution, and may be defined at the window, buffer, or
267    global level and are checked in that order of precedence.
268
269
270    The following variables are available:
271
272       |HGCommandAnnotateParent|
273       |HGCommandCommitOnWrite|
274       |HGCommandHGExec|
275       |HGCommandDeleteOnHide|
276       |HGCommandDiffOpt|
277       |HGCommandDiffSplit|
278       |HGCommandEdit|
279       |HGCommandEnableBufferSetup|
280       |HGCommandInteractive|
281       |HGCommandNameMarker|
282       |HGCommandNameResultBuffers|
283       |HGCommandSplit|
284
285 HGCommandAnnotateParent                              *HGCommandAnnotateParent*
286
287    This variable, if set to a non-zero value, causes the zero-argument form of
288    HGAnnotate when invoked on a HGAnnotate buffer to go to the version
289    previous to that displayed on the current line. If not set, it defaults to
290    0.
291
292 HGCommandCommitOnWrite                                *HGCommandCommitOnWrite*
293
294    This variable, if set to a non-zero value, causes the pending hg commit to
295    take place immediately as soon as the log message buffer is written.  If
296    set to zero, only the HGCommit mapping will cause the pending commit to
297    occur.  If not set, it defaults to 1.
298
299 HGCommandHGExec                                              *HGCommandHGExec*
300
301    This variable controls the executable used for all HG commands.  If not
302    set, it defaults to "hg".
303
304 HGCommandDeleteOnHide                                  *HGCommandDeleteOnHide*
305
306    This variable, if set to a non-zero value, causes the temporary HG result
307    buffers to automatically delete themselves when hidden.
308
309 HGCommandDiffOpt                                            *HGCommandDiffOpt*
310
311    This variable, if set, determines the options passed to the diff command of
312    HG.  If not set, it defaults to 'w'.
313
314 HGCommandDiffSplit                                        *HGCommandDiffSplit*
315
316    This variable overrides the |HGCommandSplit| variable, but only for buffers
317    created with |:HGVimDiff|.
318
319 HGCommandEdit                                                  *HGCommandEdit*
320
321    This variable controls whether the original buffer is replaced ('edit') or
322    split ('split').  If not set, it defaults to 'edit'.
323
324 HGCommandEnableBufferSetup                        *HGCommandEnableBufferSetup*
325
326    This variable, if set to a non-zero value, activates HG buffer management
327    mode see (|hgcommand-buffer-management|).  This mode means that three
328    buffer variables, 'HGRepository', 'HGRevision' and 'HGBranch', are set if
329    the file is HG-controlled.  This is useful for displaying version
330    information in the status bar.
331
332 HGCommandInteractive                                    *HGCommandInteractive*
333
334    This variable, if set to a non-zero value, causes appropriate commands (for
335    the moment, only |:HGReview|) to query the user for a revision to use
336    instead of the current revision if none is specified.
337
338 HGCommandNameMarker                                      *HGCommandNameMarker*
339
340    This variable, if set, configures the special attention-getting characters
341    that appear on either side of the hg buffer type in the buffer name.  This
342    has no effect unless |HGCommandNameResultBuffers| is set to a true value.
343    If not set, it defaults to '_'.
344
345 HGCommandNameResultBuffers                        *HGCommandNameResultBuffers*
346
347    This variable, if set to a true value, causes the hg result buffers to be
348    named in the old way ('<source file name> _<hg command>_').  If not set or
349    set to a false value, the result buffer is nameless.
350
351 HGCommandSplit                                                *HGCommandSplit*
352
353    This variable controls the orientation of the various window splits that
354    may occur (such as with HGVimDiff, when using a HG command on a HG command
355    buffer, or when the |HGCommandEdit| variable is set to 'split'.  If set to
356    'horizontal', the resulting windows will be on stacked on top of one
357    another.  If set to 'vertical', the resulting windows will be side-by-side.
358    If not set, it defaults to 'horizontal' for all but HGVimDiff windows.
359
360 5.2 HGCommand events                                        *hgcommand-events*
361
362    For additional customization, HGCommand can trigger user-defined events.
363    Event handlers are provided by defining User event autocommands (see
364    |autocommand|, |User|) in the HGCommand group with patterns matching the
365    event name.
366
367    For instance, the following could be added to the vimrc to provide a 'q'
368    mapping to quit a HGCommand scratch buffer: >
369
370       augroup HGCommand
371          au HGCommand User HGBufferCreated silent! nmap <unique> <buffer> q:
372          bwipeout<cr>
373       augroup END
374 <
375
376    The following hooks are available:
377
378 HGBufferCreated         This event is fired just after a hg command result
379                         buffer is created and filled with the result of a hg
380                         command.  It is executed within the context of the HG
381                         command buffer.  The HGCommand buffer variables may be
382                         useful for handlers of this event (please see
383                         |hgcommand-buffer-variables|).
384
385 HGBufferSetup           This event is fired just after HG buffer setup occurs,
386                         if enabled.
387
388 HGPluginInit            This event is fired when the HGCommand plugin first
389                         loads.
390
391 HGPluginFinish          This event is fired just after the HGCommand plugin
392                         loads.
393
394 HGVimDiffFinish         This event is fired just after the HGVimDiff command
395                         executes to allow customization of, for instance,
396                         window placement and focus.
397
398 5.3 HGCommand buffer naming                                 *hgcommand-naming*
399
400    By default, the buffers containing the result of HG commands are nameless
401    scratch buffers.  It is intended that buffer variables of those buffers be
402    used to customize the statusline option so that the user may fully control
403    the display of result buffers.
404
405    If the old-style naming is desired, please enable the
406    |HGCommandNameResultBuffers| variable.  Then, each result buffer will
407    receive a unique name that includes the source file name, the HG command,
408    and any extra data (such as revision numbers) that were part of the
409    command.
410
411 5.4 HGCommand status line support                       *hgcommand-statusline*
412
413    It is intended that the user will customize the |'statusline'| option to
414    include HG result buffer attributes.  A sample function that may be used in
415    the |'statusline'| option is provided by the plugin, HGGetStatusLine().  In
416    order to use that function in the status line, do something like the
417    following: >
418
419       set statusline=%<%f\ %{HGGetStatusLine()}\ %h%m%r%=%l,%c%V\ %P
420 <
421    of which %{HGGetStatusLine()} is the relevant portion.
422
423    The sample HGGetStatusLine() function handles both HG result buffers and
424    HG-managed files if HGCommand buffer management is enabled (please see
425    |hgcommand-buffer-management|).
426
427 5.5 HGCommand buffer management                  *hgcommand-buffer-management*
428
429    The HGCommand plugin can operate in buffer management mode, which means
430    that it attempts to set two buffer variables ('HGRevision' and 'HGBranch')
431    upon entry into a buffer.  This is rather slow because it means that 'hg
432    status' will be invoked at each entry into a buffer (during the |BufEnter|
433    autocommand).
434
435    This mode is enabled by default.  In order to disable it, set the
436    |HGCommandEnableBufferSetup| variable to a false (zero) value.  Enabling
437    this mode simply provides the buffer variables mentioned above.  The user
438    must explicitly include those in the |'statusline'| option if they are to
439    appear in the status line (but see |hgcommand-statusline| for a simple way
440    to do that).
441
442 ==============================================================================
443 9. Tips                                                       *hgcommand-tips*
444
445 9.1 Split window annotation, by Michael Anderson >
446
447    :nmap <Leader>hgN :vs<CR><C-w>h<Leader>hgn:vertical res 40<CR>
448                  \ggdddd:set scb<CR>:set nowrap<CR><C-w>lgg:set scb<CR>
449                  \:set nowrap<CR>
450 <
451
452    This splits the buffer vertically, puts an annotation on the left (minus
453    the header) with the width set to 40. An editable/normal copy is placed on
454    the right.  The two versions are scroll locked so they  move as one. and
455    wrapping is turned off so that the lines line up correctly. The advantages
456    are...
457
458    1) You get a versioning on the right.
459    2) You can still edit your own code.
460    3) Your own code still has syntax highlighting.
461
462 ==============================================================================
463
464 8. Known bugs                                                 *hgcommand-bugs*
465
466    Please let me know if you run across any.
467
468    HGVimDiff, when using the original (real) source buffer as one of the diff
469    buffers, uses some hacks to try to restore the state of the original buffer
470    when the scratch buffer containing the other version is destroyed.  There
471    may still be bugs in here, depending on many configuration details.
472
473 ==============================================================================
474
475 9. TODO                                                       *hgcommand-todo*
476
477    Integrate symlink tracking once HG will support them.
478 ==============================================================================
479
480  vim:tw=78:ts=8:ft=help:norl: