Show More
@@ -1,1676 +1,1680 b'' | |||
|
1 | 1 | " vim600: set foldmethod=marker: |
|
2 | 2 | " |
|
3 | 3 | " Vim plugin to assist in working with HG-controlled files. |
|
4 | 4 | " |
|
5 | 5 | " Last Change: 2006/02/22 |
|
6 | 6 | " Version: 1.76 |
|
7 | 7 | " Maintainer: Mathieu Clabaut <mathieu.clabaut@gmail.com> |
|
8 | 8 | " License: This file is placed in the public domain. |
|
9 | 9 | " Credits: |
|
10 | 10 | " Bob Hiestand <bob.hiestand@gmail.com> for the fabulous |
|
11 | 11 | " cvscommand.vim from which this script was directly created by |
|
12 | 12 | " means of sed commands and minor tweaks. |
|
13 | 13 | |
|
14 | 14 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
|
15 | 15 | " |
|
16 | 16 | " Section: Documentation |
|
17 | 17 | "---------------------------- |
|
18 | 18 | " |
|
19 | 19 | " Documentation should be available by ":help hgcommand" command, once the |
|
20 | 20 | " script has been copied in you .vim/plugin directory. |
|
21 | 21 | " |
|
22 | 22 | " You still can read the documentation at the end of this file. Locate it by |
|
23 | 23 | " searching the "hgcommand-contents" string (and set ft=help to have |
|
24 | 24 | " appropriate syntaxic coloration). |
|
25 | 25 | |
|
26 | 26 | " Section: Plugin header {{{1 |
|
27 | 27 | |
|
28 | 28 | " loaded_hgcommand is set to 1 when the initialization begins, and 2 when it |
|
29 | 29 | " completes. This allows various actions to only be taken by functions after |
|
30 | 30 | " system initialization. |
|
31 | 31 | |
|
32 | 32 | if exists("loaded_hgcommand") |
|
33 | 33 | finish |
|
34 | 34 | endif |
|
35 | 35 | let loaded_hgcommand = 1 |
|
36 | 36 | |
|
37 | 37 | if v:version < 602 |
|
38 | 38 | echohl WarningMsg|echomsg "HGCommand 1.69 or later requires VIM 6.2 or later"|echohl None |
|
39 | 39 | finish |
|
40 | 40 | endif |
|
41 | 41 | |
|
42 | 42 | " Section: Event group setup {{{1 |
|
43 | 43 | |
|
44 | 44 | augroup HGCommand |
|
45 | 45 | augroup END |
|
46 | 46 | |
|
47 | 47 | " Section: Plugin initialization {{{1 |
|
48 | 48 | silent do HGCommand User HGPluginInit |
|
49 | 49 | |
|
50 | 50 | " Section: Script variable initialization {{{1 |
|
51 | 51 | |
|
52 | 52 | let s:HGCommandEditFileRunning = 0 |
|
53 | 53 | unlet! s:vimDiffRestoreCmd |
|
54 | 54 | unlet! s:vimDiffSourceBuffer |
|
55 | 55 | unlet! s:vimDiffBufferCount |
|
56 | 56 | unlet! s:vimDiffScratchList |
|
57 | 57 | |
|
58 | 58 | " Section: Utility functions {{{1 |
|
59 | 59 | |
|
60 | 60 | " Function: s:HGResolveLink() {{{2 |
|
61 | 61 | " Fully resolve the given file name to remove shortcuts or symbolic links. |
|
62 | 62 | |
|
63 | 63 | function! s:HGResolveLink(fileName) |
|
64 | 64 | let resolved = resolve(a:fileName) |
|
65 | 65 | if resolved != a:fileName |
|
66 | 66 | let resolved = s:HGResolveLink(resolved) |
|
67 | 67 | endif |
|
68 | 68 | return resolved |
|
69 | 69 | endfunction |
|
70 | 70 | |
|
71 | 71 | " Function: s:HGChangeToCurrentFileDir() {{{2 |
|
72 | 72 | " Go to the directory in which the current HG-controlled file is located. |
|
73 | 73 | " If this is a HG command buffer, first switch to the original file. |
|
74 | 74 | |
|
75 | 75 | function! s:HGChangeToCurrentFileDir(fileName) |
|
76 | 76 | let oldCwd=getcwd() |
|
77 | 77 | let fileName=s:HGResolveLink(a:fileName) |
|
78 | 78 | let newCwd=fnamemodify(fileName, ':h') |
|
79 | 79 | if strlen(newCwd) > 0 |
|
80 | 80 | execute 'cd' escape(newCwd, ' ') |
|
81 | 81 | endif |
|
82 | 82 | return oldCwd |
|
83 | 83 | endfunction |
|
84 | 84 | |
|
85 | 85 | " Function: s:HGGetOption(name, default) {{{2 |
|
86 | 86 | " Grab a user-specified option to override the default provided. Options are |
|
87 | 87 | " searched in the window, buffer, then global spaces. |
|
88 | 88 | |
|
89 | 89 | function! s:HGGetOption(name, default) |
|
90 | 90 | if exists("s:" . a:name . "Override") |
|
91 | 91 | execute "return s:".a:name."Override" |
|
92 | 92 | elseif exists("w:" . a:name) |
|
93 | 93 | execute "return w:".a:name |
|
94 | 94 | elseif exists("b:" . a:name) |
|
95 | 95 | execute "return b:".a:name |
|
96 | 96 | elseif exists("g:" . a:name) |
|
97 | 97 | execute "return g:".a:name |
|
98 | 98 | else |
|
99 | 99 | return a:default |
|
100 | 100 | endif |
|
101 | 101 | endfunction |
|
102 | 102 | |
|
103 | 103 | " Function: s:HGEditFile(name, origBuffNR) {{{2 |
|
104 | 104 | " Wrapper around the 'edit' command to provide some helpful error text if the |
|
105 | 105 | " current buffer can't be abandoned. If name is provided, it is used; |
|
106 | 106 | " otherwise, a nameless scratch buffer is used. |
|
107 | 107 | " Returns: 0 if successful, -1 if an error occurs. |
|
108 | 108 | |
|
109 | 109 | function! s:HGEditFile(name, origBuffNR) |
|
110 | 110 | "Name parameter will be pasted into expression. |
|
111 | 111 | let name = escape(a:name, ' *?\') |
|
112 | 112 | |
|
113 | 113 | let editCommand = s:HGGetOption('HGCommandEdit', 'edit') |
|
114 | 114 | if editCommand != 'edit' |
|
115 | 115 | if s:HGGetOption('HGCommandSplit', 'horizontal') == 'horizontal' |
|
116 | 116 | if name == "" |
|
117 | 117 | let editCommand = 'rightbelow new' |
|
118 | 118 | else |
|
119 | 119 | let editCommand = 'rightbelow split ' . name |
|
120 | 120 | endif |
|
121 | 121 | else |
|
122 | 122 | if name == "" |
|
123 | 123 | let editCommand = 'vert rightbelow new' |
|
124 | 124 | else |
|
125 | 125 | let editCommand = 'vert rightbelow split ' . name |
|
126 | 126 | endif |
|
127 | 127 | endif |
|
128 | 128 | else |
|
129 | 129 | if name == "" |
|
130 | 130 | let editCommand = 'enew' |
|
131 | 131 | else |
|
132 | 132 | let editCommand = 'edit ' . name |
|
133 | 133 | endif |
|
134 | 134 | endif |
|
135 | 135 | |
|
136 | 136 | " Protect against useless buffer set-up |
|
137 | 137 | let s:HGCommandEditFileRunning = s:HGCommandEditFileRunning + 1 |
|
138 | 138 | try |
|
139 | 139 | execute editCommand |
|
140 | 140 | finally |
|
141 | 141 | let s:HGCommandEditFileRunning = s:HGCommandEditFileRunning - 1 |
|
142 | 142 | endtry |
|
143 | 143 | |
|
144 | 144 | let b:HGOrigBuffNR=a:origBuffNR |
|
145 | 145 | let b:HGCommandEdit='split' |
|
146 | 146 | endfunction |
|
147 | 147 | |
|
148 | 148 | " Function: s:HGCreateCommandBuffer(cmd, cmdName, statusText, filename) {{{2 |
|
149 | 149 | " Creates a new scratch buffer and captures the output from execution of the |
|
150 | 150 | " given command. The name of the scratch buffer is returned. |
|
151 | 151 | |
|
152 | 152 | function! s:HGCreateCommandBuffer(cmd, cmdName, statusText, origBuffNR) |
|
153 | 153 | let fileName=bufname(a:origBuffNR) |
|
154 | 154 | |
|
155 | 155 | let resultBufferName='' |
|
156 | 156 | |
|
157 | 157 | if s:HGGetOption("HGCommandNameResultBuffers", 0) |
|
158 | 158 | let nameMarker = s:HGGetOption("HGCommandNameMarker", '_') |
|
159 | 159 | if strlen(a:statusText) > 0 |
|
160 | 160 | let bufName=a:cmdName . ' -- ' . a:statusText |
|
161 | 161 | else |
|
162 | 162 | let bufName=a:cmdName |
|
163 | 163 | endif |
|
164 | 164 | let bufName=fileName . ' ' . nameMarker . bufName . nameMarker |
|
165 | 165 | let counter=0 |
|
166 | 166 | let resultBufferName = bufName |
|
167 | 167 | while buflisted(resultBufferName) |
|
168 | 168 | let counter=counter + 1 |
|
169 | 169 | let resultBufferName=bufName . ' (' . counter . ')' |
|
170 | 170 | endwhile |
|
171 | 171 | endif |
|
172 | 172 | |
|
173 | 173 | let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " " . a:cmd |
|
174 | 174 | echomsg "DBG :".hgCommand |
|
175 | 175 | let hgOut = system(hgCommand) |
|
176 | 176 | " HACK: diff command does not return proper error codes |
|
177 | 177 | if v:shell_error && a:cmdName != 'hgdiff' |
|
178 | 178 | if strlen(hgOut) == 0 |
|
179 | 179 | echoerr "HG command failed" |
|
180 | 180 | else |
|
181 | 181 | echoerr "HG command failed: " . hgOut |
|
182 | 182 | endif |
|
183 | 183 | return -1 |
|
184 | 184 | endif |
|
185 | 185 | if strlen(hgOut) == 0 |
|
186 | 186 | " Handle case of no output. In this case, it is important to check the |
|
187 | 187 | " file status, especially since hg edit/unedit may change the attributes |
|
188 | 188 | " of the file with no visible output. |
|
189 | 189 | |
|
190 | 190 | echomsg "No output from HG command" |
|
191 | 191 | checktime |
|
192 | 192 | return -1 |
|
193 | 193 | endif |
|
194 | 194 | |
|
195 | 195 | if s:HGEditFile(resultBufferName, a:origBuffNR) == -1 |
|
196 | 196 | return -1 |
|
197 | 197 | endif |
|
198 | 198 | |
|
199 | 199 | set buftype=nofile |
|
200 | 200 | set noswapfile |
|
201 | 201 | set filetype= |
|
202 | 202 | |
|
203 | 203 | if s:HGGetOption("HGCommandDeleteOnHide", 0) |
|
204 | 204 | set bufhidden=delete |
|
205 | 205 | endif |
|
206 | 206 | |
|
207 | 207 | silent 0put=hgOut |
|
208 | 208 | |
|
209 | 209 | " The last command left a blank line at the end of the buffer. If the |
|
210 | 210 | " last line is folded (a side effect of the 'put') then the attempt to |
|
211 | 211 | " remove the blank line will kill the last fold. |
|
212 | 212 | " |
|
213 | 213 | " This could be fixed by explicitly detecting whether the last line is |
|
214 | 214 | " within a fold, but I prefer to simply unfold the result buffer altogether. |
|
215 | 215 | |
|
216 | 216 | if has('folding') |
|
217 | 217 | normal zR |
|
218 | 218 | endif |
|
219 | 219 | |
|
220 | 220 | $d |
|
221 | 221 | 1 |
|
222 | 222 | |
|
223 | 223 | " Define the environment and execute user-defined hooks. |
|
224 | 224 | |
|
225 | 225 | let b:HGSourceFile=fileName |
|
226 | 226 | let b:HGCommand=a:cmdName |
|
227 | 227 | if a:statusText != "" |
|
228 | 228 | let b:HGStatusText=a:statusText |
|
229 | 229 | endif |
|
230 | 230 | |
|
231 | 231 | silent do HGCommand User HGBufferCreated |
|
232 | 232 | return bufnr("%") |
|
233 | 233 | endfunction |
|
234 | 234 | |
|
235 | 235 | " Function: s:HGBufferCheck(hgBuffer) {{{2 |
|
236 | 236 | " Attempts to locate the original file to which HG operations were applied |
|
237 | 237 | " for a given buffer. |
|
238 | 238 | |
|
239 | 239 | function! s:HGBufferCheck(hgBuffer) |
|
240 | 240 | let origBuffer = getbufvar(a:hgBuffer, "HGOrigBuffNR") |
|
241 | 241 | if origBuffer |
|
242 | 242 | if bufexists(origBuffer) |
|
243 | 243 | return origBuffer |
|
244 | 244 | else |
|
245 | 245 | " Original buffer no longer exists. |
|
246 | 246 | return -1 |
|
247 | 247 | endif |
|
248 | 248 | else |
|
249 | 249 | " No original buffer |
|
250 | 250 | return a:hgBuffer |
|
251 | 251 | endif |
|
252 | 252 | endfunction |
|
253 | 253 | |
|
254 | 254 | " Function: s:HGCurrentBufferCheck() {{{2 |
|
255 | 255 | " Attempts to locate the original file to which HG operations were applied |
|
256 | 256 | " for the current buffer. |
|
257 | 257 | |
|
258 | 258 | function! s:HGCurrentBufferCheck() |
|
259 | 259 | return s:HGBufferCheck(bufnr("%")) |
|
260 | 260 | endfunction |
|
261 | 261 | |
|
262 | 262 | " Function: s:HGToggleDeleteOnHide() {{{2 |
|
263 | 263 | " Toggles on and off the delete-on-hide behavior of HG buffers |
|
264 | 264 | |
|
265 | 265 | function! s:HGToggleDeleteOnHide() |
|
266 | 266 | if exists("g:HGCommandDeleteOnHide") |
|
267 | 267 | unlet g:HGCommandDeleteOnHide |
|
268 | 268 | else |
|
269 | 269 | let g:HGCommandDeleteOnHide=1 |
|
270 | 270 | endif |
|
271 | 271 | endfunction |
|
272 | 272 | |
|
273 | 273 | " Function: s:HGDoCommand(hgcmd, cmdName, statusText) {{{2 |
|
274 | 274 | " General skeleton for HG function execution. |
|
275 | 275 | " Returns: name of the new command buffer containing the command results |
|
276 | 276 | |
|
277 | 277 | function! s:HGDoCommand(cmd, cmdName, statusText) |
|
278 | 278 | let hgBufferCheck=s:HGCurrentBufferCheck() |
|
279 | 279 | if hgBufferCheck == -1 |
|
280 | 280 | echo "Original buffer no longer exists, aborting." |
|
281 | 281 | return -1 |
|
282 | 282 | endif |
|
283 | 283 | |
|
284 | 284 | let fileName=bufname(hgBufferCheck) |
|
285 | 285 | if isdirectory(fileName) |
|
286 | 286 | let fileName=fileName . "/" . getline(".") |
|
287 | 287 | endif |
|
288 | 288 | let realFileName = fnamemodify(s:HGResolveLink(fileName), ':t') |
|
289 | 289 | let oldCwd=s:HGChangeToCurrentFileDir(fileName) |
|
290 | 290 | try |
|
291 | 291 | " TODO |
|
292 | 292 | "if !filereadable('HG/Root') |
|
293 | 293 | "throw fileName . ' is not a HG-controlled file.' |
|
294 | 294 | "endif |
|
295 | 295 | let fullCmd = a:cmd . ' "' . realFileName . '"' |
|
296 | 296 | "echomsg "DEBUG".fullCmd |
|
297 | 297 | let resultBuffer=s:HGCreateCommandBuffer(fullCmd, a:cmdName, a:statusText, hgBufferCheck) |
|
298 | 298 | return resultBuffer |
|
299 | 299 | catch |
|
300 | 300 | echoerr v:exception |
|
301 | 301 | return -1 |
|
302 | 302 | finally |
|
303 | 303 | execute 'cd' escape(oldCwd, ' ') |
|
304 | 304 | endtry |
|
305 | 305 | endfunction |
|
306 | 306 | |
|
307 | 307 | |
|
308 | 308 | " Function: s:HGGetStatusVars(revision, branch, repository) {{{2 |
|
309 | 309 | " |
|
310 | 310 | " Obtains a HG revision number and branch name. The 'revisionVar', |
|
311 | 311 | " 'branchVar'and 'repositoryVar' arguments, if non-empty, contain the names of variables to hold |
|
312 | 312 | " the corresponding results. |
|
313 | 313 | " |
|
314 | 314 | " Returns: string to be exec'd that sets the multiple return values. |
|
315 | 315 | |
|
316 | 316 | function! s:HGGetStatusVars(revisionVar, branchVar, repositoryVar) |
|
317 | 317 | let hgBufferCheck=s:HGCurrentBufferCheck() |
|
318 | 318 | if hgBufferCheck == -1 |
|
319 | 319 | return "" |
|
320 | 320 | endif |
|
321 | 321 | let fileName=bufname(hgBufferCheck) |
|
322 | 322 | let realFileName = fnamemodify(s:HGResolveLink(fileName), ':t') |
|
323 | 323 | let oldCwd=s:HGChangeToCurrentFileDir(fileName) |
|
324 | 324 | try |
|
325 | 325 | ""TODO |
|
326 | 326 | "if !filereadable('HG/Root') |
|
327 | 327 | "return "" |
|
328 | 328 | "endif |
|
329 | 329 | let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " status -mardui " . fileName |
|
330 | 330 | let statustext=system(hgCommand) |
|
331 | 331 | if(v:shell_error) |
|
332 | 332 | return "" |
|
333 | 333 | endif |
|
334 | 334 | if match(statustext, '^[?I]') >= 0 |
|
335 | 335 | let revision="NEW" |
|
336 | 336 | elseif match(statustext, '^[R]') >= 0 |
|
337 | 337 | let revision="REMOVED" |
|
338 | 338 | elseif match(statustext, '^[D]') >= 0 |
|
339 | 339 | let revision="DELETED" |
|
340 | 340 | elseif match(statustext, '^[A]') >= 0 |
|
341 | 341 | let revision="ADDED" |
|
342 | 342 | endif |
|
343 | 343 | |
|
344 | 344 | let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " parents -b " |
|
345 | 345 | let statustext=system(hgCommand) |
|
346 | 346 | if(v:shell_error) |
|
347 | 347 | return "" |
|
348 | 348 | endif |
|
349 | 349 | if exists('revision') |
|
350 | 350 | let returnExpression = "let " . a:revisionVar . "='" . revision . "'" |
|
351 | 351 | else |
|
352 | 352 | let revision=substitute(statustext, '^changeset:\s*\(\d\+\):.*\_$\_.*$', '\1', "") |
|
353 | 353 | let returnExpression = "let " . a:revisionVar . "='" . revision . "'" |
|
354 | 354 | endif |
|
355 | 355 | |
|
356 | 356 | if a:branchVar != "" && match(statustext, '^\_.*\_^branch:') >= 0 |
|
357 | 357 | let branch=substitute(statustext, '^\_.*\_^branch:\s*\(\S\+\)\n\_.*$', '\1', "") |
|
358 | 358 | let returnExpression=returnExpression . " | let " . a:branchVar . "='" . branch . "'" |
|
359 | 359 | endif |
|
360 | 360 | if a:repositoryVar != "" |
|
361 | 361 | let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " root " |
|
362 | 362 | let roottext=system(hgCommand) |
|
363 | 363 | let repository=substitute(roottext,'^.*/\([^/\n\r]*\)\n\_.*$','\1','') |
|
364 | 364 | let returnExpression=returnExpression . " | let " . a:repositoryVar . "='" . repository . "'" |
|
365 | 365 | endif |
|
366 | 366 | |
|
367 | 367 | |
|
368 | 368 | |
|
369 | 369 | return returnExpression |
|
370 | 370 | finally |
|
371 | 371 | execute 'cd' escape(oldCwd, ' ') |
|
372 | 372 | endtry |
|
373 | 373 | endfunction |
|
374 | 374 | |
|
375 | 375 | " Function: s:HGSetupBuffer() {{{2 |
|
376 | 376 | " Attempts to set the b:HGBranch, b:HGRevision and b:HGRepository variables. |
|
377 | 377 | |
|
378 | function! s:HGSetupBuffer() | |
|
379 | if (exists("b:HGBufferSetup") && b:HGBufferSetup) | |
|
378 | function! s:HGSetupBuffer(...) | |
|
379 | if (exists("b:HGBufferSetup") && b:HGBufferSetup && !exists('a:1')) | |
|
380 | 380 | " This buffer is already set up. |
|
381 | 381 | return |
|
382 | 382 | endif |
|
383 | 383 | |
|
384 | 384 | if !s:HGGetOption("HGCommandEnableBufferSetup", 0) |
|
385 | 385 | \ || @% == "" |
|
386 | 386 | \ || s:HGCommandEditFileRunning > 0 |
|
387 | 387 | \ || exists("b:HGOrigBuffNR") |
|
388 | 388 | unlet! b:HGRevision |
|
389 | 389 | unlet! b:HGBranch |
|
390 | 390 | unlet! b:HGRepository |
|
391 | 391 | return |
|
392 | 392 | endif |
|
393 | 393 | |
|
394 | 394 | if !filereadable(expand("%")) |
|
395 | 395 | return -1 |
|
396 | 396 | endif |
|
397 | 397 | |
|
398 | 398 | let revision="" |
|
399 | 399 | let branch="" |
|
400 | 400 | let repository="" |
|
401 | 401 | |
|
402 | 402 | exec s:HGGetStatusVars('revision', 'branch', 'repository') |
|
403 | 403 | "echomsg "DBG ".revision."#".branch."#".repository |
|
404 | 404 | if revision != "" |
|
405 | 405 | let b:HGRevision=revision |
|
406 | 406 | else |
|
407 | 407 | unlet! b:HGRevision |
|
408 | 408 | endif |
|
409 | 409 | if branch != "" |
|
410 | 410 | let b:HGBranch=branch |
|
411 | 411 | else |
|
412 | 412 | unlet! b:HGBranch |
|
413 | 413 | endif |
|
414 | 414 | if repository != "" |
|
415 | 415 | let b:HGRepository=repository |
|
416 | 416 | else |
|
417 | 417 | unlet! b:HGRepository |
|
418 | 418 | endif |
|
419 | 419 | silent do HGCommand User HGBufferSetup |
|
420 | 420 | let b:HGBufferSetup=1 |
|
421 | 421 | endfunction |
|
422 | 422 | |
|
423 | 423 | " Function: s:HGMarkOrigBufferForSetup(hgbuffer) {{{2 |
|
424 | 424 | " Resets the buffer setup state of the original buffer for a given HG buffer. |
|
425 | 425 | " Returns: The HG buffer number in a passthrough mode. |
|
426 | 426 | |
|
427 | 427 | function! s:HGMarkOrigBufferForSetup(hgBuffer) |
|
428 | 428 | checktime |
|
429 | 429 | if a:hgBuffer != -1 |
|
430 | 430 | let origBuffer = s:HGBufferCheck(a:hgBuffer) |
|
431 | 431 | "This should never not work, but I'm paranoid |
|
432 | 432 | if origBuffer != a:hgBuffer |
|
433 | 433 | call setbufvar(origBuffer, "HGBufferSetup", 0) |
|
434 | 434 | endif |
|
435 | 435 | endif |
|
436 | 436 | return a:hgBuffer |
|
437 | 437 | endfunction |
|
438 | 438 | |
|
439 | 439 | " Function: s:HGOverrideOption(option, [value]) {{{2 |
|
440 | 440 | " Provides a temporary override for the given HG option. If no value is |
|
441 | 441 | " passed, the override is disabled. |
|
442 | 442 | |
|
443 | 443 | function! s:HGOverrideOption(option, ...) |
|
444 | 444 | if a:0 == 0 |
|
445 | 445 | unlet! s:{a:option}Override |
|
446 | 446 | else |
|
447 | 447 | let s:{a:option}Override = a:1 |
|
448 | 448 | endif |
|
449 | 449 | endfunction |
|
450 | 450 | |
|
451 | 451 | " Function: s:HGWipeoutCommandBuffers() {{{2 |
|
452 | 452 | " Clears all current HG buffers of the specified type for a given source. |
|
453 | 453 | |
|
454 | 454 | function! s:HGWipeoutCommandBuffers(originalBuffer, hgCommand) |
|
455 | 455 | let buffer = 1 |
|
456 | 456 | while buffer <= bufnr('$') |
|
457 | 457 | if getbufvar(buffer, 'HGOrigBuffNR') == a:originalBuffer |
|
458 | 458 | if getbufvar(buffer, 'HGCommand') == a:hgCommand |
|
459 | 459 | execute 'bw' buffer |
|
460 | 460 | endif |
|
461 | 461 | endif |
|
462 | 462 | let buffer = buffer + 1 |
|
463 | 463 | endwhile |
|
464 | 464 | endfunction |
|
465 | 465 | |
|
466 | 466 | " Function: s:HGInstallDocumentation(full_name, revision) {{{2 |
|
467 | 467 | " Install help documentation. |
|
468 | 468 | " Arguments: |
|
469 | 469 | " full_name: Full name of this vim plugin script, including path name. |
|
470 | 470 | " revision: Revision of the vim script. #version# mark in the document file |
|
471 | 471 | " will be replaced with this string with 'v' prefix. |
|
472 | 472 | " Return: |
|
473 | 473 | " 1 if new document installed, 0 otherwise. |
|
474 | 474 | " Note: Cleaned and generalized by guo-peng Wen |
|
475 | 475 | "''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' |
|
476 | 476 | |
|
477 | 477 | function! s:HGInstallDocumentation(full_name, revision) |
|
478 | 478 | " Name of the document path based on the system we use: |
|
479 | 479 | if (has("unix")) |
|
480 | 480 | " On UNIX like system, using forward slash: |
|
481 | 481 | let l:slash_char = '/' |
|
482 | 482 | let l:mkdir_cmd = ':silent !mkdir -p ' |
|
483 | 483 | else |
|
484 | 484 | " On M$ system, use backslash. Also mkdir syntax is different. |
|
485 | 485 | " This should only work on W2K and up. |
|
486 | 486 | let l:slash_char = '\' |
|
487 | 487 | let l:mkdir_cmd = ':silent !mkdir ' |
|
488 | 488 | endif |
|
489 | 489 | |
|
490 | 490 | let l:doc_path = l:slash_char . 'doc' |
|
491 | 491 | let l:doc_home = l:slash_char . '.vim' . l:slash_char . 'doc' |
|
492 | 492 | |
|
493 | 493 | " Figure out document path based on full name of this script: |
|
494 | 494 | let l:vim_plugin_path = fnamemodify(a:full_name, ':h') |
|
495 | 495 | let l:vim_doc_path = fnamemodify(a:full_name, ':h:h') . l:doc_path |
|
496 | 496 | if (!(filewritable(l:vim_doc_path) == 2)) |
|
497 | 497 | echomsg "Doc path: " . l:vim_doc_path |
|
498 | 498 | execute l:mkdir_cmd . '"' . l:vim_doc_path . '"' |
|
499 | 499 | if (!(filewritable(l:vim_doc_path) == 2)) |
|
500 | 500 | " Try a default configuration in user home: |
|
501 | 501 | let l:vim_doc_path = expand("~") . l:doc_home |
|
502 | 502 | if (!(filewritable(l:vim_doc_path) == 2)) |
|
503 | 503 | execute l:mkdir_cmd . '"' . l:vim_doc_path . '"' |
|
504 | 504 | if (!(filewritable(l:vim_doc_path) == 2)) |
|
505 | 505 | " Put a warning: |
|
506 | 506 | echomsg "Unable to open documentation directory" |
|
507 | 507 | echomsg " type :help add-local-help for more informations." |
|
508 | 508 | return 0 |
|
509 | 509 | endif |
|
510 | 510 | endif |
|
511 | 511 | endif |
|
512 | 512 | endif |
|
513 | 513 | |
|
514 | 514 | " Exit if we have problem to access the document directory: |
|
515 | 515 | if (!isdirectory(l:vim_plugin_path) |
|
516 | 516 | \ || !isdirectory(l:vim_doc_path) |
|
517 | 517 | \ || filewritable(l:vim_doc_path) != 2) |
|
518 | 518 | return 0 |
|
519 | 519 | endif |
|
520 | 520 | |
|
521 | 521 | " Full name of script and documentation file: |
|
522 | 522 | let l:script_name = fnamemodify(a:full_name, ':t') |
|
523 | 523 | let l:doc_name = fnamemodify(a:full_name, ':t:r') . '.txt' |
|
524 | 524 | let l:plugin_file = l:vim_plugin_path . l:slash_char . l:script_name |
|
525 | 525 | let l:doc_file = l:vim_doc_path . l:slash_char . l:doc_name |
|
526 | 526 | |
|
527 | 527 | " Bail out if document file is still up to date: |
|
528 | 528 | if (filereadable(l:doc_file) && |
|
529 | 529 | \ getftime(l:plugin_file) < getftime(l:doc_file)) |
|
530 | 530 | return 0 |
|
531 | 531 | endif |
|
532 | 532 | |
|
533 | 533 | " Prepare window position restoring command: |
|
534 | 534 | if (strlen(@%)) |
|
535 | 535 | let l:go_back = 'b ' . bufnr("%") |
|
536 | 536 | else |
|
537 | 537 | let l:go_back = 'enew!' |
|
538 | 538 | endif |
|
539 | 539 | |
|
540 | 540 | " Create a new buffer & read in the plugin file (me): |
|
541 | 541 | setl nomodeline |
|
542 | 542 | exe 'enew!' |
|
543 | 543 | exe 'r ' . l:plugin_file |
|
544 | 544 | |
|
545 | 545 | setl modeline |
|
546 | 546 | let l:buf = bufnr("%") |
|
547 | 547 | setl noswapfile modifiable |
|
548 | 548 | |
|
549 | 549 | norm zR |
|
550 | 550 | norm gg |
|
551 | 551 | |
|
552 | 552 | " Delete from first line to a line starts with |
|
553 | 553 | " === START_DOC |
|
554 | 554 | 1,/^=\{3,}\s\+START_DOC\C/ d |
|
555 | 555 | |
|
556 | 556 | " Delete from a line starts with |
|
557 | 557 | " === END_DOC |
|
558 | 558 | " to the end of the documents: |
|
559 | 559 | /^=\{3,}\s\+END_DOC\C/,$ d |
|
560 | 560 | |
|
561 | 561 | " Remove fold marks: |
|
562 | 562 | %s/{\{3}[1-9]/ / |
|
563 | 563 | |
|
564 | 564 | " Add modeline for help doc: the modeline string is mangled intentionally |
|
565 | 565 | " to avoid it be recognized by VIM: |
|
566 | 566 | call append(line('$'), '') |
|
567 | 567 | call append(line('$'), ' v' . 'im:tw=78:ts=8:ft=help:norl:') |
|
568 | 568 | |
|
569 | 569 | " Replace revision: |
|
570 | 570 | exe "normal :1s/#version#/ v" . a:revision . "/\<CR>" |
|
571 | 571 | |
|
572 | 572 | " Save the help document: |
|
573 | 573 | exe 'w! ' . l:doc_file |
|
574 | 574 | exe l:go_back |
|
575 | 575 | exe 'bw ' . l:buf |
|
576 | 576 | |
|
577 | 577 | " Build help tags: |
|
578 | 578 | exe 'helptags ' . l:vim_doc_path |
|
579 | 579 | |
|
580 | 580 | return 1 |
|
581 | 581 | endfunction |
|
582 | 582 | |
|
583 | 583 | " Section: Public functions {{{1 |
|
584 | 584 | |
|
585 | 585 | " Function: HGGetRevision() {{{2 |
|
586 | 586 | " Global function for retrieving the current buffer's HG revision number. |
|
587 | 587 | " Returns: Revision number or an empty string if an error occurs. |
|
588 | 588 | |
|
589 | 589 | function! HGGetRevision() |
|
590 | 590 | let revision="" |
|
591 | 591 | exec s:HGGetStatusVars('revision', '', '') |
|
592 | 592 | return revision |
|
593 | 593 | endfunction |
|
594 | 594 | |
|
595 | 595 | " Function: HGDisableBufferSetup() {{{2 |
|
596 | 596 | " Global function for deactivating the buffer autovariables. |
|
597 | 597 | |
|
598 | 598 | function! HGDisableBufferSetup() |
|
599 | 599 | let g:HGCommandEnableBufferSetup=0 |
|
600 | 600 | silent! augroup! HGCommandPlugin |
|
601 | 601 | endfunction |
|
602 | 602 | |
|
603 | 603 | " Function: HGEnableBufferSetup() {{{2 |
|
604 | 604 | " Global function for activating the buffer autovariables. |
|
605 | 605 | |
|
606 | 606 | function! HGEnableBufferSetup() |
|
607 | 607 | let g:HGCommandEnableBufferSetup=1 |
|
608 | 608 | augroup HGCommandPlugin |
|
609 | 609 | au! |
|
610 | 610 | au BufEnter * call s:HGSetupBuffer() |
|
611 | " Force resetting up buffer on external file change (HG update) | |
|
612 | au FileChangedShell * call s:HGSetupBuffer(1) | |
|
611 | 613 | augroup END |
|
612 | 614 | |
|
613 | 615 | " Only auto-load if the plugin is fully loaded. This gives other plugins a |
|
614 | 616 | " chance to run. |
|
615 | 617 | if g:loaded_hgcommand == 2 |
|
616 | 618 | call s:HGSetupBuffer() |
|
617 | 619 | endif |
|
618 | 620 | endfunction |
|
619 | 621 | |
|
620 | 622 | " Function: HGGetStatusLine() {{{2 |
|
621 | 623 | " Default (sample) status line entry for HG files. This is only useful if |
|
622 | 624 | " HG-managed buffer mode is on (see the HGCommandEnableBufferSetup variable |
|
623 | 625 | " for how to do this). |
|
624 | 626 | |
|
625 | 627 | function! HGGetStatusLine() |
|
626 | 628 | if exists('b:HGSourceFile') |
|
627 | 629 | " This is a result buffer |
|
628 | 630 | let value='[' . b:HGCommand . ' ' . b:HGSourceFile |
|
629 | 631 | if exists('b:HGStatusText') |
|
630 | 632 | let value=value . ' ' . b:HGStatusText |
|
631 | 633 | endif |
|
632 | 634 | let value = value . ']' |
|
633 | 635 | return value |
|
634 | 636 | endif |
|
635 | 637 | |
|
636 | 638 | if exists('b:HGRevision') |
|
637 | 639 | \ && b:HGRevision != '' |
|
638 | 640 | \ && exists('b:HGRepository') |
|
639 | 641 | \ && b:HGRepository != '' |
|
640 | 642 | \ && exists('g:HGCommandEnableBufferSetup') |
|
641 | 643 | \ && g:HGCommandEnableBufferSetup |
|
642 | 644 | if !exists('b:HGBranch') |
|
643 | 645 | let l:branch='' |
|
644 | 646 | else |
|
645 | 647 | let l:branch=b:HGBranch |
|
646 | 648 | endif |
|
647 | 649 | return '[HG ' . b:HGRepository . '/' . l:branch .'/' . b:HGRevision . ']' |
|
648 | 650 | else |
|
649 | 651 | return '' |
|
650 | 652 | endif |
|
651 | 653 | endfunction |
|
652 | 654 | |
|
653 | 655 | " Section: HG command functions {{{1 |
|
654 | 656 | |
|
655 | 657 | " Function: s:HGAdd() {{{2 |
|
656 | 658 | function! s:HGAdd() |
|
657 | 659 | return s:HGMarkOrigBufferForSetup(s:HGDoCommand('add', 'hgadd', '')) |
|
658 | 660 | endfunction |
|
659 | 661 | |
|
660 | 662 | " Function: s:HGAnnotate(...) {{{2 |
|
661 | 663 | function! s:HGAnnotate(...) |
|
662 | 664 | if a:0 == 0 |
|
663 | 665 | if &filetype == "HGAnnotate" |
|
664 | 666 | " This is a HGAnnotate buffer. Perform annotation of the version |
|
665 | 667 | " indicated by the current line. |
|
666 | 668 | let revision = substitute(getline("."),'\(^[0-9]*\):.*','\1','') |
|
667 | 669 | if s:HGGetOption('HGCommandAnnotateParent', 0) != 0 && revision > 0 |
|
668 | 670 | let revision = revision - 1 |
|
669 | 671 | endif |
|
670 | 672 | else |
|
671 | 673 | let revision=HGGetRevision() |
|
672 | 674 | if revision == "" |
|
673 | 675 | echoerr "Unable to obtain HG version information." |
|
674 | 676 | return -1 |
|
675 | 677 | endif |
|
676 | 678 | endif |
|
677 | 679 | else |
|
678 | 680 | let revision=a:1 |
|
679 | 681 | endif |
|
680 | 682 | |
|
681 | 683 | if revision == "NEW" |
|
682 | 684 | echo "No annotatation available for new file." |
|
683 | 685 | return -1 |
|
684 | 686 | endif |
|
685 | 687 | |
|
686 | 688 | let resultBuffer=s:HGDoCommand('annotate -ndu -r ' . revision, 'hgannotate', revision) |
|
687 | 689 | echomsg "DBG: ".resultBuffer |
|
688 | 690 | if resultBuffer != -1 |
|
689 | 691 | set filetype=HGAnnotate |
|
690 | 692 | endif |
|
691 | 693 | |
|
692 | 694 | return resultBuffer |
|
693 | 695 | endfunction |
|
694 | 696 | |
|
695 | 697 | " Function: s:HGCommit() {{{2 |
|
696 | 698 | function! s:HGCommit(...) |
|
697 | 699 | " Handle the commit message being specified. If a message is supplied, it |
|
698 | 700 | " is used; if bang is supplied, an empty message is used; otherwise, the |
|
699 | 701 | " user is provided a buffer from which to edit the commit message. |
|
700 | 702 | if a:2 != "" || a:1 == "!" |
|
701 | 703 | return s:HGMarkOrigBufferForSetup(s:HGDoCommand('commit -m "' . a:2 . '"', 'hgcommit', '')) |
|
702 | 704 | endif |
|
703 | 705 | |
|
704 | 706 | let hgBufferCheck=s:HGCurrentBufferCheck() |
|
705 | 707 | if hgBufferCheck == -1 |
|
706 | 708 | echo "Original buffer no longer exists, aborting." |
|
707 | 709 | return -1 |
|
708 | 710 | endif |
|
709 | 711 | |
|
710 | 712 | " Protect against windows' backslashes in paths. They confuse exec'd |
|
711 | 713 | " commands. |
|
712 | 714 | |
|
713 | 715 | let shellSlashBak = &shellslash |
|
714 | 716 | try |
|
715 | 717 | set shellslash |
|
716 | 718 | |
|
717 | 719 | let messageFileName = tempname() |
|
718 | 720 | |
|
719 | 721 | let fileName=bufname(hgBufferCheck) |
|
720 | 722 | let realFilePath=s:HGResolveLink(fileName) |
|
721 | 723 | let newCwd=fnamemodify(realFilePath, ':h') |
|
722 | 724 | if strlen(newCwd) == 0 |
|
723 | 725 | " Account for autochdir being in effect, which will make this blank, but |
|
724 | 726 | " we know we'll be in the current directory for the original file. |
|
725 | 727 | let newCwd = getcwd() |
|
726 | 728 | endif |
|
727 | 729 | |
|
728 | 730 | let realFileName=fnamemodify(realFilePath, ':t') |
|
729 | 731 | |
|
730 | 732 | if s:HGEditFile(messageFileName, hgBufferCheck) == -1 |
|
731 | 733 | return |
|
732 | 734 | endif |
|
733 | 735 | |
|
734 | 736 | " Protect against case and backslash issues in Windows. |
|
735 | 737 | let autoPattern = '\c' . messageFileName |
|
736 | 738 | |
|
737 | 739 | " Ensure existance of group |
|
738 | 740 | augroup HGCommit |
|
739 | 741 | augroup END |
|
740 | 742 | |
|
741 | 743 | execute 'au HGCommit BufDelete' autoPattern 'call delete("' . messageFileName . '")' |
|
742 | 744 | execute 'au HGCommit BufDelete' autoPattern 'au! HGCommit * ' autoPattern |
|
743 | 745 | |
|
744 | 746 | " Create a commit mapping. The mapping must clear all autocommands in case |
|
745 | 747 | " it is invoked when HGCommandCommitOnWrite is active, as well as to not |
|
746 | 748 | " invoke the buffer deletion autocommand. |
|
747 | 749 | |
|
748 | 750 | execute 'nnoremap <silent> <buffer> <Plug>HGCommit '. |
|
749 | 751 | \ ':au! HGCommit * ' . autoPattern . '<CR>'. |
|
750 | 752 | \ ':g/^HG:/d<CR>'. |
|
751 | 753 | \ ':update<CR>'. |
|
752 | 754 | \ ':call <SID>HGFinishCommit("' . messageFileName . '",' . |
|
753 | 755 | \ '"' . newCwd . '",' . |
|
754 | 756 | \ '"' . realFileName . '",' . |
|
755 | \ hgBufferCheck . ')<CR>' | |
|
757 | \ hgBufferCheck . ')<CR>'. | |
|
758 | \ ':call <SID>HGBufferSetup(1)<CR>' | |
|
756 | 759 | |
|
757 | 760 | silent 0put ='HG: ----------------------------------------------------------------------' |
|
758 | 761 | silent put =\"HG: Enter Log. Lines beginning with `HG:' are removed automatically\" |
|
759 | 762 | silent put ='HG: Type <leader>cc (or your own <Plug>HGCommit mapping)' |
|
760 | 763 | |
|
761 | 764 | if s:HGGetOption('HGCommandCommitOnWrite', 1) == 1 |
|
762 | 765 | execute 'au HGCommit BufWritePre' autoPattern 'g/^HG:/d' |
|
763 | 766 | execute 'au HGCommit BufWritePost' autoPattern 'call s:HGFinishCommit("' . messageFileName . '", "' . newCwd . '", "' . realFileName . '", ' . hgBufferCheck . ') | au! * ' autoPattern |
|
764 | 767 | silent put ='HG: or write this buffer' |
|
765 | 768 | endif |
|
766 | 769 | |
|
767 | 770 | silent put ='HG: to finish this commit operation' |
|
768 | 771 | silent put ='HG: ----------------------------------------------------------------------' |
|
769 | 772 | $ |
|
770 | 773 | let b:HGSourceFile=fileName |
|
771 | 774 | let b:HGCommand='HGCommit' |
|
772 | 775 | set filetype=hg |
|
773 | 776 | finally |
|
774 | 777 | let &shellslash = shellSlashBak |
|
775 | 778 | endtry |
|
776 | 779 | |
|
777 | 780 | endfunction |
|
778 | 781 | |
|
779 | 782 | " Function: s:HGDiff(...) {{{2 |
|
780 | 783 | function! s:HGDiff(...) |
|
781 | 784 | if a:0 == 1 |
|
782 | 785 | let revOptions = '-r' . a:1 |
|
783 | 786 | let caption = a:1 . ' -> current' |
|
784 | 787 | elseif a:0 == 2 |
|
785 | 788 | let revOptions = '-r' . a:1 . ' -r' . a:2 |
|
786 | 789 | let caption = a:1 . ' -> ' . a:2 |
|
787 | 790 | else |
|
788 | 791 | let revOptions = '' |
|
789 | 792 | let caption = '' |
|
790 | 793 | endif |
|
791 | 794 | |
|
792 | 795 | let hgdiffopt=s:HGGetOption('HGCommandDiffOpt', 'w') |
|
793 | 796 | |
|
794 | 797 | if hgdiffopt == "" |
|
795 | 798 | let diffoptionstring="" |
|
796 | 799 | else |
|
797 | 800 | let diffoptionstring=" -" . hgdiffopt . " " |
|
798 | 801 | endif |
|
799 | 802 | |
|
800 | 803 | let resultBuffer = s:HGDoCommand('diff ' . diffoptionstring . revOptions , 'hgdiff', caption) |
|
801 | 804 | if resultBuffer != -1 |
|
802 | 805 | set filetype=diff |
|
803 | 806 | endif |
|
804 | 807 | return resultBuffer |
|
805 | 808 | endfunction |
|
806 | 809 | |
|
807 | 810 | |
|
808 | 811 | " Function: s:HGGotoOriginal(["!]) {{{2 |
|
809 | 812 | function! s:HGGotoOriginal(...) |
|
810 | 813 | let origBuffNR = s:HGCurrentBufferCheck() |
|
811 | 814 | if origBuffNR > 0 |
|
812 | 815 | let origWinNR = bufwinnr(origBuffNR) |
|
813 | 816 | if origWinNR == -1 |
|
814 | 817 | execute 'buffer' origBuffNR |
|
815 | 818 | else |
|
816 | 819 | execute origWinNR . 'wincmd w' |
|
817 | 820 | endif |
|
818 | 821 | if a:0 == 1 |
|
819 | 822 | if a:1 == "!" |
|
820 | 823 | let buffnr = 1 |
|
821 | 824 | let buffmaxnr = bufnr("$") |
|
822 | 825 | while buffnr <= buffmaxnr |
|
823 | 826 | if getbufvar(buffnr, "HGOrigBuffNR") == origBuffNR |
|
824 | 827 | execute "bw" buffnr |
|
825 | 828 | endif |
|
826 | 829 | let buffnr = buffnr + 1 |
|
827 | 830 | endwhile |
|
828 | 831 | endif |
|
829 | 832 | endif |
|
830 | 833 | endif |
|
831 | 834 | endfunction |
|
832 | 835 | |
|
833 | 836 | " Function: s:HGFinishCommit(messageFile, targetDir, targetFile) {{{2 |
|
834 | 837 | function! s:HGFinishCommit(messageFile, targetDir, targetFile, origBuffNR) |
|
835 | 838 | if filereadable(a:messageFile) |
|
836 | 839 | let oldCwd=getcwd() |
|
837 | 840 | if strlen(a:targetDir) > 0 |
|
838 | 841 | execute 'cd' escape(a:targetDir, ' ') |
|
839 | 842 | endif |
|
840 | 843 | let resultBuffer=s:HGCreateCommandBuffer('commit -F "' . a:messageFile . '" "'. a:targetFile . '"', 'hgcommit', '', a:origBuffNR) |
|
841 | 844 | execute 'cd' escape(oldCwd, ' ') |
|
842 | 845 | execute 'bw' escape(a:messageFile, ' *?\') |
|
843 | 846 | silent execute 'call delete("' . a:messageFile . '")' |
|
844 | 847 | return s:HGMarkOrigBufferForSetup(resultBuffer) |
|
845 | 848 | else |
|
846 | 849 | echoerr "Can't read message file; no commit is possible." |
|
847 | 850 | return -1 |
|
848 | 851 | endif |
|
849 | 852 | endfunction |
|
850 | 853 | |
|
851 | 854 | " Function: s:HGLog() {{{2 |
|
852 | 855 | function! s:HGLog(...) |
|
853 | 856 | if a:0 == 0 |
|
854 | 857 | let versionOption = "" |
|
855 | 858 | let caption = '' |
|
856 | 859 | else |
|
857 | 860 | let versionOption=" -r" . a:1 |
|
858 | 861 | let caption = a:1 |
|
859 | 862 | endif |
|
860 | 863 | |
|
861 | 864 | let resultBuffer=s:HGDoCommand('log' . versionOption, 'hglog', caption) |
|
862 | 865 | if resultBuffer != "" |
|
863 | 866 | set filetype=rcslog |
|
864 | 867 | endif |
|
865 | 868 | return resultBuffer |
|
866 | 869 | endfunction |
|
867 | 870 | |
|
868 | 871 | " Function: s:HGRevert() {{{2 |
|
869 | 872 | function! s:HGRevert() |
|
870 | 873 | return s:HGMarkOrigBufferForSetup(s:HGDoCommand('revert', 'hgrevert', '')) |
|
871 | 874 | endfunction |
|
872 | 875 | |
|
873 | 876 | " Function: s:HGReview(...) {{{2 |
|
874 | 877 | function! s:HGReview(...) |
|
875 | 878 | if a:0 == 0 |
|
876 | 879 | let versiontag="" |
|
877 | 880 | if s:HGGetOption('HGCommandInteractive', 0) |
|
878 | 881 | let versiontag=input('Revision: ') |
|
879 | 882 | endif |
|
880 | 883 | if versiontag == "" |
|
881 | 884 | let versiontag="(current)" |
|
882 | 885 | let versionOption="" |
|
883 | 886 | else |
|
884 | 887 | let versionOption=" -r " . versiontag . " " |
|
885 | 888 | endif |
|
886 | 889 | else |
|
887 | 890 | let versiontag=a:1 |
|
888 | 891 | let versionOption=" -r " . versiontag . " " |
|
889 | 892 | endif |
|
890 | 893 | |
|
891 | 894 | let resultBuffer = s:HGDoCommand('cat' . versionOption, 'hgreview', versiontag) |
|
892 | 895 | if resultBuffer > 0 |
|
893 | 896 | let &filetype=getbufvar(b:HGOrigBuffNR, '&filetype') |
|
894 | 897 | endif |
|
895 | 898 | |
|
896 | 899 | return resultBuffer |
|
897 | 900 | endfunction |
|
898 | 901 | |
|
899 | 902 | " Function: s:HGStatus() {{{2 |
|
900 | 903 | function! s:HGStatus() |
|
901 | 904 | return s:HGDoCommand('status', 'hgstatus', '') |
|
902 | 905 | endfunction |
|
903 | 906 | |
|
904 | 907 | |
|
905 | 908 | " Function: s:HGUpdate() {{{2 |
|
906 | 909 | function! s:HGUpdate() |
|
907 | 910 | return s:HGMarkOrigBufferForSetup(s:HGDoCommand('update', 'update', '')) |
|
911 | call s:HGSetupBuffer(1) | |
|
908 | 912 | endfunction |
|
909 | 913 | |
|
910 | 914 | " Function: s:HGVimDiff(...) {{{2 |
|
911 | 915 | function! s:HGVimDiff(...) |
|
912 | 916 | let originalBuffer = s:HGCurrentBufferCheck() |
|
913 | 917 | let s:HGCommandEditFileRunning = s:HGCommandEditFileRunning + 1 |
|
914 | 918 | try |
|
915 | 919 | " If there's already a VimDiff'ed window, restore it. |
|
916 | 920 | " There may only be one HGVimDiff original window at a time. |
|
917 | 921 | |
|
918 | 922 | if exists("s:vimDiffSourceBuffer") && s:vimDiffSourceBuffer != originalBuffer |
|
919 | 923 | " Clear the existing vimdiff setup by removing the result buffers. |
|
920 | 924 | call s:HGWipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff') |
|
921 | 925 | endif |
|
922 | 926 | |
|
923 | 927 | " Split and diff |
|
924 | 928 | if(a:0 == 2) |
|
925 | 929 | " Reset the vimdiff system, as 2 explicit versions were provided. |
|
926 | 930 | if exists('s:vimDiffSourceBuffer') |
|
927 | 931 | call s:HGWipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff') |
|
928 | 932 | endif |
|
929 | 933 | let resultBuffer = s:HGReview(a:1) |
|
930 | 934 | if resultBuffer < 0 |
|
931 | 935 | echomsg "Can't open HG revision " . a:1 |
|
932 | 936 | return resultBuffer |
|
933 | 937 | endif |
|
934 | 938 | let b:HGCommand = 'vimdiff' |
|
935 | 939 | diffthis |
|
936 | 940 | let s:vimDiffBufferCount = 1 |
|
937 | 941 | let s:vimDiffScratchList = '{'. resultBuffer . '}' |
|
938 | 942 | " If no split method is defined, cheat, and set it to vertical. |
|
939 | 943 | try |
|
940 | 944 | call s:HGOverrideOption('HGCommandSplit', s:HGGetOption('HGCommandDiffSplit', s:HGGetOption('HGCommandSplit', 'vertical'))) |
|
941 | 945 | let resultBuffer=s:HGReview(a:2) |
|
942 | 946 | finally |
|
943 | 947 | call s:HGOverrideOption('HGCommandSplit') |
|
944 | 948 | endtry |
|
945 | 949 | if resultBuffer < 0 |
|
946 | 950 | echomsg "Can't open HG revision " . a:1 |
|
947 | 951 | return resultBuffer |
|
948 | 952 | endif |
|
949 | 953 | let b:HGCommand = 'vimdiff' |
|
950 | 954 | diffthis |
|
951 | 955 | let s:vimDiffBufferCount = 2 |
|
952 | 956 | let s:vimDiffScratchList = s:vimDiffScratchList . '{'. resultBuffer . '}' |
|
953 | 957 | else |
|
954 | 958 | " Add new buffer |
|
955 | 959 | try |
|
956 | 960 | " Force splitting behavior, otherwise why use vimdiff? |
|
957 | 961 | call s:HGOverrideOption("HGCommandEdit", "split") |
|
958 | 962 | call s:HGOverrideOption("HGCommandSplit", s:HGGetOption('HGCommandDiffSplit', s:HGGetOption('HGCommandSplit', 'vertical'))) |
|
959 | 963 | if(a:0 == 0) |
|
960 | 964 | let resultBuffer=s:HGReview() |
|
961 | 965 | else |
|
962 | 966 | let resultBuffer=s:HGReview(a:1) |
|
963 | 967 | endif |
|
964 | 968 | finally |
|
965 | 969 | call s:HGOverrideOption("HGCommandEdit") |
|
966 | 970 | call s:HGOverrideOption("HGCommandSplit") |
|
967 | 971 | endtry |
|
968 | 972 | if resultBuffer < 0 |
|
969 | 973 | echomsg "Can't open current HG revision" |
|
970 | 974 | return resultBuffer |
|
971 | 975 | endif |
|
972 | 976 | let b:HGCommand = 'vimdiff' |
|
973 | 977 | diffthis |
|
974 | 978 | |
|
975 | 979 | if !exists('s:vimDiffBufferCount') |
|
976 | 980 | " New instance of vimdiff. |
|
977 | 981 | let s:vimDiffBufferCount = 2 |
|
978 | 982 | let s:vimDiffScratchList = '{' . resultBuffer . '}' |
|
979 | 983 | |
|
980 | 984 | " This could have been invoked on a HG result buffer, not the |
|
981 | 985 | " original buffer. |
|
982 | 986 | wincmd W |
|
983 | 987 | execute 'buffer' originalBuffer |
|
984 | 988 | " Store info for later original buffer restore |
|
985 | 989 | let s:vimDiffRestoreCmd = |
|
986 | 990 | \ "call setbufvar(".originalBuffer.", \"&diff\", ".getbufvar(originalBuffer, '&diff').")" |
|
987 | 991 | \ . "|call setbufvar(".originalBuffer.", \"&foldcolumn\", ".getbufvar(originalBuffer, '&foldcolumn').")" |
|
988 | 992 | \ . "|call setbufvar(".originalBuffer.", \"&foldenable\", ".getbufvar(originalBuffer, '&foldenable').")" |
|
989 | 993 | \ . "|call setbufvar(".originalBuffer.", \"&foldmethod\", '".getbufvar(originalBuffer, '&foldmethod')."')" |
|
990 | 994 | \ . "|call setbufvar(".originalBuffer.", \"&scrollbind\", ".getbufvar(originalBuffer, '&scrollbind').")" |
|
991 | 995 | \ . "|call setbufvar(".originalBuffer.", \"&wrap\", ".getbufvar(originalBuffer, '&wrap').")" |
|
992 | 996 | \ . "|if &foldmethod=='manual'|execute 'normal zE'|endif" |
|
993 | 997 | diffthis |
|
994 | 998 | wincmd w |
|
995 | 999 | else |
|
996 | 1000 | " Adding a window to an existing vimdiff |
|
997 | 1001 | let s:vimDiffBufferCount = s:vimDiffBufferCount + 1 |
|
998 | 1002 | let s:vimDiffScratchList = s:vimDiffScratchList . '{' . resultBuffer . '}' |
|
999 | 1003 | endif |
|
1000 | 1004 | endif |
|
1001 | 1005 | |
|
1002 | 1006 | let s:vimDiffSourceBuffer = originalBuffer |
|
1003 | 1007 | |
|
1004 | 1008 | " Avoid executing the modeline in the current buffer after the autocommand. |
|
1005 | 1009 | |
|
1006 | 1010 | let currentBuffer = bufnr('%') |
|
1007 | 1011 | let saveModeline = getbufvar(currentBuffer, '&modeline') |
|
1008 | 1012 | try |
|
1009 | 1013 | call setbufvar(currentBuffer, '&modeline', 0) |
|
1010 | 1014 | silent do HGCommand User HGVimDiffFinish |
|
1011 | 1015 | finally |
|
1012 | 1016 | call setbufvar(currentBuffer, '&modeline', saveModeline) |
|
1013 | 1017 | endtry |
|
1014 | 1018 | return resultBuffer |
|
1015 | 1019 | finally |
|
1016 | 1020 | let s:HGCommandEditFileRunning = s:HGCommandEditFileRunning - 1 |
|
1017 | 1021 | endtry |
|
1018 | 1022 | endfunction |
|
1019 | 1023 | |
|
1020 | 1024 | " Section: Command definitions {{{1 |
|
1021 | 1025 | " Section: Primary commands {{{2 |
|
1022 | 1026 | com! HGAdd call s:HGAdd() |
|
1023 | 1027 | com! -nargs=? HGAnnotate call s:HGAnnotate(<f-args>) |
|
1024 | 1028 | com! -bang -nargs=? HGCommit call s:HGCommit(<q-bang>, <q-args>) |
|
1025 | 1029 | com! -nargs=* HGDiff call s:HGDiff(<f-args>) |
|
1026 | 1030 | com! -bang HGGotoOriginal call s:HGGotoOriginal(<q-bang>) |
|
1027 | 1031 | com! -nargs=? HGLog call s:HGLog(<f-args>) |
|
1028 | 1032 | com! HGRevert call s:HGRevert() |
|
1029 | 1033 | com! -nargs=? HGReview call s:HGReview(<f-args>) |
|
1030 | 1034 | com! HGStatus call s:HGStatus() |
|
1031 | 1035 | com! HGUpdate call s:HGUpdate() |
|
1032 | 1036 | com! -nargs=* HGVimDiff call s:HGVimDiff(<f-args>) |
|
1033 | 1037 | |
|
1034 | 1038 | " Section: HG buffer management commands {{{2 |
|
1035 | 1039 | com! HGDisableBufferSetup call HGDisableBufferSetup() |
|
1036 | 1040 | com! HGEnableBufferSetup call HGEnableBufferSetup() |
|
1037 | 1041 | |
|
1038 | 1042 | " Allow reloading hgcommand.vim |
|
1039 | 1043 | com! HGReload unlet! loaded_hgcommand | runtime plugin/hgcommand.vim |
|
1040 | 1044 | |
|
1041 | 1045 | " Section: Plugin command mappings {{{1 |
|
1042 | 1046 | nnoremap <silent> <Plug>HGAdd :HGAdd<CR> |
|
1043 | 1047 | nnoremap <silent> <Plug>HGAnnotate :HGAnnotate<CR> |
|
1044 | 1048 | nnoremap <silent> <Plug>HGCommit :HGCommit<CR> |
|
1045 | 1049 | nnoremap <silent> <Plug>HGDiff :HGDiff<CR> |
|
1046 | 1050 | nnoremap <silent> <Plug>HGGotoOriginal :HGGotoOriginal<CR> |
|
1047 | 1051 | nnoremap <silent> <Plug>HGClearAndGotoOriginal :HGGotoOriginal!<CR> |
|
1048 | 1052 | nnoremap <silent> <Plug>HGLog :HGLog<CR> |
|
1049 | 1053 | nnoremap <silent> <Plug>HGRevert :HGRevert<CR> |
|
1050 | 1054 | nnoremap <silent> <Plug>HGReview :HGReview<CR> |
|
1051 | 1055 | nnoremap <silent> <Plug>HGStatus :HGStatus<CR> |
|
1052 | 1056 | nnoremap <silent> <Plug>HGUpdate :HGUpdate<CR> |
|
1053 | 1057 | nnoremap <silent> <Plug>HGVimDiff :HGVimDiff<CR> |
|
1054 | 1058 | |
|
1055 | 1059 | " Section: Default mappings {{{1 |
|
1056 | 1060 | if !hasmapto('<Plug>HGAdd') |
|
1057 | 1061 | nmap <unique> <Leader>hga <Plug>HGAdd |
|
1058 | 1062 | endif |
|
1059 | 1063 | if !hasmapto('<Plug>HGAnnotate') |
|
1060 | 1064 | nmap <unique> <Leader>hgn <Plug>HGAnnotate |
|
1061 | 1065 | endif |
|
1062 | 1066 | if !hasmapto('<Plug>HGClearAndGotoOriginal') |
|
1063 | 1067 | nmap <unique> <Leader>hgG <Plug>HGClearAndGotoOriginal |
|
1064 | 1068 | endif |
|
1065 | 1069 | if !hasmapto('<Plug>HGCommit') |
|
1066 | 1070 | nmap <unique> <Leader>hgc <Plug>HGCommit |
|
1067 | 1071 | endif |
|
1068 | 1072 | if !hasmapto('<Plug>HGDiff') |
|
1069 | 1073 | nmap <unique> <Leader>hgd <Plug>HGDiff |
|
1070 | 1074 | endif |
|
1071 | 1075 | if !hasmapto('<Plug>HGGotoOriginal') |
|
1072 | 1076 | nmap <unique> <Leader>hgg <Plug>HGGotoOriginal |
|
1073 | 1077 | endif |
|
1074 | 1078 | if !hasmapto('<Plug>HGLog') |
|
1075 | 1079 | nmap <unique> <Leader>hgl <Plug>HGLog |
|
1076 | 1080 | endif |
|
1077 | 1081 | if !hasmapto('<Plug>HGRevert') |
|
1078 | 1082 | nmap <unique> <Leader>hgq <Plug>HGRevert |
|
1079 | 1083 | endif |
|
1080 | 1084 | if !hasmapto('<Plug>HGReview') |
|
1081 | 1085 | nmap <unique> <Leader>hgr <Plug>HGReview |
|
1082 | 1086 | endif |
|
1083 | 1087 | if !hasmapto('<Plug>HGStatus') |
|
1084 | 1088 | nmap <unique> <Leader>hgs <Plug>HGStatus |
|
1085 | 1089 | endif |
|
1086 | 1090 | if !hasmapto('<Plug>HGUpdate') |
|
1087 | 1091 | nmap <unique> <Leader>hgu <Plug>HGUpdate |
|
1088 | 1092 | endif |
|
1089 | 1093 | if !hasmapto('<Plug>HGVimDiff') |
|
1090 | 1094 | nmap <unique> <Leader>hgv <Plug>HGVimDiff |
|
1091 | 1095 | endif |
|
1092 | 1096 | |
|
1093 | 1097 | " Section: Menu items {{{1 |
|
1094 | 1098 | silent! aunmenu Plugin.HG |
|
1095 | 1099 | amenu <silent> &Plugin.HG.&Add <Plug>HGAdd |
|
1096 | 1100 | amenu <silent> &Plugin.HG.A&nnotate <Plug>HGAnnotate |
|
1097 | 1101 | amenu <silent> &Plugin.HG.&Commit <Plug>HGCommit |
|
1098 | 1102 | amenu <silent> &Plugin.HG.&Diff <Plug>HGDiff |
|
1099 | 1103 | amenu <silent> &Plugin.HG.&Log <Plug>HGLog |
|
1100 | 1104 | amenu <silent> &Plugin.HG.Revert <Plug>HGRevert |
|
1101 | 1105 | amenu <silent> &Plugin.HG.&Review <Plug>HGReview |
|
1102 | 1106 | amenu <silent> &Plugin.HG.&Status <Plug>HGStatus |
|
1103 | 1107 | amenu <silent> &Plugin.HG.&Update <Plug>HGUpdate |
|
1104 | 1108 | amenu <silent> &Plugin.HG.&VimDiff <Plug>HGVimDiff |
|
1105 | 1109 | |
|
1106 | 1110 | " Section: Autocommands to restore vimdiff state {{{1 |
|
1107 | 1111 | function! s:HGVimDiffRestore(vimDiffBuff) |
|
1108 | 1112 | let s:HGCommandEditFileRunning = s:HGCommandEditFileRunning + 1 |
|
1109 | 1113 | try |
|
1110 | 1114 | if exists("s:vimDiffSourceBuffer") |
|
1111 | 1115 | if a:vimDiffBuff == s:vimDiffSourceBuffer |
|
1112 | 1116 | " Original file is being removed. |
|
1113 | 1117 | unlet! s:vimDiffSourceBuffer |
|
1114 | 1118 | unlet! s:vimDiffBufferCount |
|
1115 | 1119 | unlet! s:vimDiffRestoreCmd |
|
1116 | 1120 | unlet! s:vimDiffScratchList |
|
1117 | 1121 | elseif match(s:vimDiffScratchList, '{' . a:vimDiffBuff . '}') >= 0 |
|
1118 | 1122 | let s:vimDiffScratchList = substitute(s:vimDiffScratchList, '{' . a:vimDiffBuff . '}', '', '') |
|
1119 | 1123 | let s:vimDiffBufferCount = s:vimDiffBufferCount - 1 |
|
1120 | 1124 | if s:vimDiffBufferCount == 1 && exists('s:vimDiffRestoreCmd') |
|
1121 | 1125 | " All scratch buffers are gone, reset the original. |
|
1122 | 1126 | " Only restore if the source buffer is still in Diff mode |
|
1123 | 1127 | |
|
1124 | 1128 | let sourceWinNR=bufwinnr(s:vimDiffSourceBuffer) |
|
1125 | 1129 | if sourceWinNR != -1 |
|
1126 | 1130 | " The buffer is visible in at least one window |
|
1127 | 1131 | let currentWinNR = winnr() |
|
1128 | 1132 | while winbufnr(sourceWinNR) != -1 |
|
1129 | 1133 | if winbufnr(sourceWinNR) == s:vimDiffSourceBuffer |
|
1130 | 1134 | execute sourceWinNR . 'wincmd w' |
|
1131 | 1135 | if getwinvar('', "&diff") |
|
1132 | 1136 | execute s:vimDiffRestoreCmd |
|
1133 | 1137 | endif |
|
1134 | 1138 | endif |
|
1135 | 1139 | let sourceWinNR = sourceWinNR + 1 |
|
1136 | 1140 | endwhile |
|
1137 | 1141 | execute currentWinNR . 'wincmd w' |
|
1138 | 1142 | else |
|
1139 | 1143 | " The buffer is hidden. It must be visible in order to set the |
|
1140 | 1144 | " diff option. |
|
1141 | 1145 | let currentBufNR = bufnr('') |
|
1142 | 1146 | execute "hide buffer" s:vimDiffSourceBuffer |
|
1143 | 1147 | if getwinvar('', "&diff") |
|
1144 | 1148 | execute s:vimDiffRestoreCmd |
|
1145 | 1149 | endif |
|
1146 | 1150 | execute "hide buffer" currentBufNR |
|
1147 | 1151 | endif |
|
1148 | 1152 | |
|
1149 | 1153 | unlet s:vimDiffRestoreCmd |
|
1150 | 1154 | unlet s:vimDiffSourceBuffer |
|
1151 | 1155 | unlet s:vimDiffBufferCount |
|
1152 | 1156 | unlet s:vimDiffScratchList |
|
1153 | 1157 | elseif s:vimDiffBufferCount == 0 |
|
1154 | 1158 | " All buffers are gone. |
|
1155 | 1159 | unlet s:vimDiffSourceBuffer |
|
1156 | 1160 | unlet s:vimDiffBufferCount |
|
1157 | 1161 | unlet s:vimDiffScratchList |
|
1158 | 1162 | endif |
|
1159 | 1163 | endif |
|
1160 | 1164 | endif |
|
1161 | 1165 | finally |
|
1162 | 1166 | let s:HGCommandEditFileRunning = s:HGCommandEditFileRunning - 1 |
|
1163 | 1167 | endtry |
|
1164 | 1168 | endfunction |
|
1165 | 1169 | |
|
1166 | 1170 | augroup HGVimDiffRestore |
|
1167 | 1171 | au! |
|
1168 | 1172 | au BufUnload * call s:HGVimDiffRestore(expand("<abuf>")) |
|
1169 | 1173 | augroup END |
|
1170 | 1174 | |
|
1171 | 1175 | " Section: Optional activation of buffer management {{{1 |
|
1172 | 1176 | |
|
1173 |
if s:HGGetOption('HGCommandEnableBufferSetup', |
|
|
1177 | if s:HGGetOption('HGCommandEnableBufferSetup', 1) | |
|
1174 | 1178 | call HGEnableBufferSetup() |
|
1175 | 1179 | endif |
|
1176 | 1180 | |
|
1177 | 1181 | " Section: Doc installation {{{1 |
|
1178 | 1182 | " |
|
1179 | 1183 | let s:revision="0.1" |
|
1180 | 1184 | silent! let s:install_status = |
|
1181 | 1185 | \ s:HGInstallDocumentation(expand('<sfile>:p'), s:revision) |
|
1182 | 1186 | if (s:install_status == 1) |
|
1183 | 1187 | echom expand("<sfile>:t:r") . ' v' . s:revision . |
|
1184 | 1188 | \ ': Help-documentation installed.' |
|
1185 | 1189 | endif |
|
1186 | 1190 | |
|
1187 | 1191 | |
|
1188 | 1192 | " Section: Plugin completion {{{1 |
|
1189 | 1193 | |
|
1190 | 1194 | let loaded_hgcommand=2 |
|
1191 | 1195 | silent do HGCommand User HGPluginFinish |
|
1192 | 1196 | " vim:se expandtab sts=2 sw=2: |
|
1193 | 1197 | finish |
|
1194 | 1198 | |
|
1195 | 1199 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
|
1196 | 1200 | " Section: Documentation content {{{1 |
|
1197 | 1201 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
|
1198 | 1202 | === START_DOC |
|
1199 | 1203 | *hgcommand.txt* Mercurial vim integration #version# |
|
1200 | 1204 | |
|
1201 | 1205 | |
|
1202 | 1206 | HGCOMMAND REFERENCE MANUAL~ |
|
1203 | 1207 | |
|
1204 | 1208 | |
|
1205 | 1209 | Author: Mathieu Clabaut <mathieu.clabaut@gmail.com> |
|
1206 | 1210 | Credits: Bob Hiestand <bob.hiestand@gmail.com> |
|
1207 | 1211 | Mercurial: http://www.selenic.com/mercurial |
|
1208 | 1212 | Mercurial (noted Hg) is a fast, lightweight Source Control Management |
|
1209 | 1213 | system designed for efficient handling of very large distributed projects. |
|
1210 | 1214 | |
|
1211 | 1215 | ============================================================================== |
|
1212 | 1216 | 1. Contents *hgcommand-contents* |
|
1213 | 1217 | |
|
1214 | 1218 | Installation : |hgcommand-install| |
|
1215 | 1219 | HGCommand Intro : |hgcommand| |
|
1216 | 1220 | HGCommand Manual : |hgcommand-manual| |
|
1217 | 1221 | Customization : |hgcommand-customize| |
|
1218 | 1222 | Bugs : |hgcommand-bugs| |
|
1219 | 1223 | |
|
1220 | 1224 | ============================================================================== |
|
1221 | 1225 | 2. HGCommand Installation *hgcommand-install* |
|
1222 | 1226 | |
|
1223 | 1227 | In order to install the plugin, place the hgcommand.vim file into a plugin' |
|
1224 | 1228 | directory in your runtime path (please see |add-global-plugin| and |
|
1225 | 1229 | |'runtimepath'|. |
|
1226 | 1230 | |
|
1227 | 1231 | HGCommand may be customized by setting variables, creating maps, and |
|
1228 | 1232 | specifying event handlers. Please see |hgcommand-customize| for more |
|
1229 | 1233 | details. |
|
1230 | 1234 | |
|
1231 | 1235 | *hgcommand-auto-help* |
|
1232 | 1236 | The help file is automagically generated when the |hgcommand| script is |
|
1233 | 1237 | loaded for the first time. |
|
1234 | 1238 | |
|
1235 | 1239 | ============================================================================== |
|
1236 | 1240 | |
|
1237 | 1241 | 3. HGCommand Intro *hgcommand* |
|
1238 | 1242 | *hgcommand-intro* |
|
1239 | 1243 | |
|
1240 | 1244 | The HGCommand plugin provides global ex commands for manipulating |
|
1241 | 1245 | HG-controlled source files. In general, each command operates on the |
|
1242 | 1246 | current buffer and accomplishes a separate hg function, such as update, |
|
1243 | 1247 | commit, log, and others (please see |hgcommand-commands| for a list of all |
|
1244 | 1248 | available commands). The results of each operation are displayed in a |
|
1245 | 1249 | scratch buffer. Several buffer variables are defined for those scratch |
|
1246 | 1250 | buffers (please see |hgcommand-buffer-variables|). |
|
1247 | 1251 | |
|
1248 | 1252 | The notion of "current file" means either the current buffer, or, in the |
|
1249 | 1253 | case of a directory buffer, the file on the current line within the buffer. |
|
1250 | 1254 | |
|
1251 | 1255 | For convenience, any HGCommand invoked on a HGCommand scratch buffer acts |
|
1252 | 1256 | as though it was invoked on the original file and splits the screen so that |
|
1253 | 1257 | the output appears in a new window. |
|
1254 | 1258 | |
|
1255 | 1259 | Many of the commands accept revisions as arguments. By default, most |
|
1256 | 1260 | operate on the most recent revision on the current branch if no revision is |
|
1257 | 1261 | specified (though see |HGCommandInteractive| to prompt instead). |
|
1258 | 1262 | |
|
1259 | 1263 | Each HGCommand is mapped to a key sequence starting with the <Leader> |
|
1260 | 1264 | keystroke. The default mappings may be overridden by supplying different |
|
1261 | 1265 | mappings before the plugin is loaded, such as in the vimrc, in the standard |
|
1262 | 1266 | fashion for plugin mappings. For examples, please see |
|
1263 | 1267 | |hgcommand-mappings-override|. |
|
1264 | 1268 | |
|
1265 | 1269 | The HGCommand plugin may be configured in several ways. For more details, |
|
1266 | 1270 | please see |hgcommand-customize|. |
|
1267 | 1271 | |
|
1268 | 1272 | ============================================================================== |
|
1269 | 1273 | 4. HGCommand Manual *hgcommand-manual* |
|
1270 | 1274 | |
|
1271 | 1275 | 4.1 HGCommand commands *hgcommand-commands* |
|
1272 | 1276 | |
|
1273 | 1277 | HGCommand defines the following commands: |
|
1274 | 1278 | |
|
1275 | 1279 | |:HGAdd| |
|
1276 | 1280 | |:HGAnnotate| |
|
1277 | 1281 | |:HGCommit| |
|
1278 | 1282 | |:HGDiff| |
|
1279 | 1283 | |:HGGotoOriginal| |
|
1280 | 1284 | |:HGLog| |
|
1281 | 1285 | |:HGRevert| |
|
1282 | 1286 | |:HGReview| |
|
1283 | 1287 | |:HGStatus| |
|
1284 | 1288 | |:HGUpdate| |
|
1285 | 1289 | |:HGVimDiff| |
|
1286 | 1290 | |
|
1287 | 1291 | :HGAdd *:HGAdd* |
|
1288 | 1292 | |
|
1289 | 1293 | This command performs "hg add" on the current file. Please note, this does |
|
1290 | 1294 | not commit the newly-added file. |
|
1291 | 1295 | |
|
1292 | 1296 | :HGAnnotate *:HGAnnotate* |
|
1293 | 1297 | |
|
1294 | 1298 | This command performs "hg annotate" on the current file. If an argument is |
|
1295 | 1299 | given, the argument is used as a revision number to display. If not given |
|
1296 | 1300 | an argument, it uses the most recent version of the file on the current |
|
1297 | 1301 | branch. Additionally, if the current buffer is a HGAnnotate buffer |
|
1298 | 1302 | already, the version number on the current line is used. |
|
1299 | 1303 | |
|
1300 | 1304 | If the |HGCommandAnnotateParent| variable is set to a non-zero value, the |
|
1301 | 1305 | version previous to the one on the current line is used instead. This |
|
1302 | 1306 | allows one to navigate back to examine the previous version of a line. |
|
1303 | 1307 | |
|
1304 | 1308 | The filetype of the HGCommand scratch buffer is set to 'HGAnnotate', to |
|
1305 | 1309 | take advantage of the bundled syntax file. |
|
1306 | 1310 | |
|
1307 | 1311 | |
|
1308 | 1312 | :HGCommit[!] *:HGCommit* |
|
1309 | 1313 | |
|
1310 | 1314 | If called with arguments, this performs "hg commit" using the arguments as |
|
1311 | 1315 | the log message. |
|
1312 | 1316 | |
|
1313 | 1317 | If '!' is used with no arguments, an empty log message is committed. |
|
1314 | 1318 | |
|
1315 | 1319 | If called with no arguments, this is a two-step command. The first step |
|
1316 | 1320 | opens a buffer to accept a log message. When that buffer is written, it is |
|
1317 | 1321 | automatically closed and the file is committed using the information from |
|
1318 | 1322 | that log message. The commit can be abandoned if the log message buffer is |
|
1319 | 1323 | deleted or wiped before being written. |
|
1320 | 1324 | |
|
1321 | 1325 | Alternatively, the mapping that is used to invoke :HGCommit (by default |
|
1322 | 1326 | <Leader>hgc) can be used in the log message buffer to immediately commit. |
|
1323 | 1327 | This is useful if the |HGCommandCommitOnWrite| variable is set to 0 to |
|
1324 | 1328 | disable the normal commit-on-write behavior. |
|
1325 | 1329 | |
|
1326 | 1330 | :HGDiff *:HGDiff* |
|
1327 | 1331 | |
|
1328 | 1332 | With no arguments, this performs "hg diff" on the current file against the |
|
1329 | 1333 | current repository version. |
|
1330 | 1334 | |
|
1331 | 1335 | With one argument, "hg diff" is performed on the current file against the |
|
1332 | 1336 | specified revision. |
|
1333 | 1337 | |
|
1334 | 1338 | With two arguments, hg diff is performed between the specified revisions of |
|
1335 | 1339 | the current file. |
|
1336 | 1340 | |
|
1337 | 1341 | This command uses the 'HGCommandDiffOpt' variable to specify diff options. |
|
1338 | 1342 | If that variable does not exist, then 'wbBc' is assumed. If you wish to |
|
1339 | 1343 | have no options, then set it to the empty string. |
|
1340 | 1344 | |
|
1341 | 1345 | |
|
1342 | 1346 | :HGGotoOriginal *:HGGotoOriginal* |
|
1343 | 1347 | |
|
1344 | 1348 | This command returns the current window to the source buffer, if the |
|
1345 | 1349 | current buffer is a HG command output buffer. |
|
1346 | 1350 | |
|
1347 | 1351 | :HGGotoOriginal! |
|
1348 | 1352 | |
|
1349 | 1353 | Like ":HGGotoOriginal" but also executes :bufwipeout on all HG command |
|
1350 | 1354 | output buffers for the source buffer. |
|
1351 | 1355 | |
|
1352 | 1356 | :HGLog *:HGLog* |
|
1353 | 1357 | |
|
1354 | 1358 | Performs "hg log" on the current file. |
|
1355 | 1359 | |
|
1356 | 1360 | If an argument is given, it is passed as an argument to the "-r" option of |
|
1357 | 1361 | "hg log". |
|
1358 | 1362 | |
|
1359 | 1363 | :HGRevert *:HGRevert* |
|
1360 | 1364 | |
|
1361 | 1365 | Replaces the current file with the most recent version from the repository |
|
1362 | 1366 | in order to wipe out any undesired changes. |
|
1363 | 1367 | |
|
1364 | 1368 | :HGReview *:HGReview* |
|
1365 | 1369 | |
|
1366 | 1370 | Retrieves a particular version of the current file. If no argument is |
|
1367 | 1371 | given, the most recent version of the file on the current branch is |
|
1368 | 1372 | retrieved. Otherwise, the specified version is retrieved. |
|
1369 | 1373 | |
|
1370 | 1374 | :HGStatus *:HGStatus* |
|
1371 | 1375 | |
|
1372 | 1376 | Performs "hg status" on the current file. |
|
1373 | 1377 | |
|
1374 | 1378 | :HGUpdate *:HGUpdate* |
|
1375 | 1379 | |
|
1376 | 1380 | Performs "hg update" on the current file. This intentionally does not |
|
1377 | 1381 | automatically reload the current buffer, though vim should prompt the user |
|
1378 | 1382 | to do so if the underlying file is altered by this command. |
|
1379 | 1383 | |
|
1380 | 1384 | :HGVimDiff *:HGVimDiff* |
|
1381 | 1385 | |
|
1382 | 1386 | With no arguments, this prompts the user for a revision and then uses |
|
1383 | 1387 | vimdiff to display the differences between the current file and the |
|
1384 | 1388 | specified revision. If no revision is specified, the most recent version |
|
1385 | 1389 | of the file on the current branch is used. |
|
1386 | 1390 | |
|
1387 | 1391 | With one argument, that argument is used as the revision as above. With |
|
1388 | 1392 | two arguments, the differences between the two revisions is displayed using |
|
1389 | 1393 | vimdiff. |
|
1390 | 1394 | |
|
1391 | 1395 | With either zero or one argument, the original buffer is used to perform |
|
1392 | 1396 | the vimdiff. When the other buffer is closed, the original buffer will be |
|
1393 | 1397 | returned to normal mode. |
|
1394 | 1398 | |
|
1395 | 1399 | Once vimdiff mode is started using the above methods, additional vimdiff |
|
1396 | 1400 | buffers may be added by passing a single version argument to the command. |
|
1397 | 1401 | There may be up to 4 vimdiff buffers total. |
|
1398 | 1402 | |
|
1399 | 1403 | Using the 2-argument form of the command resets the vimdiff to only those 2 |
|
1400 | 1404 | versions. Additionally, invoking the command on a different file will |
|
1401 | 1405 | close the previous vimdiff buffers. |
|
1402 | 1406 | |
|
1403 | 1407 | |
|
1404 | 1408 | 4.2 Mappings *hgcommand-mappings* |
|
1405 | 1409 | |
|
1406 | 1410 | By default, a mapping is defined for each command. These mappings execute |
|
1407 | 1411 | the default (no-argument) form of each command. |
|
1408 | 1412 | |
|
1409 | 1413 | <Leader>hga HGAdd |
|
1410 | 1414 | <Leader>hgn HGAnnotate |
|
1411 | 1415 | <Leader>hgc HGCommit |
|
1412 | 1416 | <Leader>hgd HGDiff |
|
1413 | 1417 | <Leader>hgg HGGotoOriginal |
|
1414 | 1418 | <Leader>hgG HGGotoOriginal! |
|
1415 | 1419 | <Leader>hgl HGLog |
|
1416 | 1420 | <Leader>hgr HGReview |
|
1417 | 1421 | <Leader>hgs HGStatus |
|
1418 | 1422 | <Leader>hgu HGUpdate |
|
1419 | 1423 | <Leader>hgv HGVimDiff |
|
1420 | 1424 | |
|
1421 | 1425 | *hgcommand-mappings-override* |
|
1422 | 1426 | |
|
1423 | 1427 | The default mappings can be overriden by user-provided instead by mapping |
|
1424 | 1428 | to <Plug>CommandName. This is especially useful when these mappings |
|
1425 | 1429 | collide with other existing mappings (vim will warn of this during plugin |
|
1426 | 1430 | initialization, but will not clobber the existing mappings). |
|
1427 | 1431 | |
|
1428 | 1432 | For instance, to override the default mapping for :HGAdd to set it to |
|
1429 | 1433 | '\add', add the following to the vimrc: > |
|
1430 | 1434 | |
|
1431 | 1435 | nmap \add <Plug>HGAdd |
|
1432 | 1436 | < |
|
1433 | 1437 | 4.3 Automatic buffer variables *hgcommand-buffer-variables* |
|
1434 | 1438 | |
|
1435 | 1439 | Several buffer variables are defined in each HGCommand result buffer. |
|
1436 | 1440 | These may be useful for additional customization in callbacks defined in |
|
1437 | 1441 | the event handlers (please see |hgcommand-events|). |
|
1438 | 1442 | |
|
1439 | 1443 | The following variables are automatically defined: |
|
1440 | 1444 | |
|
1441 | 1445 | b:hgOrigBuffNR *b:hgOrigBuffNR* |
|
1442 | 1446 | |
|
1443 | 1447 | This variable is set to the buffer number of the source file. |
|
1444 | 1448 | |
|
1445 | 1449 | b:hgcmd *b:hgcmd* |
|
1446 | 1450 | |
|
1447 | 1451 | This variable is set to the name of the hg command that created the result |
|
1448 | 1452 | buffer. |
|
1449 | 1453 | ============================================================================== |
|
1450 | 1454 | |
|
1451 | 1455 | 5. Configuration and customization *hgcommand-customize* |
|
1452 | 1456 | *hgcommand-config* |
|
1453 | 1457 | |
|
1454 | 1458 | The HGCommand plugin can be configured in two ways: by setting |
|
1455 | 1459 | configuration variables (see |hgcommand-options|) or by defining HGCommand |
|
1456 | 1460 | event handlers (see |hgcommand-events|). Additionally, the HGCommand |
|
1457 | 1461 | plugin provides several option for naming the HG result buffers (see |
|
1458 | 1462 | |hgcommand-naming|) and supported a customized status line (see |
|
1459 | 1463 | |hgcommand-statusline| and |hgcommand-buffer-management|). |
|
1460 | 1464 | |
|
1461 | 1465 | 5.1 HGCommand configuration variables *hgcommand-options* |
|
1462 | 1466 | |
|
1463 | 1467 | Several variables affect the plugin's behavior. These variables are |
|
1464 | 1468 | checked at time of execution, and may be defined at the window, buffer, or |
|
1465 | 1469 | global level and are checked in that order of precedence. |
|
1466 | 1470 | |
|
1467 | 1471 | |
|
1468 | 1472 | The following variables are available: |
|
1469 | 1473 | |
|
1470 | 1474 | |HGCommandAnnotateParent| |
|
1471 | 1475 | |HGCommandCommitOnWrite| |
|
1472 | 1476 | |HGCommandHGExec| |
|
1473 | 1477 | |HGCommandDeleteOnHide| |
|
1474 | 1478 | |HGCommandDiffOpt| |
|
1475 | 1479 | |HGCommandDiffSplit| |
|
1476 | 1480 | |HGCommandEdit| |
|
1477 | 1481 | |HGCommandEnableBufferSetup| |
|
1478 | 1482 | |HGCommandInteractive| |
|
1479 | 1483 | |HGCommandNameMarker| |
|
1480 | 1484 | |HGCommandNameResultBuffers| |
|
1481 | 1485 | |HGCommandSplit| |
|
1482 | 1486 | |
|
1483 | 1487 | HGCommandAnnotateParent *HGCommandAnnotateParent* |
|
1484 | 1488 | |
|
1485 | 1489 | This variable, if set to a non-zero value, causes the zero-argument form of |
|
1486 | 1490 | HGAnnotate when invoked on a HGAnnotate buffer to go to the version |
|
1487 | 1491 | previous to that displayed on the current line. If not set, it defaults to |
|
1488 | 1492 | 0. |
|
1489 | 1493 | |
|
1490 | 1494 | HGCommandCommitOnWrite *HGCommandCommitOnWrite* |
|
1491 | 1495 | |
|
1492 | 1496 | This variable, if set to a non-zero value, causes the pending hg commit to |
|
1493 | 1497 | take place immediately as soon as the log message buffer is written. If |
|
1494 | 1498 | set to zero, only the HGCommit mapping will cause the pending commit to |
|
1495 | 1499 | occur. If not set, it defaults to 1. |
|
1496 | 1500 | |
|
1497 | 1501 | HGCommandHGExec *HGCommandHGExec* |
|
1498 | 1502 | |
|
1499 | 1503 | This variable controls the executable used for all HG commands. If not |
|
1500 | 1504 | set, it defaults to "hg". |
|
1501 | 1505 | |
|
1502 | 1506 | HGCommandDeleteOnHide *HGCommandDeleteOnHide* |
|
1503 | 1507 | |
|
1504 | 1508 | This variable, if set to a non-zero value, causes the temporary HG result |
|
1505 | 1509 | buffers to automatically delete themselves when hidden. |
|
1506 | 1510 | |
|
1507 | 1511 | HGCommandDiffOpt *HGCommandDiffOpt* |
|
1508 | 1512 | |
|
1509 | 1513 | This variable, if set, determines the options passed to the diff command of |
|
1510 | 1514 | HG. If not set, it defaults to 'w'. |
|
1511 | 1515 | |
|
1512 | 1516 | HGCommandDiffSplit *HGCommandDiffSplit* |
|
1513 | 1517 | |
|
1514 | 1518 | This variable overrides the |HGCommandSplit| variable, but only for buffers |
|
1515 | 1519 | created with |:HGVimDiff|. |
|
1516 | 1520 | |
|
1517 | 1521 | HGCommandEdit *HGCommandEdit* |
|
1518 | 1522 | |
|
1519 | 1523 | This variable controls whether the original buffer is replaced ('edit') or |
|
1520 | 1524 | split ('split'). If not set, it defaults to 'edit'. |
|
1521 | 1525 | |
|
1522 | 1526 | HGCommandEnableBufferSetup *HGCommandEnableBufferSetup* |
|
1523 | 1527 | |
|
1524 | 1528 | This variable, if set to a non-zero value, activates HG buffer management |
|
1525 | 1529 | mode see (|hgcommand-buffer-management|). This mode means that three |
|
1526 | 1530 | buffer variables, 'HGRepository', 'HGRevision' and 'HGBranch', are set if |
|
1527 | 1531 | the file is HG-controlled. This is useful for displaying version |
|
1528 | 1532 | information in the status bar. |
|
1529 | 1533 | |
|
1530 | 1534 | HGCommandInteractive *HGCommandInteractive* |
|
1531 | 1535 | |
|
1532 | 1536 | This variable, if set to a non-zero value, causes appropriate commands (for |
|
1533 | 1537 | the moment, only |:HGReview|) to query the user for a revision to use |
|
1534 | 1538 | instead of the current revision if none is specified. |
|
1535 | 1539 | |
|
1536 | 1540 | HGCommandNameMarker *HGCommandNameMarker* |
|
1537 | 1541 | |
|
1538 | 1542 | This variable, if set, configures the special attention-getting characters |
|
1539 | 1543 | that appear on either side of the hg buffer type in the buffer name. This |
|
1540 | 1544 | has no effect unless |HGCommandNameResultBuffers| is set to a true value. |
|
1541 | 1545 | If not set, it defaults to '_'. |
|
1542 | 1546 | |
|
1543 | 1547 | HGCommandNameResultBuffers *HGCommandNameResultBuffers* |
|
1544 | 1548 | |
|
1545 | 1549 | This variable, if set to a true value, causes the hg result buffers to be |
|
1546 | 1550 | named in the old way ('<source file name> _<hg command>_'). If not set or |
|
1547 | 1551 | set to a false value, the result buffer is nameless. |
|
1548 | 1552 | |
|
1549 | 1553 | HGCommandSplit *HGCommandSplit* |
|
1550 | 1554 | |
|
1551 | 1555 | This variable controls the orientation of the various window splits that |
|
1552 | 1556 | may occur (such as with HGVimDiff, when using a HG command on a HG command |
|
1553 | 1557 | buffer, or when the |HGCommandEdit| variable is set to 'split'. If set to |
|
1554 | 1558 | 'horizontal', the resulting windows will be on stacked on top of one |
|
1555 | 1559 | another. If set to 'vertical', the resulting windows will be side-by-side. |
|
1556 | 1560 | If not set, it defaults to 'horizontal' for all but HGVimDiff windows. |
|
1557 | 1561 | |
|
1558 | 1562 | 5.2 HGCommand events *hgcommand-events* |
|
1559 | 1563 | |
|
1560 | 1564 | For additional customization, HGCommand can trigger user-defined events. |
|
1561 | 1565 | Event handlers are provided by defining User event autocommands (see |
|
1562 | 1566 | |autocommand|, |User|) in the HGCommand group with patterns matching the |
|
1563 | 1567 | event name. |
|
1564 | 1568 | |
|
1565 | 1569 | For instance, the following could be added to the vimrc to provide a 'q' |
|
1566 | 1570 | mapping to quit a HGCommand scratch buffer: > |
|
1567 | 1571 | |
|
1568 | 1572 | augroup HGCommand |
|
1569 | 1573 | au HGCommand User HGBufferCreated silent! nmap <unique> <buffer> q: |
|
1570 | 1574 | bwipeout<cr> |
|
1571 | 1575 | augroup END |
|
1572 | 1576 | < |
|
1573 | 1577 | |
|
1574 | 1578 | The following hooks are available: |
|
1575 | 1579 | |
|
1576 | 1580 | HGBufferCreated This event is fired just after a hg command result |
|
1577 | 1581 | buffer is created and filled with the result of a hg |
|
1578 | 1582 | command. It is executed within the context of the HG |
|
1579 | 1583 | command buffer. The HGCommand buffer variables may be |
|
1580 | 1584 | useful for handlers of this event (please see |
|
1581 | 1585 | |hgcommand-buffer-variables|). |
|
1582 | 1586 | |
|
1583 | 1587 | HGBufferSetup This event is fired just after HG buffer setup occurs, |
|
1584 | 1588 | if enabled. |
|
1585 | 1589 | |
|
1586 | 1590 | HGPluginInit This event is fired when the HGCommand plugin first |
|
1587 | 1591 | loads. |
|
1588 | 1592 | |
|
1589 | 1593 | HGPluginFinish This event is fired just after the HGCommand plugin |
|
1590 | 1594 | loads. |
|
1591 | 1595 | |
|
1592 | 1596 | HGVimDiffFinish This event is fired just after the HGVimDiff command |
|
1593 | 1597 | executes to allow customization of, for instance, |
|
1594 | 1598 | window placement and focus. |
|
1595 | 1599 | |
|
1596 | 1600 | 5.3 HGCommand buffer naming *hgcommand-naming* |
|
1597 | 1601 | |
|
1598 | 1602 | By default, the buffers containing the result of HG commands are nameless |
|
1599 | 1603 | scratch buffers. It is intended that buffer variables of those buffers be |
|
1600 | 1604 | used to customize the statusline option so that the user may fully control |
|
1601 | 1605 | the display of result buffers. |
|
1602 | 1606 | |
|
1603 | 1607 | If the old-style naming is desired, please enable the |
|
1604 | 1608 | |HGCommandNameResultBuffers| variable. Then, each result buffer will |
|
1605 | 1609 | receive a unique name that includes the source file name, the HG command, |
|
1606 | 1610 | and any extra data (such as revision numbers) that were part of the |
|
1607 | 1611 | command. |
|
1608 | 1612 | |
|
1609 | 1613 | 5.4 HGCommand status line support *hgcommand-statusline* |
|
1610 | 1614 | |
|
1611 | 1615 | It is intended that the user will customize the |'statusline'| option to |
|
1612 | 1616 | include HG result buffer attributes. A sample function that may be used in |
|
1613 | 1617 | the |'statusline'| option is provided by the plugin, HGGetStatusLine(). In |
|
1614 | 1618 | order to use that function in the status line, do something like the |
|
1615 | 1619 | following: > |
|
1616 | 1620 | |
|
1617 | 1621 | set statusline=%<%f\ %{HGGetStatusLine()}\ %h%m%r%=%l,%c%V\ %P |
|
1618 | 1622 | < |
|
1619 | 1623 | of which %{HGGetStatusLine()} is the relevant portion. |
|
1620 | 1624 | |
|
1621 | 1625 | The sample HGGetStatusLine() function handles both HG result buffers and |
|
1622 | 1626 | HG-managed files if HGCommand buffer management is enabled (please see |
|
1623 | 1627 | |hgcommand-buffer-management|). |
|
1624 | 1628 | |
|
1625 | 1629 | 5.5 HGCommand buffer management *hgcommand-buffer-management* |
|
1626 | 1630 | |
|
1627 | 1631 | The HGCommand plugin can operate in buffer management mode, which means |
|
1628 | 1632 | that it attempts to set two buffer variables ('HGRevision' and 'HGBranch') |
|
1629 | 1633 | upon entry into a buffer. This is rather slow because it means that 'hg |
|
1630 | 1634 | status' will be invoked at each entry into a buffer (during the |BufEnter| |
|
1631 | 1635 | autocommand). |
|
1632 | 1636 | |
|
1633 |
This mode is |
|
|
1634 |
|HGCommandEnableBufferSetup| variable to a |
|
|
1637 | This mode is enablmed by default. In order to disable it, set the | |
|
1638 | |HGCommandEnableBufferSetup| variable to a false (zero) value. Enabling | |
|
1635 | 1639 | this mode simply provides the buffer variables mentioned above. The user |
|
1636 | 1640 | must explicitly include those in the |'statusline'| option if they are to |
|
1637 | 1641 | appear in the status line (but see |hgcommand-statusline| for a simple way |
|
1638 | 1642 | to do that). |
|
1639 | 1643 | |
|
1640 | 1644 | ============================================================================== |
|
1641 | 1645 | 9. Tips *hgcommand-tips* |
|
1642 | 1646 | |
|
1643 | 1647 | 9.1 Split window annotation, by Michael Anderson > |
|
1644 | 1648 | |
|
1645 | 1649 | :nmap <Leader>hgN :vs<CR><C-w>h<Leader>hgn:vertical res 40<CR> |
|
1646 | 1650 | \ggdddd:set scb<CR>:set nowrap<CR><C-w>lgg:set scb<CR> |
|
1647 | 1651 | \:set nowrap<CR> |
|
1648 | 1652 | < |
|
1649 | 1653 | |
|
1650 | 1654 | This splits the buffer vertically, puts an annotation on the left (minus |
|
1651 | 1655 | the header) with the width set to 40. An editable/normal copy is placed on |
|
1652 | 1656 | the right. The two versions are scroll locked so they move as one. and |
|
1653 | 1657 | wrapping is turned off so that the lines line up correctly. The advantages |
|
1654 | 1658 | are... |
|
1655 | 1659 | |
|
1656 | 1660 | 1) You get a versioning on the right. |
|
1657 | 1661 | 2) You can still edit your own code. |
|
1658 | 1662 | 3) Your own code still has syntax highlighting. |
|
1659 | 1663 | |
|
1660 | 1664 | ============================================================================== |
|
1661 | 1665 | |
|
1662 | 1666 | 8. Known bugs *hgcommand-bugs* |
|
1663 | 1667 | |
|
1664 | 1668 | Please let me know if you run across any. |
|
1665 | 1669 | |
|
1666 | 1670 | HGVimDiff, when using the original (real) source buffer as one of the diff |
|
1667 | 1671 | buffers, uses some hacks to try to restore the state of the original buffer |
|
1668 | 1672 | when the scratch buffer containing the other version is destroyed. There |
|
1669 | 1673 | may still be bugs in here, depending on many configuration details. |
|
1670 | 1674 | |
|
1671 | 1675 | ============================================================================== |
|
1672 | 1676 | === END_DOC |
|
1673 | 1677 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
|
1674 | 1678 | " v im:tw=78:ts=8:ft=help:norl: |
|
1675 | 1679 | " vim600: set foldmethod=marker tabstop=8 shiftwidth=2 softtabstop=2 smartindent smarttab : |
|
1676 | 1680 | "fileencoding=iso-8859-15 |
General Comments 0
You need to be logged in to leave comments.
Login now