Mercurial > hg
annotate contrib/vim/hg-menu.vim @ 7090:7b5c063b0b94
diff: pass contexts to status
Allow status() to take contexts as well as nodes. This lets us avoid
unpacking manifests multiple times and intelligently unpack manifests
in revision order. Also, we can avoid unpacking manifests at all when
there are no changes in the working directory.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 12 Oct 2008 15:21:08 -0500 |
parents | ea7b982b6c08 |
children |
rev | line source |
---|---|
1414
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
1 " vim600: set foldmethod=marker: |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
2 " ============================================================================= |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
3 " Name Of File: hg-menu.vim |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
4 " Description: Interface to Mercurial Version Control. |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
5 " Author: Steve Borho (modified Jeff Lanzarotta's RCS script) |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
6 " Date: Wednesday, October 5, 2005 |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
7 " Version: 0.1.0 |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
8 " Copyright: None. |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
9 " Usage: These command and gui menu displays useful hg functions |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
10 " Configuration: Your hg executable must be in your path. |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
11 " ============================================================================= |
5081
ea7b982b6c08
Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2351
diff
changeset
|
12 |
1414
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
13 " Section: Init {{{1 |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
14 if exists("loaded_hg_menu") |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
15 finish |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
16 endif |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
17 let loaded_hg_menu = 1 |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
18 |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
19 " Section: Menu Options {{{1 |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
20 if has("gui") |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
21 " amenu H&G.Commit\ File<Tab>,ci :!hg commit %<CR>:e!<CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
22 " amenu H&G.Commit\ All<Tab>,call :!hg commit<CR>:e!<CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
23 " amenu H&G.-SEP1- <nul> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
24 amenu H&G.Add<Tab>\\add :!hg add %<CR><CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
25 amenu H&G.Forget\ Add<Tab>\\fgt :!hg forget %<CR><CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
26 amenu H&G.Show\ Differences<Tab>\\diff :call ShowResults("FileDiff", "hg\ diff")<CR><CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
27 amenu H&G.Revert\ to\ Last\ Version<Tab>\\revert :!hg revert %<CR>:e!<CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
28 amenu H&G.Show\ History<Tab>\\log :call ShowResults("FileLog", "hg\ log")<CR><CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
29 amenu H&G.Annotate<Tab>\\an :call ShowResults("annotate", "hg\ annotate")<CR><CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
30 amenu H&G.-SEP1- <nul> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
31 amenu H&G.Repo\ Status<Tab>\\stat :call ShowResults("RepoStatus", "hg\ status")<CR><CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
32 amenu H&G.Pull<Tab>\\pull :!hg pull<CR>:e!<CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
33 amenu H&G.Update<Tab>\\upd :!hg update<CR>:e!<CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
34 endif |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
35 |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
36 " Section: Mappings {{{1 |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
37 if(v:version >= 600) |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
38 " The default Leader is \ 'backslash' |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
39 map <Leader>add :!hg add %<CR><CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
40 map <Leader>fgt :!hg forget %<CR><CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
41 map <Leader>diff :call ShowResults("FileDiff", "hg\ diff")<CR><CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
42 map <Leader>revert :!hg revert %<CR>:e!<CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
43 map <Leader>log :call ShowResults("FileLog", "hg\ log")<CR><CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
44 map <Leader>an :call ShowResults("annotate", "hg\ annotate")<CR><CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
45 map <Leader>stat :call ShowResults("RepoStatus", "hg\ status")<CR><CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
46 map <Leader>upd :!hg update<CR>:e!<CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
47 map <Leader>pull :!hg pull<CR>:e!<CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
48 else |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
49 " pre 6.0, the default Leader was a comma |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
50 map ,add :!hg add %<CR><CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
51 map ,fgt :!hg forget %<CR><CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
52 map ,diff :call ShowResults("FileDiff", "hg\ diff")<CR><CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
53 map ,revert :!hg revert<CR>:e!<CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
54 map ,log :call ShowResults("FileLog", "hg\ log")<CR><CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
55 map ,an :call ShowResults("annotate", "hg\ annotate")<CR><CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
56 map ,stat :call ShowResults("RepoStatus", "hg\ status")<CR><CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
57 map ,upd :!hg update<CR>:e!<CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
58 map ,pull :!hg pull<CR>:e!<CR> |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
59 endif |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
60 |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
61 " Section: Functions {{{1 |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
62 " Show the log results of the current file with a revision control system. |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
63 function! ShowResults(bufferName, cmdName) |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
64 " Modify the shortmess option: |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
65 " A don't give the "ATTENTION" message when an existing swap file is |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
66 " found. |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
67 set shortmess+=A |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
68 |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
69 " Get the name of the current buffer. |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
70 let currentBuffer = bufname("%") |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
71 |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
72 " If a buffer with the name rlog exists, delete it. |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
73 if bufexists(a:bufferName) |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
74 execute 'bd! ' a:bufferName |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
75 endif |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
76 |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
77 " Create a new buffer. |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
78 execute 'new ' a:bufferName |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
79 |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
80 " Execute the command. |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
81 execute 'r!' a:cmdName ' ' currentBuffer |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
82 |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
83 " Make is so that the file can't be edited. |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
84 setlocal nomodified |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
85 setlocal nomodifiable |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
86 setlocal readonly |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
87 |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
88 " Go to the beginning of the buffer. |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
89 execute "normal 1G" |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
90 |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
91 " Restore the shortmess option. |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
92 set shortmess-=A |
32fde51910c0
New vim script; provides key mappings and menus for GVIM
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
93 endfunction |