1 " vim600: set foldmethod=marker: |
1 " vim600: set foldmethod=marker: |
2 " |
2 " |
3 " Vim plugin to assist in working with HG-controlled files. |
3 " Vim plugin to assist in working with HG-controlled files. |
4 " |
4 " |
5 " Last Change: 2006/02/22 |
5 " Last Change: 2006/02/22 |
6 " Version: 1.76 |
6 " Version: 1.77 |
7 " Maintainer: Mathieu Clabaut <mathieu.clabaut@gmail.com> |
7 " Maintainer: Mathieu Clabaut <mathieu.clabaut@gmail.com> |
8 " License: This file is placed in the public domain. |
8 " License: This file is placed in the public domain. |
9 " Credits: |
9 " Credits: |
10 " Bob Hiestand <bob.hiestand@gmail.com> for the fabulous |
10 " Bob Hiestand <bob.hiestand@gmail.com> for the fabulous |
11 " cvscommand.vim from which this script was directly created by |
11 " cvscommand.vim from which this script was directly created by |
12 " means of sed commands and minor tweaks. |
12 " means of sed commands and minor tweaks. |
13 |
13 |
14 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
14 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
15 " |
15 " |
16 " Section: Documentation |
16 " Section: Documentation |
17 "---------------------------- |
17 "---------------------------- |
18 " |
18 " |
19 " Documentation should be available by ":help hgcommand" command, once the |
19 " Documentation should be available by ":help hgcommand" command, once the |
20 " script has been copied in you .vim/plugin directory. |
20 " script has been copied in you .vim/plugin directory. |
21 " |
21 " |
22 " You still can read the documentation at the end of this file. Locate it by |
22 " You still can read the documentation at the end of this file. Locate it by |
23 " searching the "hgcommand-contents" string (and set ft=help to have |
23 " searching the "hgcommand-contents" string (and set ft=help to have |
24 " appropriate syntaxic coloration). |
24 " appropriate syntaxic coloration). |
25 |
25 |
26 " Section: Plugin header {{{1 |
26 " Section: Plugin header {{{1 |
27 |
27 |
28 " loaded_hgcommand is set to 1 when the initialization begins, and 2 when it |
28 " loaded_hgcommand is set to 1 when the initialization begins, and 2 when it |
29 " completes. This allows various actions to only be taken by functions after |
29 " completes. This allows various actions to only be taken by functions after |
61 " Fully resolve the given file name to remove shortcuts or symbolic links. |
83 " Fully resolve the given file name to remove shortcuts or symbolic links. |
62 |
84 |
63 function! s:HGResolveLink(fileName) |
85 function! s:HGResolveLink(fileName) |
64 let resolved = resolve(a:fileName) |
86 let resolved = resolve(a:fileName) |
65 if resolved != a:fileName |
87 if resolved != a:fileName |
66 let resolved = s:HGResolveLink(resolved) |
88 let resolved = <SID>HGResolveLink(resolved) |
67 endif |
89 endif |
68 return resolved |
90 return resolved |
69 endfunction |
91 endfunction |
70 |
92 |
71 " Function: s:HGChangeToCurrentFileDir() {{{2 |
93 " Function: s:HGChangeToCurrentFileDir() {{{2 |
72 " Go to the directory in which the current HG-controlled file is located. |
94 " Go to the directory in which the current HG-controlled file is located. |
73 " If this is a HG command buffer, first switch to the original file. |
95 " If this is a HG command buffer, first switch to the original file. |
74 |
96 |
75 function! s:HGChangeToCurrentFileDir(fileName) |
97 function! s:HGChangeToCurrentFileDir(fileName) |
76 let oldCwd=getcwd() |
98 let oldCwd=getcwd() |
77 let fileName=s:HGResolveLink(a:fileName) |
99 let fileName=<SID>HGResolveLink(a:fileName) |
78 let newCwd=fnamemodify(fileName, ':h') |
100 let newCwd=fnamemodify(fileName, ':h') |
79 if strlen(newCwd) > 0 |
101 if strlen(newCwd) > 0 |
80 execute 'cd' escape(newCwd, ' ') |
102 execute 'cd' escape(newCwd, ' ') |
81 endif |
103 endif |
82 return oldCwd |
104 return oldCwd |
83 endfunction |
105 endfunction |
84 |
106 |
85 " Function: s:HGGetOption(name, default) {{{2 |
107 " Function: <SID>HGGetOption(name, default) {{{2 |
86 " Grab a user-specified option to override the default provided. Options are |
108 " Grab a user-specified option to override the default provided. Options are |
87 " searched in the window, buffer, then global spaces. |
109 " searched in the window, buffer, then global spaces. |
88 |
110 |
89 function! s:HGGetOption(name, default) |
111 function! s:HGGetOption(name, default) |
90 if exists("s:" . a:name . "Override") |
112 if exists("s:" . a:name . "Override") |
273 " Function: s:HGDoCommand(hgcmd, cmdName, statusText) {{{2 |
295 " Function: s:HGDoCommand(hgcmd, cmdName, statusText) {{{2 |
274 " General skeleton for HG function execution. |
296 " General skeleton for HG function execution. |
275 " Returns: name of the new command buffer containing the command results |
297 " Returns: name of the new command buffer containing the command results |
276 |
298 |
277 function! s:HGDoCommand(cmd, cmdName, statusText) |
299 function! s:HGDoCommand(cmd, cmdName, statusText) |
278 let hgBufferCheck=s:HGCurrentBufferCheck() |
300 let hgBufferCheck=<SID>HGCurrentBufferCheck() |
279 if hgBufferCheck == -1 |
301 if hgBufferCheck == -1 |
280 echo "Original buffer no longer exists, aborting." |
302 echo "Original buffer no longer exists, aborting." |
281 return -1 |
303 return -1 |
282 endif |
304 endif |
283 |
305 |
284 let fileName=bufname(hgBufferCheck) |
306 let fileName=bufname(hgBufferCheck) |
285 if isdirectory(fileName) |
307 if isdirectory(fileName) |
286 let fileName=fileName . "/" . getline(".") |
308 let fileName=fileName . "/" . getline(".") |
287 endif |
309 endif |
288 let realFileName = fnamemodify(s:HGResolveLink(fileName), ':t') |
310 let realFileName = fnamemodify(<SID>HGResolveLink(fileName), ':t') |
289 let oldCwd=s:HGChangeToCurrentFileDir(fileName) |
311 let oldCwd=<SID>HGChangeToCurrentFileDir(fileName) |
290 try |
312 try |
291 " TODO |
313 " TODO |
292 "if !filereadable('HG/Root') |
314 "if !filereadable('HG/Root') |
293 "throw fileName . ' is not a HG-controlled file.' |
315 "throw fileName . ' is not a HG-controlled file.' |
294 "endif |
316 "endif |
295 let fullCmd = a:cmd . ' "' . realFileName . '"' |
317 let fullCmd = a:cmd . ' "' . realFileName . '"' |
296 "echomsg "DEBUG".fullCmd |
318 "echomsg "DEBUG".fullCmd |
297 let resultBuffer=s:HGCreateCommandBuffer(fullCmd, a:cmdName, a:statusText, hgBufferCheck) |
319 let resultBuffer=<SID>HGCreateCommandBuffer(fullCmd, a:cmdName, a:statusText, hgBufferCheck) |
298 return resultBuffer |
320 return resultBuffer |
299 catch |
321 catch |
300 echoerr v:exception |
322 echoerr v:exception |
301 return -1 |
323 return -1 |
302 finally |
324 finally |
312 " the corresponding results. |
334 " the corresponding results. |
313 " |
335 " |
314 " Returns: string to be exec'd that sets the multiple return values. |
336 " Returns: string to be exec'd that sets the multiple return values. |
315 |
337 |
316 function! s:HGGetStatusVars(revisionVar, branchVar, repositoryVar) |
338 function! s:HGGetStatusVars(revisionVar, branchVar, repositoryVar) |
317 let hgBufferCheck=s:HGCurrentBufferCheck() |
339 let hgBufferCheck=<SID>HGCurrentBufferCheck() |
318 "echomsg "DBG : in HGGetStatusVars" |
340 "echomsg "DBG : in HGGetStatusVars" |
319 if hgBufferCheck == -1 |
341 if hgBufferCheck == -1 |
320 return "" |
342 return "" |
321 endif |
343 endif |
322 let fileName=bufname(hgBufferCheck) |
344 let fileName=bufname(hgBufferCheck) |
323 let fileNameWithoutLink=s:HGResolveLink(fileName) |
345 let fileNameWithoutLink=<SID>HGResolveLink(fileName) |
324 let realFileName = fnamemodify(fileNameWithoutLink, ':t') |
346 let realFileName = fnamemodify(fileNameWithoutLink, ':t') |
325 let oldCwd=s:HGChangeToCurrentFileDir(realFileName) |
347 let oldCwd=<SID>HGChangeToCurrentFileDir(realFileName) |
326 try |
348 try |
327 let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " root " |
349 let hgCommand = <SID>HGGetOption("HGCommandHGExec", "hg") . " root " |
328 let roottext=system(hgCommand) |
350 let roottext=system(hgCommand) |
329 " Suppress ending null char ! Does it work in window ? |
351 " Suppress ending null char ! Does it work in window ? |
330 let roottext=substitute(roottext,'^.*/\([^/\n\r]*\)\n\_.*$','\1','') |
352 let roottext=substitute(roottext,'^.*/\([^/\n\r]*\)\n\_.*$','\1','') |
331 if match(getcwd()."/".fileNameWithoutLink, roottext) == -1 |
353 if match(getcwd()."/".fileNameWithoutLink, roottext) == -1 |
332 return "" |
354 return "" |
333 endif |
355 endif |
334 let returnExpression = "" |
356 let returnExpression = "" |
335 if a:repositoryVar != "" |
357 if a:repositoryVar != "" |
336 let returnExpression=returnExpression . " | let " . a:repositoryVar . "='" . roottext . "'" |
358 let returnExpression=returnExpression . " | let " . a:repositoryVar . "='" . roottext . "'" |
337 endif |
359 endif |
338 let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " status -mardui " . realFileName |
360 let hgCommand = <SID>HGGetOption("HGCommandHGExec", "hg") . " status -mardui " . realFileName |
339 let statustext=system(hgCommand) |
361 let statustext=system(hgCommand) |
340 if(v:shell_error) |
362 if(v:shell_error) |
341 return "" |
363 return "" |
342 endif |
364 endif |
343 if match(statustext, '^[?I]') >= 0 |
365 if match(statustext, '^[?I]') >= 0 |
344 let revision="NEW" |
366 let revision="NEW" |
345 elseif match(statustext, '^[R]') >= 0 |
367 elseif match(statustext, '^[R]') >= 0 |
346 let revision="REMOVED" |
368 let revision="REMOVED" |
347 elseif match(statustext, '^[D]') >= 0 |
369 elseif match(statustext, '^[D]') >= 0 |
348 let revision="DELETED" |
370 let revision="DELETED" |
349 elseif match(statustext, '^[A]') >= 0 |
371 elseif match(statustext, '^[A]') >= 0 |
350 let revision="ADDED" |
372 let revision="ADDED" |
351 else |
373 else |
352 " The file is tracked, we can try to get is revision number |
374 " The file is tracked, we can try to get is revision number |
353 let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " parents -b " |
375 let hgCommand = <SID>HGGetOption("HGCommandHGExec", "hg") . " parents -b " |
354 let statustext=system(hgCommand) |
376 let statustext=system(hgCommand) |
355 if(v:shell_error) |
377 if(v:shell_error) |
356 return "" |
378 return "" |
357 endif |
379 endif |
358 let revision=substitute(statustext, '^changeset:\s*\(\d\+\):.*\_$\_.*$', '\1', "") |
380 let revision=substitute(statustext, '^changeset:\s*\(\d\+\):.*\_$\_.*$', '\1', "") |
481 " Helper function to make mkdir as portable as possible |
503 " Helper function to make mkdir as portable as possible |
482 function! s:HGFlexiMkdir(dir) |
504 function! s:HGFlexiMkdir(dir) |
483 if exists("*mkdir") " we can use Vim's own mkdir() |
505 if exists("*mkdir") " we can use Vim's own mkdir() |
484 call mkdir(a:dir) |
506 call mkdir(a:dir) |
485 elseif !exists("+shellslash") |
507 elseif !exists("+shellslash") |
486 call system('mkdir -p "'.a:dir.'"') |
508 call system("mkdir -p '".a:dir."'") |
487 else " M$ |
509 else " M$ |
488 let l:ssl = &shellslash |
510 let l:ssl = &shellslash |
489 try |
511 try |
490 set shellslash |
512 set shellslash |
|
513 " no single quotes? |
491 call system('mkdir "'.a:dir.'"') |
514 call system('mkdir "'.a:dir.'"') |
492 finally |
515 finally |
493 let &shellslash = l:ssl |
516 let &shellslash = l:ssl |
494 endtry |
517 endtry |
495 endif |
518 endif |
496 endfunction |
519 endfunction |
497 |
520 |
498 function! s:HGInstallDocumentation(full_name, revision) |
521 function! s:HGInstallDocumentation(full_name) |
499 " Figure out document path based on full name of this script: |
522 " Figure out document path based on full name of this script: |
500 let l:vim_plugin_path = fnamemodify(a:full_name, ':h') |
523 let l:vim_doc_path = fnamemodify(a:full_name, ":h:h") . "/doc" |
501 let l:vim_doc_path = fnamemodify(a:full_name, ':h:h') . "/doc" |
|
502 if filewritable(l:vim_doc_path) != 2 |
524 if filewritable(l:vim_doc_path) != 2 |
503 echomsg "hgcommand: Trying to update docs at: " . l:vim_doc_path |
525 echomsg s:script_name . ": Trying to update docs at" l:vim_doc_path |
504 silent! call <SID>HGFlexiMkdir(l:vim_doc_path) |
526 silent! call <SID>HGFlexiMkdir(l:vim_doc_path) |
505 if filewritable(l:vim_doc_path) != 2 |
527 if filewritable(l:vim_doc_path) != 2 |
506 " Try first item in 'runtimepath': |
528 " Try first item in 'runtimepath': |
507 let l:vimfiles = matchstr(&runtimepath, '[^,]\+\ze,') |
529 let l:vim_doc_path = |
508 let l:vim_doc_path = l:vimfiles . "/doc" |
530 \ substitute(&runtimepath, '^\([^,]*\).*', '\1/doc', 'e') |
509 if filewritable(l:vim_doc_path) != 2 |
531 if filewritable(l:vim_doc_path) != 2 |
510 echomsg "hgcommand: Trying to update docs at: " . l:vim_doc_path |
532 echomsg s:script_name . ": Trying to update docs at" l:vim_doc_path |
511 silent! call <SID>HGFlexiMkdir(l:vim_doc_path) |
533 silent! call <SID>HGFlexiMkdir(l:vim_doc_path) |
512 if filewritable(l:vim_doc_path) != 2 |
534 if filewritable(l:vim_doc_path) != 2 |
513 " Put a warning: |
535 " Put a warning: |
514 echomsg "Unable to open documentation directory" |
536 echomsg "Unable to open documentation directory" |
515 echomsg " type `:help add-local-help' for more information." |
537 echomsg " type `:help add-local-help' for more information." |
517 endif |
539 endif |
518 endif |
540 endif |
519 endif |
541 endif |
520 endif |
542 endif |
521 |
543 |
522 " Full name of script and documentation file: |
544 " Full name of documentation file: |
523 let l:script_name = fnamemodify(a:full_name, ':t') |
545 let l:doc_file = |
524 let l:doc_name = fnamemodify(a:full_name, ':t:r') . '.txt' |
546 \ l:vim_doc_path . "/" . s:script_name . ".txt" |
525 let l:doc_file = l:vim_doc_path . "/" . l:doc_name |
|
526 |
|
527 " Bail out if document file is still up to date: |
547 " Bail out if document file is still up to date: |
528 if filereadable(l:doc_file) && getftime(a:full_name) < getftime(l:doc_file) |
548 if filereadable(l:doc_file) && |
|
549 \ getftime(a:full_name) < getftime(l:doc_file) |
529 return 0 |
550 return 0 |
530 endif |
551 endif |
531 |
552 |
|
553 " temporary global settings |
|
554 let l:lz = &lazyredraw |
|
555 let l:hls = &hlsearch |
|
556 set lazyredraw nohlsearch |
532 " Create a new buffer & read in the plugin file (me): |
557 " Create a new buffer & read in the plugin file (me): |
533 setl nomodeline |
558 1 new |
534 1 new! |
559 setlocal noswapfile modifiable nomodeline |
535 setl noswapfile modifiable |
560 if has("folding") |
536 sil exe 'read ' . a:full_name |
561 setlocal nofoldenable |
537 |
562 endif |
538 setl modeline |
563 silent execute "read" escape(a:full_name, " ") |
539 let l:buf = bufnr("%") |
564 let l:doc_buf = bufnr("%") |
540 |
565 |
541 norm zR |
566 1 |
542 norm gg |
|
543 |
|
544 " Delete from first line to a line starts with |
567 " Delete from first line to a line starts with |
545 " === START_DOC |
568 " === START_DOC |
546 sil 1,/^=\{3,}\s\+START_DOC\C/ d |
569 silent 1,/^=\{3,}\s\+START_DOC\C/ d |
547 |
|
548 " Delete from a line starts with |
570 " Delete from a line starts with |
549 " === END_DOC |
571 " === END_DOC |
550 " to the end of the documents: |
572 " to the end of the documents: |
551 sil /^=\{3,}\s\+END_DOC\C/,$ d |
573 silent /^=\{3,}\s\+END_DOC\C/,$ d |
552 |
|
553 " Remove fold marks: |
|
554 sil %s/{\{3}[1-9]/ /e |
|
555 |
574 |
556 " Add modeline for help doc: the modeline string is mangled intentionally |
575 " Add modeline for help doc: the modeline string is mangled intentionally |
557 " to avoid it be recognized by VIM: |
576 " to avoid it be recognized by VIM: |
558 call append(line('$'), '') |
577 call append(line("$"), "") |
559 call append(line('$'), ' v' . 'im:tw=78:ts=8:ft=help:norl:') |
578 call append(line("$"), " v" . "im:tw=78:ts=8:ft=help:norl:") |
560 |
579 |
561 " Replace revision: |
580 " Replace revision: |
562 sil exe "normal :1s/#version#/ v" . a:revision . "/\<CR>" |
581 silent execute "normal :1s/#version#/" . s:script_version . "/\<CR>" |
563 |
|
564 " Save the help document and wipe out buffer: |
582 " Save the help document and wipe out buffer: |
565 sil exe 'wq! ' . l:doc_file . ' | bw ' . l:buf |
583 silent execute "wq!" escape(l:doc_file, " ") "| bw" l:doc_buf |
566 |
|
567 " Build help tags: |
584 " Build help tags: |
568 sil exe 'helptags ' . l:vim_doc_path |
585 silent execute "helptags" l:vim_doc_path |
569 |
586 |
|
587 let &hlsearch = l:hls |
|
588 let &lazyredraw = l:lz |
570 return 1 |
589 return 1 |
571 endfunction |
590 endfunction |
572 |
591 |
573 " Section: Public functions {{{1 |
592 " Section: Public functions {{{1 |
574 |
593 |
879 else |
898 else |
880 let versiontag=a:1 |
899 let versiontag=a:1 |
881 let versionOption=" -r " . versiontag . " " |
900 let versionOption=" -r " . versiontag . " " |
882 endif |
901 endif |
883 |
902 |
884 let resultBuffer = s:HGDoCommand('cat' . versionOption, 'hgreview', versiontag) |
903 let resultBuffer = <SID>HGDoCommand('cat' . versionOption, 'hgreview', versiontag) |
885 if resultBuffer > 0 |
904 if resultBuffer > 0 |
886 let &filetype=getbufvar(b:HGOrigBuffNR, '&filetype') |
905 let &filetype=getbufvar(b:HGOrigBuffNR, '&filetype') |
887 endif |
906 endif |
888 |
907 |
889 return resultBuffer |
908 return resultBuffer |
890 endfunction |
909 endfunction |
891 |
910 |
892 " Function: s:HGStatus() {{{2 |
911 " Function: s:HGStatus() {{{2 |
893 function! s:HGStatus() |
912 function! s:HGStatus() |
894 return s:HGDoCommand('status', 'hgstatus', '') |
913 return <SID>HGDoCommand('status', 'hgstatus', '') |
895 endfunction |
914 endfunction |
896 |
915 |
897 |
916 |
898 " Function: s:HGUpdate() {{{2 |
917 " Function: s:HGUpdate() {{{2 |
899 function! s:HGUpdate() |
918 function! s:HGUpdate() |
900 return s:HGMarkOrigBufferForSetup(s:HGDoCommand('update', 'update', '')) |
919 return <SID>HGMarkOrigBufferForSetup(<SID>HGDoCommand('update', 'update', '')) |
901 endfunction |
920 endfunction |
902 |
921 |
903 " Function: s:HGVimDiff(...) {{{2 |
922 " Function: s:HGVimDiff(...) {{{2 |
904 function! s:HGVimDiff(...) |
923 function! s:HGVimDiff(...) |
905 let originalBuffer = s:HGCurrentBufferCheck() |
924 let originalBuffer = <SID>HGCurrentBufferCheck() |
906 let s:HGCommandEditFileRunning = s:HGCommandEditFileRunning + 1 |
925 let s:HGCommandEditFileRunning = s:HGCommandEditFileRunning + 1 |
907 try |
926 try |
908 " If there's already a VimDiff'ed window, restore it. |
927 " If there's already a VimDiff'ed window, restore it. |
909 " There may only be one HGVimDiff original window at a time. |
928 " There may only be one HGVimDiff original window at a time. |
910 |
929 |
911 if exists("s:vimDiffSourceBuffer") && s:vimDiffSourceBuffer != originalBuffer |
930 if exists("s:vimDiffSourceBuffer") && s:vimDiffSourceBuffer != originalBuffer |
912 " Clear the existing vimdiff setup by removing the result buffers. |
931 " Clear the existing vimdiff setup by removing the result buffers. |
913 call s:HGWipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff') |
932 call <SID>HGWipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff') |
914 endif |
933 endif |
915 |
934 |
916 " Split and diff |
935 " Split and diff |
917 if(a:0 == 2) |
936 if(a:0 == 2) |
918 " Reset the vimdiff system, as 2 explicit versions were provided. |
937 " Reset the vimdiff system, as 2 explicit versions were provided. |
919 if exists('s:vimDiffSourceBuffer') |
938 if exists('s:vimDiffSourceBuffer') |
920 call s:HGWipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff') |
939 call <SID>HGWipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff') |
921 endif |
940 endif |
922 let resultBuffer = s:HGReview(a:1) |
941 let resultBuffer = <SID>HGReview(a:1) |
923 if resultBuffer < 0 |
942 if resultBuffer < 0 |
924 echomsg "Can't open HG revision " . a:1 |
943 echomsg "Can't open HG revision " . a:1 |
925 return resultBuffer |
944 return resultBuffer |
926 endif |
945 endif |
927 let b:HGCommand = 'vimdiff' |
946 let b:HGCommand = 'vimdiff' |
928 diffthis |
947 diffthis |
929 let s:vimDiffBufferCount = 1 |
948 let s:vimDiffBufferCount = 1 |
930 let s:vimDiffScratchList = '{'. resultBuffer . '}' |
949 let s:vimDiffScratchList = '{'. resultBuffer . '}' |
931 " If no split method is defined, cheat, and set it to vertical. |
950 " If no split method is defined, cheat, and set it to vertical. |
932 try |
951 try |
933 call s:HGOverrideOption('HGCommandSplit', s:HGGetOption('HGCommandDiffSplit', s:HGGetOption('HGCommandSplit', 'vertical'))) |
952 call <SID>HGOverrideOption('HGCommandSplit', <SID>HGGetOption('HGCommandDiffSplit', <SID>HGGetOption('HGCommandSplit', 'vertical'))) |
934 let resultBuffer=s:HGReview(a:2) |
953 let resultBuffer=<SID>HGReview(a:2) |
935 finally |
954 finally |
936 call s:HGOverrideOption('HGCommandSplit') |
955 call <SID>HGOverrideOption('HGCommandSplit') |
937 endtry |
956 endtry |
938 if resultBuffer < 0 |
957 if resultBuffer < 0 |
939 echomsg "Can't open HG revision " . a:1 |
958 echomsg "Can't open HG revision " . a:1 |
940 return resultBuffer |
959 return resultBuffer |
941 endif |
960 endif |
973 " This could have been invoked on a HG result buffer, not the |
992 " This could have been invoked on a HG result buffer, not the |
974 " original buffer. |
993 " original buffer. |
975 wincmd W |
994 wincmd W |
976 execute 'buffer' originalBuffer |
995 execute 'buffer' originalBuffer |
977 " Store info for later original buffer restore |
996 " Store info for later original buffer restore |
978 let s:vimDiffRestoreCmd = |
997 let s:vimDiffRestoreCmd = |
979 \ "call setbufvar(".originalBuffer.", \"&diff\", ".getbufvar(originalBuffer, '&diff').")" |
998 \ "call setbufvar(".originalBuffer.", \"&diff\", ".getbufvar(originalBuffer, '&diff').")" |
980 \ . "|call setbufvar(".originalBuffer.", \"&foldcolumn\", ".getbufvar(originalBuffer, '&foldcolumn').")" |
999 \ . "|call setbufvar(".originalBuffer.", \"&foldcolumn\", ".getbufvar(originalBuffer, '&foldcolumn').")" |
981 \ . "|call setbufvar(".originalBuffer.", \"&foldenable\", ".getbufvar(originalBuffer, '&foldenable').")" |
1000 \ . "|call setbufvar(".originalBuffer.", \"&foldenable\", ".getbufvar(originalBuffer, '&foldenable').")" |
982 \ . "|call setbufvar(".originalBuffer.", \"&foldmethod\", '".getbufvar(originalBuffer, '&foldmethod')."')" |
1001 \ . "|call setbufvar(".originalBuffer.", \"&foldmethod\", '".getbufvar(originalBuffer, '&foldmethod')."')" |
983 \ . "|call setbufvar(".originalBuffer.", \"&scrollbind\", ".getbufvar(originalBuffer, '&scrollbind').")" |
1002 \ . "|call setbufvar(".originalBuffer.", \"&scrollbind\", ".getbufvar(originalBuffer, '&scrollbind').")" |
984 \ . "|call setbufvar(".originalBuffer.", \"&wrap\", ".getbufvar(originalBuffer, '&wrap').")" |
1003 \ . "|call setbufvar(".originalBuffer.", \"&wrap\", ".getbufvar(originalBuffer, '&wrap').")" |
985 \ . "|if &foldmethod=='manual'|execute 'normal zE'|endif" |
1004 \ . "|if &foldmethod=='manual'|execute 'normal! zE'|endif" |
986 diffthis |
1005 diffthis |
987 wincmd w |
1006 wincmd w |
988 else |
1007 else |
989 " Adding a window to an existing vimdiff |
1008 " Adding a window to an existing vimdiff |
990 let s:vimDiffBufferCount = s:vimDiffBufferCount + 1 |
1009 let s:vimDiffBufferCount = s:vimDiffBufferCount + 1 |
1156 endtry |
1175 endtry |
1157 endfunction |
1176 endfunction |
1158 |
1177 |
1159 augroup HGVimDiffRestore |
1178 augroup HGVimDiffRestore |
1160 au! |
1179 au! |
1161 au BufUnload * call s:HGVimDiffRestore(expand("<abuf>")) |
1180 au BufUnload * call <SID>HGVimDiffRestore(expand("<abuf>")) |
1162 augroup END |
1181 augroup END |
1163 |
1182 |
1164 " Section: Optional activation of buffer management {{{1 |
1183 " Section: Optional activation of buffer management {{{1 |
1165 |
1184 |
1166 if s:HGGetOption('HGCommandEnableBufferSetup', 1) |
1185 if s:HGGetOption('HGCommandEnableBufferSetup', 1) |
1167 call HGEnableBufferSetup() |
1186 call HGEnableBufferSetup() |
1168 endif |
1187 endif |
1169 |
1188 |
1170 " Section: Doc installation {{{1 |
1189 " Section: Doc installation {{{1 |
1171 " |
1190 |
1172 let s:revision="0.1" |
1191 if <SID>HGInstallDocumentation(expand("<sfile>:p")) |
1173 if s:HGInstallDocumentation(escape(expand('<sfile>:p'), ' '), s:revision) |
1192 echomsg s:script_name s:script_version . ": updated documentation" |
1174 echom expand('<sfile>:t:r') . ' v' . s:revision . |
1193 endif |
1175 \ ': Help-documentation installed.' |
|
1176 endif |
|
1177 |
|
1178 " delete one-time vars and functions |
|
1179 delfunction <SID>HGInstallDocumentation |
|
1180 delfunction <SID>HGFlexiMkdir |
|
1181 unlet s:revision |
|
1182 |
|
1183 |
1194 |
1184 " Section: Plugin completion {{{1 |
1195 " Section: Plugin completion {{{1 |
|
1196 |
|
1197 " delete one-time vars and functions |
|
1198 delfunction <SID>HGInstallDocumentation |
|
1199 delfunction <SID>HGFlexiMkdir |
|
1200 delfunction <SID>HGCleanupOnFailure |
|
1201 unlet s:script_version s:script_name |
1185 |
1202 |
1186 let loaded_hgcommand=2 |
1203 let loaded_hgcommand=2 |
1187 silent do HGCommand User HGPluginFinish |
1204 silent do HGCommand User HGPluginFinish |
|
1205 |
|
1206 let &cpo = s:save_cpo |
|
1207 unlet s:save_cpo |
1188 " vim:se expandtab sts=2 sw=2: |
1208 " vim:se expandtab sts=2 sw=2: |
1189 finish |
1209 finish |
1190 |
1210 |
1191 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
1211 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
1192 " Section: Documentation content {{{1 |
1212 " Section: Documentation content {{{1 |
1214 Bugs : |hgcommand-bugs| |
1234 Bugs : |hgcommand-bugs| |
1215 |
1235 |
1216 ============================================================================== |
1236 ============================================================================== |
1217 2. HGCommand Installation *hgcommand-install* |
1237 2. HGCommand Installation *hgcommand-install* |
1218 |
1238 |
1219 In order to install the plugin, place the hgcommand.vim file into a plugin' |
1239 In order to install the plugin, place the hgcommand.vim file into a plugin' |
1220 directory in your runtime path (please see |add-global-plugin| and |
1240 directory in your runtime path (please see |add-global-plugin| and |
1221 |'runtimepath'|. |
1241 |'runtimepath'|. |
1222 |
1242 |
1223 HGCommand may be customized by setting variables, creating maps, and |
1243 HGCommand may be customized by setting variables, creating maps, and |
1224 specifying event handlers. Please see |hgcommand-customize| for more |
1244 specifying event handlers. Please see |hgcommand-customize| for more |
1225 details. |
1245 details. |
1226 |
1246 |
1227 *hgcommand-auto-help* |
1247 *hgcommand-auto-help* |
1228 The help file is automagically generated when the |hgcommand| script is |
1248 The help file is automagically generated when the |hgcommand| script is |
1229 loaded for the first time. |
1249 loaded for the first time. |
1230 |
1250 |
1231 ============================================================================== |
1251 ============================================================================== |
1232 |
1252 |
1233 3. HGCommand Intro *hgcommand* |
1253 3. HGCommand Intro *hgcommand* |
1234 *hgcommand-intro* |
1254 *hgcommand-intro* |
1235 |
1255 |
1236 The HGCommand plugin provides global ex commands for manipulating |
1256 The HGCommand plugin provides global ex commands for manipulating |
1237 HG-controlled source files. In general, each command operates on the |
1257 HG-controlled source files. In general, each command operates on the |
1238 current buffer and accomplishes a separate hg function, such as update, |
1258 current buffer and accomplishes a separate hg function, such as update, |
1239 commit, log, and others (please see |hgcommand-commands| for a list of all |
1259 commit, log, and others (please see |hgcommand-commands| for a list of all |
1240 available commands). The results of each operation are displayed in a |
1260 available commands). The results of each operation are displayed in a |
1241 scratch buffer. Several buffer variables are defined for those scratch |
1261 scratch buffer. Several buffer variables are defined for those scratch |
1242 buffers (please see |hgcommand-buffer-variables|). |
1262 buffers (please see |hgcommand-buffer-variables|). |
1243 |
1263 |
1244 The notion of "current file" means either the current buffer, or, in the |
1264 The notion of "current file" means either the current buffer, or, in the |
1245 case of a directory buffer, the file on the current line within the buffer. |
1265 case of a directory buffer, the file on the current line within the buffer. |
1246 |
1266 |
1247 For convenience, any HGCommand invoked on a HGCommand scratch buffer acts |
1267 For convenience, any HGCommand invoked on a HGCommand scratch buffer acts |
1248 as though it was invoked on the original file and splits the screen so that |
1268 as though it was invoked on the original file and splits the screen so that |
1249 the output appears in a new window. |
1269 the output appears in a new window. |
1250 |
1270 |
1251 Many of the commands accept revisions as arguments. By default, most |
1271 Many of the commands accept revisions as arguments. By default, most |
1252 operate on the most recent revision on the current branch if no revision is |
1272 operate on the most recent revision on the current branch if no revision is |
1253 specified (though see |HGCommandInteractive| to prompt instead). |
1273 specified (though see |HGCommandInteractive| to prompt instead). |
1254 |
1274 |
1255 Each HGCommand is mapped to a key sequence starting with the <Leader> |
1275 Each HGCommand is mapped to a key sequence starting with the <Leader> |
1256 keystroke. The default mappings may be overridden by supplying different |
1276 keystroke. The default mappings may be overridden by supplying different |
1257 mappings before the plugin is loaded, such as in the vimrc, in the standard |
1277 mappings before the plugin is loaded, such as in the vimrc, in the standard |
1258 fashion for plugin mappings. For examples, please see |
1278 fashion for plugin mappings. For examples, please see |
1259 |hgcommand-mappings-override|. |
1279 |hgcommand-mappings-override|. |
1260 |
1280 |
1261 The HGCommand plugin may be configured in several ways. For more details, |
1281 The HGCommand plugin may be configured in several ways. For more details, |
1262 please see |hgcommand-customize|. |
1282 please see |hgcommand-customize|. |
1263 |
1283 |
1264 ============================================================================== |
1284 ============================================================================== |
1265 4. HGCommand Manual *hgcommand-manual* |
1285 4. HGCommand Manual *hgcommand-manual* |
1266 |
1286 |
1280 |:HGUpdate| |
1300 |:HGUpdate| |
1281 |:HGVimDiff| |
1301 |:HGVimDiff| |
1282 |
1302 |
1283 :HGAdd *:HGAdd* |
1303 :HGAdd *:HGAdd* |
1284 |
1304 |
1285 This command performs "hg add" on the current file. Please note, this does |
1305 This command performs "hg add" on the current file. Please note, this does |
1286 not commit the newly-added file. |
1306 not commit the newly-added file. |
1287 |
1307 |
1288 :HGAnnotate *:HGAnnotate* |
1308 :HGAnnotate *:HGAnnotate* |
1289 |
1309 |
1290 This command performs "hg annotate" on the current file. If an argument is |
1310 This command performs "hg annotate" on the current file. If an argument is |
1291 given, the argument is used as a revision number to display. If not given |
1311 given, the argument is used as a revision number to display. If not given |
1292 an argument, it uses the most recent version of the file on the current |
1312 an argument, it uses the most recent version of the file on the current |
1293 branch. Additionally, if the current buffer is a HGAnnotate buffer |
1313 branch. Additionally, if the current buffer is a HGAnnotate buffer |
1294 already, the version number on the current line is used. |
1314 already, the version number on the current line is used. |
1295 |
1315 |
1296 If the |HGCommandAnnotateParent| variable is set to a non-zero value, the |
1316 If the |HGCommandAnnotateParent| variable is set to a non-zero value, the |
1297 version previous to the one on the current line is used instead. This |
1317 version previous to the one on the current line is used instead. This |
1298 allows one to navigate back to examine the previous version of a line. |
1318 allows one to navigate back to examine the previous version of a line. |
1299 |
1319 |
1300 The filetype of the HGCommand scratch buffer is set to 'HGAnnotate', to |
1320 The filetype of the HGCommand scratch buffer is set to 'HGAnnotate', to |
1301 take advantage of the bundled syntax file. |
1321 take advantage of the bundled syntax file. |
1302 |
1322 |
1303 |
1323 |
1304 :HGCommit[!] *:HGCommit* |
1324 :HGCommit[!] *:HGCommit* |
1305 |
1325 |
1306 If called with arguments, this performs "hg commit" using the arguments as |
1326 If called with arguments, this performs "hg commit" using the arguments as |
1307 the log message. |
1327 the log message. |
1308 |
1328 |
1309 If '!' is used with no arguments, an empty log message is committed. |
1329 If '!' is used with no arguments, an empty log message is committed. |
1310 |
1330 |
1311 If called with no arguments, this is a two-step command. The first step |
1331 If called with no arguments, this is a two-step command. The first step |
1312 opens a buffer to accept a log message. When that buffer is written, it is |
1332 opens a buffer to accept a log message. When that buffer is written, it is |
1313 automatically closed and the file is committed using the information from |
1333 automatically closed and the file is committed using the information from |
1314 that log message. The commit can be abandoned if the log message buffer is |
1334 that log message. The commit can be abandoned if the log message buffer is |
1315 deleted or wiped before being written. |
1335 deleted or wiped before being written. |
1316 |
1336 |
1317 Alternatively, the mapping that is used to invoke :HGCommit (by default |
1337 Alternatively, the mapping that is used to invoke :HGCommit (by default |
1318 <Leader>hgc) can be used in the log message buffer to immediately commit. |
1338 <Leader>hgc) can be used in the log message buffer to immediately commit. |
1319 This is useful if the |HGCommandCommitOnWrite| variable is set to 0 to |
1339 This is useful if the |HGCommandCommitOnWrite| variable is set to 0 to |
1320 disable the normal commit-on-write behavior. |
1340 disable the normal commit-on-write behavior. |
1321 |
1341 |
1322 :HGDiff *:HGDiff* |
1342 :HGDiff *:HGDiff* |
1323 |
1343 |
1324 With no arguments, this performs "hg diff" on the current file against the |
1344 With no arguments, this performs "hg diff" on the current file against the |
1325 current repository version. |
1345 current repository version. |
1326 |
1346 |
1327 With one argument, "hg diff" is performed on the current file against the |
1347 With one argument, "hg diff" is performed on the current file against the |
1328 specified revision. |
1348 specified revision. |
1329 |
1349 |
1330 With two arguments, hg diff is performed between the specified revisions of |
1350 With two arguments, hg diff is performed between the specified revisions of |
1331 the current file. |
1351 the current file. |
1332 |
1352 |
1333 This command uses the 'HGCommandDiffOpt' variable to specify diff options. |
1353 This command uses the 'HGCommandDiffOpt' variable to specify diff options. |
1334 If that variable does not exist, then 'wbBc' is assumed. If you wish to |
1354 If that variable does not exist, then 'wbBc' is assumed. If you wish to |
1335 have no options, then set it to the empty string. |
1355 have no options, then set it to the empty string. |
1336 |
1356 |
1337 |
1357 |
1338 :HGGotoOriginal *:HGGotoOriginal* |
1358 :HGGotoOriginal *:HGGotoOriginal* |
1339 |
1359 |
1340 This command returns the current window to the source buffer, if the |
1360 This command returns the current window to the source buffer, if the |
1341 current buffer is a HG command output buffer. |
1361 current buffer is a HG command output buffer. |
1342 |
1362 |
1343 :HGGotoOriginal! |
1363 :HGGotoOriginal! |
1344 |
1364 |
1345 Like ":HGGotoOriginal" but also executes :bufwipeout on all HG command |
1365 Like ":HGGotoOriginal" but also executes :bufwipeout on all HG command |
1346 output buffers for the source buffer. |
1366 output buffers for the source buffer. |
1347 |
1367 |
1348 :HGLog *:HGLog* |
1368 :HGLog *:HGLog* |
1349 |
1369 |
1350 Performs "hg log" on the current file. |
1370 Performs "hg log" on the current file. |
1351 |
1371 |
1352 If an argument is given, it is passed as an argument to the "-r" option of |
1372 If an argument is given, it is passed as an argument to the "-r" option of |
1353 "hg log". |
1373 "hg log". |
1354 |
1374 |
1355 :HGRevert *:HGRevert* |
1375 :HGRevert *:HGRevert* |
1356 |
1376 |
1357 Replaces the current file with the most recent version from the repository |
1377 Replaces the current file with the most recent version from the repository |
1358 in order to wipe out any undesired changes. |
1378 in order to wipe out any undesired changes. |
1359 |
1379 |
1360 :HGReview *:HGReview* |
1380 :HGReview *:HGReview* |
1361 |
1381 |
1362 Retrieves a particular version of the current file. If no argument is |
1382 Retrieves a particular version of the current file. If no argument is |
1363 given, the most recent version of the file on the current branch is |
1383 given, the most recent version of the file on the current branch is |
1364 retrieved. Otherwise, the specified version is retrieved. |
1384 retrieved. Otherwise, the specified version is retrieved. |
1365 |
1385 |
1366 :HGStatus *:HGStatus* |
1386 :HGStatus *:HGStatus* |
1367 |
1387 |
1368 Performs "hg status" on the current file. |
1388 Performs "hg status" on the current file. |
1369 |
1389 |
1370 :HGUpdate *:HGUpdate* |
1390 :HGUpdate *:HGUpdate* |
1371 |
1391 |
1372 Performs "hg update" on the current file. This intentionally does not |
1392 Performs "hg update" on the current file. This intentionally does not |
1373 automatically reload the current buffer, though vim should prompt the user |
1393 automatically reload the current buffer, though vim should prompt the user |
1374 to do so if the underlying file is altered by this command. |
1394 to do so if the underlying file is altered by this command. |
1375 |
1395 |
1376 :HGVimDiff *:HGVimDiff* |
1396 :HGVimDiff *:HGVimDiff* |
1377 |
1397 |
1378 With no arguments, this prompts the user for a revision and then uses |
1398 With no arguments, this prompts the user for a revision and then uses |
1379 vimdiff to display the differences between the current file and the |
1399 vimdiff to display the differences between the current file and the |
1380 specified revision. If no revision is specified, the most recent version |
1400 specified revision. If no revision is specified, the most recent version |
1381 of the file on the current branch is used. |
1401 of the file on the current branch is used. |
1382 |
1402 |
1383 With one argument, that argument is used as the revision as above. With |
1403 With one argument, that argument is used as the revision as above. With |
1384 two arguments, the differences between the two revisions is displayed using |
1404 two arguments, the differences between the two revisions is displayed using |
1385 vimdiff. |
1405 vimdiff. |
1386 |
1406 |
1387 With either zero or one argument, the original buffer is used to perform |
1407 With either zero or one argument, the original buffer is used to perform |
1388 the vimdiff. When the other buffer is closed, the original buffer will be |
1408 the vimdiff. When the other buffer is closed, the original buffer will be |
1389 returned to normal mode. |
1409 returned to normal mode. |
1390 |
1410 |
1391 Once vimdiff mode is started using the above methods, additional vimdiff |
1411 Once vimdiff mode is started using the above methods, additional vimdiff |
1392 buffers may be added by passing a single version argument to the command. |
1412 buffers may be added by passing a single version argument to the command. |
1393 There may be up to 4 vimdiff buffers total. |
1413 There may be up to 4 vimdiff buffers total. |
1394 |
1414 |
1395 Using the 2-argument form of the command resets the vimdiff to only those 2 |
1415 Using the 2-argument form of the command resets the vimdiff to only those 2 |
1396 versions. Additionally, invoking the command on a different file will |
1416 versions. Additionally, invoking the command on a different file will |
1397 close the previous vimdiff buffers. |
1417 close the previous vimdiff buffers. |
1398 |
1418 |
1399 |
1419 |
1400 4.2 Mappings *hgcommand-mappings* |
1420 4.2 Mappings *hgcommand-mappings* |
1401 |
1421 |
1402 By default, a mapping is defined for each command. These mappings execute |
1422 By default, a mapping is defined for each command. These mappings execute |
1403 the default (no-argument) form of each command. |
1423 the default (no-argument) form of each command. |
1404 |
1424 |
1405 <Leader>hga HGAdd |
1425 <Leader>hga HGAdd |
1406 <Leader>hgn HGAnnotate |
1426 <Leader>hgn HGAnnotate |
1407 <Leader>hgc HGCommit |
1427 <Leader>hgc HGCommit |
1414 <Leader>hgu HGUpdate |
1434 <Leader>hgu HGUpdate |
1415 <Leader>hgv HGVimDiff |
1435 <Leader>hgv HGVimDiff |
1416 |
1436 |
1417 *hgcommand-mappings-override* |
1437 *hgcommand-mappings-override* |
1418 |
1438 |
1419 The default mappings can be overriden by user-provided instead by mapping |
1439 The default mappings can be overriden by user-provided instead by mapping |
1420 to <Plug>CommandName. This is especially useful when these mappings |
1440 to <Plug>CommandName. This is especially useful when these mappings |
1421 collide with other existing mappings (vim will warn of this during plugin |
1441 collide with other existing mappings (vim will warn of this during plugin |
1422 initialization, but will not clobber the existing mappings). |
1442 initialization, but will not clobber the existing mappings). |
1423 |
1443 |
1424 For instance, to override the default mapping for :HGAdd to set it to |
1444 For instance, to override the default mapping for :HGAdd to set it to |
1425 '\add', add the following to the vimrc: > |
1445 '\add', add the following to the vimrc: > |
1426 |
1446 |
1427 nmap \add <Plug>HGAdd |
1447 nmap \add <Plug>HGAdd |
1428 < |
1448 < |
1429 4.3 Automatic buffer variables *hgcommand-buffer-variables* |
1449 4.3 Automatic buffer variables *hgcommand-buffer-variables* |
1430 |
1450 |
1431 Several buffer variables are defined in each HGCommand result buffer. |
1451 Several buffer variables are defined in each HGCommand result buffer. |
1432 These may be useful for additional customization in callbacks defined in |
1452 These may be useful for additional customization in callbacks defined in |
1433 the event handlers (please see |hgcommand-events|). |
1453 the event handlers (please see |hgcommand-events|). |
1434 |
1454 |
1435 The following variables are automatically defined: |
1455 The following variables are automatically defined: |
1436 |
1456 |
1437 b:hgOrigBuffNR *b:hgOrigBuffNR* |
1457 b:hgOrigBuffNR *b:hgOrigBuffNR* |
1438 |
1458 |
1439 This variable is set to the buffer number of the source file. |
1459 This variable is set to the buffer number of the source file. |
1440 |
1460 |
1441 b:hgcmd *b:hgcmd* |
1461 b:hgcmd *b:hgcmd* |
1442 |
1462 |
1443 This variable is set to the name of the hg command that created the result |
1463 This variable is set to the name of the hg command that created the result |
1444 buffer. |
1464 buffer. |
1445 ============================================================================== |
1465 ============================================================================== |
1446 |
1466 |
1447 5. Configuration and customization *hgcommand-customize* |
1467 5. Configuration and customization *hgcommand-customize* |
1448 *hgcommand-config* |
1468 *hgcommand-config* |
1449 |
1469 |
1450 The HGCommand plugin can be configured in two ways: by setting |
1470 The HGCommand plugin can be configured in two ways: by setting |
1451 configuration variables (see |hgcommand-options|) or by defining HGCommand |
1471 configuration variables (see |hgcommand-options|) or by defining HGCommand |
1452 event handlers (see |hgcommand-events|). Additionally, the HGCommand |
1472 event handlers (see |hgcommand-events|). Additionally, the HGCommand |
1453 plugin provides several option for naming the HG result buffers (see |
1473 plugin provides several option for naming the HG result buffers (see |
1454 |hgcommand-naming|) and supported a customized status line (see |
1474 |hgcommand-naming|) and supported a customized status line (see |
1455 |hgcommand-statusline| and |hgcommand-buffer-management|). |
1475 |hgcommand-statusline| and |hgcommand-buffer-management|). |
1456 |
1476 |
1457 5.1 HGCommand configuration variables *hgcommand-options* |
1477 5.1 HGCommand configuration variables *hgcommand-options* |
1458 |
1478 |
1459 Several variables affect the plugin's behavior. These variables are |
1479 Several variables affect the plugin's behavior. These variables are |
1460 checked at time of execution, and may be defined at the window, buffer, or |
1480 checked at time of execution, and may be defined at the window, buffer, or |
1461 global level and are checked in that order of precedence. |
1481 global level and are checked in that order of precedence. |
1462 |
1482 |
1463 |
1483 |
1464 The following variables are available: |
1484 The following variables are available: |
1465 |
1485 |
1476 |HGCommandNameResultBuffers| |
1496 |HGCommandNameResultBuffers| |
1477 |HGCommandSplit| |
1497 |HGCommandSplit| |
1478 |
1498 |
1479 HGCommandAnnotateParent *HGCommandAnnotateParent* |
1499 HGCommandAnnotateParent *HGCommandAnnotateParent* |
1480 |
1500 |
1481 This variable, if set to a non-zero value, causes the zero-argument form of |
1501 This variable, if set to a non-zero value, causes the zero-argument form of |
1482 HGAnnotate when invoked on a HGAnnotate buffer to go to the version |
1502 HGAnnotate when invoked on a HGAnnotate buffer to go to the version |
1483 previous to that displayed on the current line. If not set, it defaults to |
1503 previous to that displayed on the current line. If not set, it defaults to |
1484 0. |
1504 0. |
1485 |
1505 |
1486 HGCommandCommitOnWrite *HGCommandCommitOnWrite* |
1506 HGCommandCommitOnWrite *HGCommandCommitOnWrite* |
1487 |
1507 |
1488 This variable, if set to a non-zero value, causes the pending hg commit to |
1508 This variable, if set to a non-zero value, causes the pending hg commit to |
1489 take place immediately as soon as the log message buffer is written. If |
1509 take place immediately as soon as the log message buffer is written. If |
1490 set to zero, only the HGCommit mapping will cause the pending commit to |
1510 set to zero, only the HGCommit mapping will cause the pending commit to |
1491 occur. If not set, it defaults to 1. |
1511 occur. If not set, it defaults to 1. |
1492 |
1512 |
1493 HGCommandHGExec *HGCommandHGExec* |
1513 HGCommandHGExec *HGCommandHGExec* |
1494 |
1514 |
1495 This variable controls the executable used for all HG commands. If not |
1515 This variable controls the executable used for all HG commands. If not |
1496 set, it defaults to "hg". |
1516 set, it defaults to "hg". |
1497 |
1517 |
1498 HGCommandDeleteOnHide *HGCommandDeleteOnHide* |
1518 HGCommandDeleteOnHide *HGCommandDeleteOnHide* |
1499 |
1519 |
1500 This variable, if set to a non-zero value, causes the temporary HG result |
1520 This variable, if set to a non-zero value, causes the temporary HG result |
1501 buffers to automatically delete themselves when hidden. |
1521 buffers to automatically delete themselves when hidden. |
1502 |
1522 |
1503 HGCommandDiffOpt *HGCommandDiffOpt* |
1523 HGCommandDiffOpt *HGCommandDiffOpt* |
1504 |
1524 |
1505 This variable, if set, determines the options passed to the diff command of |
1525 This variable, if set, determines the options passed to the diff command of |
1506 HG. If not set, it defaults to 'w'. |
1526 HG. If not set, it defaults to 'w'. |
1507 |
1527 |
1508 HGCommandDiffSplit *HGCommandDiffSplit* |
1528 HGCommandDiffSplit *HGCommandDiffSplit* |
1509 |
1529 |
1510 This variable overrides the |HGCommandSplit| variable, but only for buffers |
1530 This variable overrides the |HGCommandSplit| variable, but only for buffers |
1511 created with |:HGVimDiff|. |
1531 created with |:HGVimDiff|. |
1512 |
1532 |
1513 HGCommandEdit *HGCommandEdit* |
1533 HGCommandEdit *HGCommandEdit* |
1514 |
1534 |
1515 This variable controls whether the original buffer is replaced ('edit') or |
1535 This variable controls whether the original buffer is replaced ('edit') or |
1516 split ('split'). If not set, it defaults to 'edit'. |
1536 split ('split'). If not set, it defaults to 'edit'. |
1517 |
1537 |
1518 HGCommandEnableBufferSetup *HGCommandEnableBufferSetup* |
1538 HGCommandEnableBufferSetup *HGCommandEnableBufferSetup* |
1519 |
1539 |
1520 This variable, if set to a non-zero value, activates HG buffer management |
1540 This variable, if set to a non-zero value, activates HG buffer management |
1521 mode see (|hgcommand-buffer-management|). This mode means that three |
1541 mode see (|hgcommand-buffer-management|). This mode means that three |
1522 buffer variables, 'HGRepository', 'HGRevision' and 'HGBranch', are set if |
1542 buffer variables, 'HGRepository', 'HGRevision' and 'HGBranch', are set if |
1523 the file is HG-controlled. This is useful for displaying version |
1543 the file is HG-controlled. This is useful for displaying version |
1524 information in the status bar. |
1544 information in the status bar. |
1525 |
1545 |
1526 HGCommandInteractive *HGCommandInteractive* |
1546 HGCommandInteractive *HGCommandInteractive* |
1527 |
1547 |
1528 This variable, if set to a non-zero value, causes appropriate commands (for |
1548 This variable, if set to a non-zero value, causes appropriate commands (for |
1529 the moment, only |:HGReview|) to query the user for a revision to use |
1549 the moment, only |:HGReview|) to query the user for a revision to use |
1530 instead of the current revision if none is specified. |
1550 instead of the current revision if none is specified. |
1531 |
1551 |
1532 HGCommandNameMarker *HGCommandNameMarker* |
1552 HGCommandNameMarker *HGCommandNameMarker* |
1533 |
1553 |
1534 This variable, if set, configures the special attention-getting characters |
1554 This variable, if set, configures the special attention-getting characters |
1535 that appear on either side of the hg buffer type in the buffer name. This |
1555 that appear on either side of the hg buffer type in the buffer name. This |
1536 has no effect unless |HGCommandNameResultBuffers| is set to a true value. |
1556 has no effect unless |HGCommandNameResultBuffers| is set to a true value. |
1537 If not set, it defaults to '_'. |
1557 If not set, it defaults to '_'. |
1538 |
1558 |
1539 HGCommandNameResultBuffers *HGCommandNameResultBuffers* |
1559 HGCommandNameResultBuffers *HGCommandNameResultBuffers* |
1540 |
1560 |
1541 This variable, if set to a true value, causes the hg result buffers to be |
1561 This variable, if set to a true value, causes the hg result buffers to be |
1542 named in the old way ('<source file name> _<hg command>_'). If not set or |
1562 named in the old way ('<source file name> _<hg command>_'). If not set or |
1543 set to a false value, the result buffer is nameless. |
1563 set to a false value, the result buffer is nameless. |
1544 |
1564 |
1545 HGCommandSplit *HGCommandSplit* |
1565 HGCommandSplit *HGCommandSplit* |
1546 |
1566 |
1547 This variable controls the orientation of the various window splits that |
1567 This variable controls the orientation of the various window splits that |
1548 may occur (such as with HGVimDiff, when using a HG command on a HG command |
1568 may occur (such as with HGVimDiff, when using a HG command on a HG command |
1549 buffer, or when the |HGCommandEdit| variable is set to 'split'. If set to |
1569 buffer, or when the |HGCommandEdit| variable is set to 'split'. If set to |
1550 'horizontal', the resulting windows will be on stacked on top of one |
1570 'horizontal', the resulting windows will be on stacked on top of one |
1551 another. If set to 'vertical', the resulting windows will be side-by-side. |
1571 another. If set to 'vertical', the resulting windows will be side-by-side. |
1552 If not set, it defaults to 'horizontal' for all but HGVimDiff windows. |
1572 If not set, it defaults to 'horizontal' for all but HGVimDiff windows. |
1553 |
1573 |
1554 5.2 HGCommand events *hgcommand-events* |
1574 5.2 HGCommand events *hgcommand-events* |
1555 |
1575 |
1556 For additional customization, HGCommand can trigger user-defined events. |
1576 For additional customization, HGCommand can trigger user-defined events. |
1557 Event handlers are provided by defining User event autocommands (see |
1577 Event handlers are provided by defining User event autocommands (see |
1558 |autocommand|, |User|) in the HGCommand group with patterns matching the |
1578 |autocommand|, |User|) in the HGCommand group with patterns matching the |
1559 event name. |
1579 event name. |
1560 |
1580 |
1561 For instance, the following could be added to the vimrc to provide a 'q' |
1581 For instance, the following could be added to the vimrc to provide a 'q' |
1562 mapping to quit a HGCommand scratch buffer: > |
1582 mapping to quit a HGCommand scratch buffer: > |
1563 |
1583 |
1564 augroup HGCommand |
1584 augroup HGCommand |
1565 au HGCommand User HGBufferCreated silent! nmap <unique> <buffer> q: |
1585 au HGCommand User HGBufferCreated silent! nmap <unique> <buffer> q: |
1566 bwipeout<cr> |
1586 bwipeout<cr> |
1584 |
1604 |
1585 HGPluginFinish This event is fired just after the HGCommand plugin |
1605 HGPluginFinish This event is fired just after the HGCommand plugin |
1586 loads. |
1606 loads. |
1587 |
1607 |
1588 HGVimDiffFinish This event is fired just after the HGVimDiff command |
1608 HGVimDiffFinish This event is fired just after the HGVimDiff command |
1589 executes to allow customization of, for instance, |
1609 executes to allow customization of, for instance, |
1590 window placement and focus. |
1610 window placement and focus. |
1591 |
1611 |
1592 5.3 HGCommand buffer naming *hgcommand-naming* |
1612 5.3 HGCommand buffer naming *hgcommand-naming* |
1593 |
1613 |
1594 By default, the buffers containing the result of HG commands are nameless |
1614 By default, the buffers containing the result of HG commands are nameless |
1595 scratch buffers. It is intended that buffer variables of those buffers be |
1615 scratch buffers. It is intended that buffer variables of those buffers be |
1596 used to customize the statusline option so that the user may fully control |
1616 used to customize the statusline option so that the user may fully control |
1597 the display of result buffers. |
1617 the display of result buffers. |
1598 |
1618 |
1599 If the old-style naming is desired, please enable the |
1619 If the old-style naming is desired, please enable the |
1600 |HGCommandNameResultBuffers| variable. Then, each result buffer will |
1620 |HGCommandNameResultBuffers| variable. Then, each result buffer will |
1601 receive a unique name that includes the source file name, the HG command, |
1621 receive a unique name that includes the source file name, the HG command, |
1602 and any extra data (such as revision numbers) that were part of the |
1622 and any extra data (such as revision numbers) that were part of the |
1603 command. |
1623 command. |
1604 |
1624 |
1605 5.4 HGCommand status line support *hgcommand-statusline* |
1625 5.4 HGCommand status line support *hgcommand-statusline* |
1606 |
1626 |
1607 It is intended that the user will customize the |'statusline'| option to |
1627 It is intended that the user will customize the |'statusline'| option to |
1608 include HG result buffer attributes. A sample function that may be used in |
1628 include HG result buffer attributes. A sample function that may be used in |
1609 the |'statusline'| option is provided by the plugin, HGGetStatusLine(). In |
1629 the |'statusline'| option is provided by the plugin, HGGetStatusLine(). In |
1610 order to use that function in the status line, do something like the |
1630 order to use that function in the status line, do something like the |
1611 following: > |
1631 following: > |
1612 |
1632 |
1613 set statusline=%<%f\ %{HGGetStatusLine()}\ %h%m%r%=%l,%c%V\ %P |
1633 set statusline=%<%f\ %{HGGetStatusLine()}\ %h%m%r%=%l,%c%V\ %P |
1614 < |
1634 < |
1615 of which %{HGGetStatusLine()} is the relevant portion. |
1635 of which %{HGGetStatusLine()} is the relevant portion. |
1616 |
1636 |
1617 The sample HGGetStatusLine() function handles both HG result buffers and |
1637 The sample HGGetStatusLine() function handles both HG result buffers and |
1618 HG-managed files if HGCommand buffer management is enabled (please see |
1638 HG-managed files if HGCommand buffer management is enabled (please see |
1619 |hgcommand-buffer-management|). |
1639 |hgcommand-buffer-management|). |
1620 |
1640 |
1621 5.5 HGCommand buffer management *hgcommand-buffer-management* |
1641 5.5 HGCommand buffer management *hgcommand-buffer-management* |
1622 |
1642 |
1623 The HGCommand plugin can operate in buffer management mode, which means |
1643 The HGCommand plugin can operate in buffer management mode, which means |
1624 that it attempts to set two buffer variables ('HGRevision' and 'HGBranch') |
1644 that it attempts to set two buffer variables ('HGRevision' and 'HGBranch') |
1625 upon entry into a buffer. This is rather slow because it means that 'hg |
1645 upon entry into a buffer. This is rather slow because it means that 'hg |
1626 status' will be invoked at each entry into a buffer (during the |BufEnter| |
1646 status' will be invoked at each entry into a buffer (during the |BufEnter| |
1627 autocommand). |
1647 autocommand). |
1628 |
1648 |
1629 This mode is enabled by default. In order to disable it, set the |
1649 This mode is enabled by default. In order to disable it, set the |
1630 |HGCommandEnableBufferSetup| variable to a false (zero) value. Enabling |
1650 |HGCommandEnableBufferSetup| variable to a false (zero) value. Enabling |
1631 this mode simply provides the buffer variables mentioned above. The user |
1651 this mode simply provides the buffer variables mentioned above. The user |
1632 must explicitly include those in the |'statusline'| option if they are to |
1652 must explicitly include those in the |'statusline'| option if they are to |
1633 appear in the status line (but see |hgcommand-statusline| for a simple way |
1653 appear in the status line (but see |hgcommand-statusline| for a simple way |
1634 to do that). |
1654 to do that). |
1635 |
1655 |
1636 ============================================================================== |
1656 ============================================================================== |
1637 9. Tips *hgcommand-tips* |
1657 9. Tips *hgcommand-tips* |