Show More
@@ -0,0 +1,93 b'' | |||||
|
1 | " vim600: set foldmethod=marker: | |||
|
2 | " ============================================================================= | |||
|
3 | " Name Of File: hg-menu.vim | |||
|
4 | " Description: Interface to Mercurial Version Control. | |||
|
5 | " Author: Steve Borho (modified Jeff Lanzarotta's RCS script) | |||
|
6 | " Date: Wednesday, October 5, 2005 | |||
|
7 | " Version: 0.1.0 | |||
|
8 | " Copyright: None. | |||
|
9 | " Usage: These command and gui menu displays useful hg functions | |||
|
10 | " Configuration: Your hg executable must be in your path. | |||
|
11 | " ============================================================================= | |||
|
12 | ||||
|
13 | " Section: Init {{{1 | |||
|
14 | if exists("loaded_hg_menu") | |||
|
15 | finish | |||
|
16 | endif | |||
|
17 | let loaded_hg_menu = 1 | |||
|
18 | ||||
|
19 | " Section: Menu Options {{{1 | |||
|
20 | if has("gui") | |||
|
21 | " amenu H&G.Commit\ File<Tab>,ci :!hg commit %<CR>:e!<CR> | |||
|
22 | " amenu H&G.Commit\ All<Tab>,call :!hg commit<CR>:e!<CR> | |||
|
23 | " amenu H&G.-SEP1- <nul> | |||
|
24 | amenu H&G.Add<Tab>\\add :!hg add %<CR><CR> | |||
|
25 | amenu H&G.Forget\ Add<Tab>\\fgt :!hg forget %<CR><CR> | |||
|
26 | amenu H&G.Show\ Differences<Tab>\\diff :call ShowResults("FileDiff", "hg\ diff")<CR><CR> | |||
|
27 | amenu H&G.Revert\ to\ Last\ Version<Tab>\\revert :!hg revert %<CR>:e!<CR> | |||
|
28 | amenu H&G.Show\ History<Tab>\\log :call ShowResults("FileLog", "hg\ log")<CR><CR> | |||
|
29 | amenu H&G.Annotate<Tab>\\an :call ShowResults("annotate", "hg\ annotate")<CR><CR> | |||
|
30 | amenu H&G.-SEP1- <nul> | |||
|
31 | amenu H&G.Repo\ Status<Tab>\\stat :call ShowResults("RepoStatus", "hg\ status")<CR><CR> | |||
|
32 | amenu H&G.Pull<Tab>\\pull :!hg pull<CR>:e!<CR> | |||
|
33 | amenu H&G.Update<Tab>\\upd :!hg update<CR>:e!<CR> | |||
|
34 | endif | |||
|
35 | ||||
|
36 | " Section: Mappings {{{1 | |||
|
37 | if(v:version >= 600) | |||
|
38 | " The default Leader is \ 'backslash' | |||
|
39 | map <Leader>add :!hg add %<CR><CR> | |||
|
40 | map <Leader>fgt :!hg forget %<CR><CR> | |||
|
41 | map <Leader>diff :call ShowResults("FileDiff", "hg\ diff")<CR><CR> | |||
|
42 | map <Leader>revert :!hg revert %<CR>:e!<CR> | |||
|
43 | map <Leader>log :call ShowResults("FileLog", "hg\ log")<CR><CR> | |||
|
44 | map <Leader>an :call ShowResults("annotate", "hg\ annotate")<CR><CR> | |||
|
45 | map <Leader>stat :call ShowResults("RepoStatus", "hg\ status")<CR><CR> | |||
|
46 | map <Leader>upd :!hg update<CR>:e!<CR> | |||
|
47 | map <Leader>pull :!hg pull<CR>:e!<CR> | |||
|
48 | else | |||
|
49 | " pre 6.0, the default Leader was a comma | |||
|
50 | map ,add :!hg add %<CR><CR> | |||
|
51 | map ,fgt :!hg forget %<CR><CR> | |||
|
52 | map ,diff :call ShowResults("FileDiff", "hg\ diff")<CR><CR> | |||
|
53 | map ,revert :!hg revert<CR>:e!<CR> | |||
|
54 | map ,log :call ShowResults("FileLog", "hg\ log")<CR><CR> | |||
|
55 | map ,an :call ShowResults("annotate", "hg\ annotate")<CR><CR> | |||
|
56 | map ,stat :call ShowResults("RepoStatus", "hg\ status")<CR><CR> | |||
|
57 | map ,upd :!hg update<CR>:e!<CR> | |||
|
58 | map ,pull :!hg pull<CR>:e!<CR> | |||
|
59 | endif | |||
|
60 | ||||
|
61 | " Section: Functions {{{1 | |||
|
62 | " Show the log results of the current file with a revision control system. | |||
|
63 | function! ShowResults(bufferName, cmdName) | |||
|
64 | " Modify the shortmess option: | |||
|
65 | " A don't give the "ATTENTION" message when an existing swap file is | |||
|
66 | " found. | |||
|
67 | set shortmess+=A | |||
|
68 | ||||
|
69 | " Get the name of the current buffer. | |||
|
70 | let currentBuffer = bufname("%") | |||
|
71 | ||||
|
72 | " If a buffer with the name rlog exists, delete it. | |||
|
73 | if bufexists(a:bufferName) | |||
|
74 | execute 'bd! ' a:bufferName | |||
|
75 | endif | |||
|
76 | ||||
|
77 | " Create a new buffer. | |||
|
78 | execute 'new ' a:bufferName | |||
|
79 | ||||
|
80 | " Execute the command. | |||
|
81 | execute 'r!' a:cmdName ' ' currentBuffer | |||
|
82 | ||||
|
83 | " Make is so that the file can't be edited. | |||
|
84 | setlocal nomodified | |||
|
85 | setlocal nomodifiable | |||
|
86 | setlocal readonly | |||
|
87 | ||||
|
88 | " Go to the beginning of the buffer. | |||
|
89 | execute "normal 1G" | |||
|
90 | ||||
|
91 | " Restore the shortmess option. | |||
|
92 | set shortmess-=A | |||
|
93 | endfunction |
General Comments 0
You need to be logged in to leave comments.
Login now