author | Matt Mackall <mpm@selenic.com> |
Wed, 03 Jun 2009 17:07:41 -0500 | |
changeset 8711 | 1b95c6f13155 |
parent 2350 | 091d555653a4 |
child 10545 | b9e4a67329cd |
permissions | -rw-r--r-- |
2350
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
1 |
" Vim global plugin for doing single or multipatch code reviews"{{{ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
2 |
|
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
3 |
" Version : 0.1 "{{{ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
4 |
" Last Modified : Thu 25 May 2006 10:15:11 PM PDT |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
5 |
" Author : Manpreet Singh (junkblocker AT yahoo DOT com) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
6 |
" Copyright : 2006 by Manpreet Singh |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
7 |
" License : This file is placed in the public domain. |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
8 |
" |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
9 |
" History : 0.1 - First released |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
10 |
"}}} |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
11 |
" Documentation: "{{{ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
12 |
" =========================================================================== |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
13 |
" This plugin allows single or multipatch code reviews to be done in VIM. Vim |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
14 |
" has :diffpatch command to do single file reviews but can not handle patch |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
15 |
" files containing multiple patches. This plugin provides that missing |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
16 |
" functionality and doesn't require the original file to be open. |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
17 |
" |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
18 |
" Installing: "{{{ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
19 |
" |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
20 |
" For a quick start... |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
21 |
" |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
22 |
" Requirements: "{{{ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
23 |
" |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
24 |
" 1) (g)vim 7.0 or higher built with +diff option. |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
25 |
" 2) patch and patchutils ( http://cyberelk.net/tim/patchutils/ ) installed |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
26 |
" for your OS. For windows it is availble from Cygwin ( |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
27 |
" http://www.cygwin.com ) or GnuWin32 ( http://gnuwin32.sourceforge.net/ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
28 |
" ). |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
29 |
""}}} |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
30 |
" Install: "{{{ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
31 |
" |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
32 |
" 1) Extract this in your $VIM/vimfiles or $HOME/.vim directory and restart |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
33 |
" vim. |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
34 |
" |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
35 |
" 2) Make sure that you have filterdiff from patchutils and patch commands |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
36 |
" installed. |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
37 |
" |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
38 |
" 3) Optinally, specify the locations to filterdiff and patch commands and |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
39 |
" location of a temporary directory to use in your .vimrc. |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
40 |
" |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
41 |
" let g:patchreview_filterdiff = '/path/to/filterdiff' |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
42 |
" let g:patchreview_patch = '/path/to/patch' |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
43 |
" let g:patchreview_tmpdir = '/tmp/or/something' |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
44 |
" |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
45 |
" 4) Optionally, generate help tags to use help |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
46 |
" |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
47 |
" :helptags ~/.vim/doc |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
48 |
" or |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
49 |
" :helptags c:\vim\vimfiles\doc |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
50 |
""}}} |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
51 |
""}}} |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
52 |
" Usage: "{{{ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
53 |
" |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
54 |
" :PatchReview path_to_submitted_patchfile [optional_source_directory] |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
55 |
" |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
56 |
" after review is done |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
57 |
" |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
58 |
" :PatchReviewCleanup |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
59 |
" |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
60 |
" See :help patchreview for details after you've created help tags. |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
61 |
""}}} |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
62 |
"}}} |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
63 |
" Code "{{{ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
64 |
|
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
65 |
" Enabled only during development "{{{ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
66 |
" unlet! g:loaded_patchreview " DEBUG |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
67 |
" unlet! g:patchreview_tmpdir " DEBUG |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
68 |
" unlet! g:patchreview_filterdiff " DEBUG |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
69 |
" unlet! g:patchreview_patch " DEBUG |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
70 |
"}}} |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
71 |
|
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
72 |
" load only once "{{{ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
73 |
if exists('g:loaded_patchreview') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
74 |
finish |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
75 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
76 |
let g:loaded_patchreview=1 |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
77 |
let s:msgbufname = 'Patch Review Messages' |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
78 |
"}}} |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
79 |
|
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
80 |
function! <SID>PR_wipeMsgBuf() "{{{ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
81 |
let s:winnum = bufwinnr(s:msgbufname) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
82 |
if s:winnum != -1 " If the window is already open, jump to it |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
83 |
let s:cur_winnr = winnr() |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
84 |
if winnr() != s:winnum |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
85 |
exe s:winnum . 'wincmd w' |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
86 |
exe 'bw' |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
87 |
exe s:cur_winnr . 'wincmd w' |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
88 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
89 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
90 |
endfunction |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
91 |
"}}} |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
92 |
|
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
93 |
function! <SID>PR_echo(...) "{{{ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
94 |
" Usage: PR_echo(msg, [return_to_original_window_flag]) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
95 |
" default return_to_original_window_flag = 0 |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
96 |
" |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
97 |
let s:cur_winnr = winnr() |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
98 |
let s:winnum = bufwinnr(s:msgbufname) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
99 |
if s:winnum != -1 " If the window is already open, jump to it |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
100 |
if winnr() != s:winnum |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
101 |
exe s:winnum . 'wincmd w' |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
102 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
103 |
else |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
104 |
let s:bufnum = bufnr(s:msgbufname) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
105 |
if s:bufnum == -1 |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
106 |
let s:wcmd = s:msgbufname |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
107 |
else |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
108 |
let s:wcmd = '+buffer' . s:bufnum |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
109 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
110 |
exe 'silent! botright 5split ' . s:wcmd |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
111 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
112 |
setlocal modifiable |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
113 |
setlocal buftype=nofile |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
114 |
setlocal bufhidden=delete |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
115 |
setlocal noswapfile |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
116 |
setlocal nowrap |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
117 |
setlocal nobuflisted |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
118 |
if a:0 != 0 |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
119 |
silent! $put =a:1 |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
120 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
121 |
exe ':$' |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
122 |
setlocal nomodifiable |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
123 |
if a:0 > 1 && a:2 |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
124 |
exe s:cur_winnr . 'wincmd w' |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
125 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
126 |
endfunction |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
127 |
"}}} |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
128 |
|
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
129 |
function! <SID>PR_checkBinary(BinaryName) "{{{ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
130 |
" Verify that BinaryName is specified or available |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
131 |
if ! exists('g:patchreview_' . a:BinaryName) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
132 |
if executable(a:BinaryName) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
133 |
let g:patchreview_{a:BinaryName} = a:BinaryName |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
134 |
return 1 |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
135 |
else |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
136 |
call s:PR_echo('g:patchreview_' . a:BinaryName . ' is not defined and could not be found on path. Please define it in your .vimrc.') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
137 |
return 0 |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
138 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
139 |
elseif ! executable(g:patchreview_{a:BinaryName}) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
140 |
call s:PR_echo('Specified g:patchreview_' . a:BinaryName . ' [' . g:patchreview_{a.BinaryName} . '] is not executable.') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
141 |
return 0 |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
142 |
else |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
143 |
return 1 |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
144 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
145 |
endfunction |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
146 |
"}}} |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
147 |
|
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
148 |
function! <SID>PR_GetTempDirLocation(Quiet) "{{{ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
149 |
if exists('g:patchreview_tmpdir') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
150 |
if ! isdirectory(g:patchreview_tmpdir) || ! filewritable(g:patchreview_tmpdir) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
151 |
if ! a:Quiet |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
152 |
call s:PR_echo('Temporary directory specified by g:patchreview_tmpdir [' . g:patchreview_tmpdir . '] is not accessible.') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
153 |
return 0 |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
154 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
155 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
156 |
elseif exists("$TMP") && isdirectory($TMP) && filewritable($TMP) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
157 |
let g:patchreview_tmpdir = $TMP |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
158 |
elseif exists("$TEMP") && isdirectory($TEMP) && filewritable($TEMP) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
159 |
let g:patchreview_tmpdir = $TEMP |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
160 |
elseif exists("$TMPDIR") && isdirectory($TMPDIR) && filewritable($TMPDIR) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
161 |
let g:patchreview_tmpdir = $TMPDIR |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
162 |
else |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
163 |
if ! a:Quiet |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
164 |
call s:PR_echo('Could not figure out a temporary directory to use. Please specify g:patchreview_tmpdir in your .vimrc.') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
165 |
return 0 |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
166 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
167 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
168 |
let g:patchreview_tmpdir = g:patchreview_tmpdir . '/' |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
169 |
let g:patchreview_tmpdir = substitute(g:patchreview_tmpdir, '\\', '/', 'g') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
170 |
let g:patchreview_tmpdir = substitute(g:patchreview_tmpdir, '/+$', '/', '') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
171 |
if has('win32') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
172 |
let g:patchreview_tmpdir = substitute(g:patchreview_tmpdir, '/', '\\', 'g') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
173 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
174 |
return 1 |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
175 |
endfunction |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
176 |
"}}} |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
177 |
|
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
178 |
function! <SID>PatchReview(...) "{{{ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
179 |
" VIM 7+ required"{{{ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
180 |
if version < 700 |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
181 |
call s:PR_echo('This plugin needs VIM 7 or higher') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
182 |
return |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
183 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
184 |
"}}} |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
185 |
|
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
186 |
let s:save_shortmess = &shortmess |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
187 |
set shortmess+=aW |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
188 |
call s:PR_wipeMsgBuf() |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
189 |
|
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
190 |
" Check passed arguments "{{{ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
191 |
if a:0 == 0 |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
192 |
call s:PR_echo('PatchReview command needs at least one argument specifying a patchfile path.') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
193 |
let &shortmess = s:save_shortmess |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
194 |
return |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
195 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
196 |
if a:0 >= 1 && a:0 <= 2 |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
197 |
let s:PatchFilePath = expand(a:1, ':p') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
198 |
if ! filereadable(s:PatchFilePath) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
199 |
call s:PR_echo('File [' . s:PatchFilePath . '] is not accessible.') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
200 |
let &shortmess = s:save_shortmess |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
201 |
return |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
202 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
203 |
if a:0 == 2 |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
204 |
let s:SrcDirectory = expand(a:2, ':p') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
205 |
if ! isdirectory(s:SrcDirectory) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
206 |
call s:PR_echo('[' . s:SrcDirectory . '] is not a directory') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
207 |
let &shortmess = s:save_shortmess |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
208 |
return |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
209 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
210 |
try |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
211 |
exe 'cd ' . s:SrcDirectory |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
212 |
catch /^.*E344.*/ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
213 |
call s:PR_echo('Could not change to directory [' . s:SrcDirectory . ']') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
214 |
let &shortmess = s:save_shortmess |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
215 |
return |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
216 |
endtry |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
217 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
218 |
else |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
219 |
call s:PR_echo('PatchReview command needs at most two arguments: patchfile path and optional source directory path.') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
220 |
let &shortmess = s:save_shortmess |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
221 |
return |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
222 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
223 |
"}}} |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
224 |
|
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
225 |
" Verify that filterdiff and patch are specified or available "{{{ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
226 |
if ! s:PR_checkBinary('filterdiff') || ! s:PR_checkBinary('patch') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
227 |
let &shortmess = s:save_shortmess |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
228 |
return |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
229 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
230 |
|
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
231 |
let s:retval = s:PR_GetTempDirLocation(0) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
232 |
if ! s:retval |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
233 |
let &shortmess = s:save_shortmess |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
234 |
return |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
235 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
236 |
"}}} |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
237 |
|
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
238 |
" Requirements met, now execute "{{{ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
239 |
let s:PatchFilePath = fnamemodify(s:PatchFilePath, ':p') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
240 |
call s:PR_echo('Patch file : ' . s:PatchFilePath) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
241 |
call s:PR_echo('Source directory: ' . getcwd()) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
242 |
call s:PR_echo('------------------') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
243 |
let s:theFilterDiffCommand = '' . g:patchreview_filterdiff . ' --list -s ' . s:PatchFilePath |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
244 |
let s:theFilesString = system(s:theFilterDiffCommand) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
245 |
let s:theFilesList = split(s:theFilesString, '[\r\n]') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
246 |
for s:filewithchangetype in s:theFilesList |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
247 |
if s:filewithchangetype !~ '^[!+-] ' |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
248 |
call s:PR_echo('*** Skipping review generation due to understood change for [' . s:filewithchangetype . ']', 1) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
249 |
continue |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
250 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
251 |
unlet! s:RelativeFilePath |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
252 |
let s:RelativeFilePath = substitute(s:filewithchangetype, '^. ', '', '') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
253 |
let s:RelativeFilePath = substitute(s:RelativeFilePath, '^[a-z][^\\\/]*[\\\/]' , '' , '') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
254 |
if s:filewithchangetype =~ '^! ' |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
255 |
let s:msgtype = 'Modification : ' |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
256 |
elseif s:filewithchangetype =~ '^+ ' |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
257 |
let s:msgtype = 'Addition : ' |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
258 |
elseif s:filewithchangetype =~ '^- ' |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
259 |
let s:msgtype = 'Deletion : ' |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
260 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
261 |
let s:bufnum = bufnr(s:RelativeFilePath) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
262 |
if buflisted(s:bufnum) && getbufvar(s:bufnum, '&mod') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
263 |
call s:PR_echo('Old buffer for file [' . s:RelativeFilePath . '] exists in modified state. Skipping review.', 1) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
264 |
continue |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
265 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
266 |
let s:tmpname = substitute(s:RelativeFilePath, '/', '_', 'g') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
267 |
let s:tmpname = substitute(s:tmpname, '\\', '_', 'g') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
268 |
let s:tmpname = g:patchreview_tmpdir . 'PatchReview.' . s:tmpname . '.' . strftime('%Y%m%d%H%M%S') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
269 |
if has('win32') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
270 |
let s:tmpname = substitute(s:tmpname, '/', '\\', 'g') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
271 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
272 |
if ! exists('s:patchreview_tmpfiles') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
273 |
let s:patchreview_tmpfiles = [] |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
274 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
275 |
let s:patchreview_tmpfiles = s:patchreview_tmpfiles + [s:tmpname] |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
276 |
|
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
277 |
let s:filterdiffcmd = '!' . g:patchreview_filterdiff . ' -i ' . s:RelativeFilePath . ' ' . s:PatchFilePath . ' > ' . s:tmpname |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
278 |
silent! exe s:filterdiffcmd |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
279 |
if s:filewithchangetype =~ '^+ ' |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
280 |
if has('win32') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
281 |
let s:inputfile = 'nul' |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
282 |
else |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
283 |
let s:inputfile = '/dev/null' |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
284 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
285 |
else |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
286 |
let s:inputfile = expand(s:RelativeFilePath, ':p') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
287 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
288 |
silent exe '!' . g:patchreview_patch . ' -o ' . s:tmpname . '.file ' . s:inputfile . ' < ' . s:tmpname |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
289 |
let s:origtabpagenr = tabpagenr() |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
290 |
silent! exe 'tabedit ' . s:RelativeFilePath |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
291 |
silent! exe 'vert diffsplit ' . s:tmpname . '.file' |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
292 |
if filereadable(s:tmpname . '.file.rej') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
293 |
silent! exe 'topleft 5split ' . s:tmpname . '.file.rej' |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
294 |
call s:PR_echo(s:msgtype . '*** REJECTED *** ' . s:RelativeFilePath, 1) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
295 |
else |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
296 |
call s:PR_echo(s:msgtype . ' ' . s:RelativeFilePath, 1) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
297 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
298 |
silent! exe 'tabn ' . s:origtabpagenr |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
299 |
endfor |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
300 |
call s:PR_echo('-----') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
301 |
call s:PR_echo('Done.') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
302 |
let &shortmess = s:save_shortmess |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
303 |
"}}} |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
304 |
endfunction |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
305 |
"}}} |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
306 |
|
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
307 |
function! <SID>PatchReviewCleanup() "{{{ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
308 |
let s:retval = s:PR_GetTempDirLocation(1) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
309 |
if s:retval && exists('g:patchreview_tmpdir') && isdirectory(g:patchreview_tmpdir) && filewritable(g:patchreview_tmpdir) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
310 |
let s:zefilestr = globpath(g:patchreview_tmpdir, 'PatchReview.*') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
311 |
let s:theFilesList = split(s:zefilestr, '\m[\r\n]\+') |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
312 |
for s:thefile in s:theFilesList |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
313 |
call delete(s:thefile) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
314 |
endfor |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
315 |
endif |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
316 |
endfunction |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
317 |
"}}} |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
318 |
|
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
319 |
" Commands "{{{ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
320 |
"============================================================================ |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
321 |
" :PatchReview |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
322 |
command! -nargs=* -complete=file PatchReview call s:PatchReview (<f-args>) |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
323 |
|
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
324 |
|
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
325 |
" :PatchReviewCleanup |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
326 |
command! -nargs=0 PatchReviewCleanup call s:PatchReviewCleanup () |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
327 |
"}}} |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
328 |
"}}} |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
329 |
|
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
330 |
" vim: textwidth=78 nowrap tabstop=2 shiftwidth=2 softtabstop=2 expandtab |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
331 |
" vim: filetype=vim encoding=latin1 fileformat=unix foldlevel=0 foldmethod=marker |
091d555653a4
contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff
changeset
|
332 |
"}}} |