annotate contrib/vim/patchreview.vim @ 14601:25c1f3ddd927

dispatch: propagate ui command options to the local ui (issue2523) so the ui object passed to pre/post python hooks has the verbose flag (and the rest) set correctly
author Idan Kamara <idankk86@gmail.com>
date Mon, 13 Jun 2011 00:19:26 +0300
parents 8036bc1871c2
children e7cfe3587ea4 223328c6f943
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
1 " VIM plugin for doing single, multi-patch or diff code reviews {{{
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
2 " Home: http://www.vim.org/scripts/script.php?script_id=1563
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
3
10550
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
4 " Version : 0.2.2 "{{{
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
5 " Author : Manpreet Singh < junkblocker@yahoo.com >
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
6 " Copyright : 2006-2010 by Manpreet Singh
2350
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.
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
8 " No warranties express or implied. Use at your own risk.
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
9 "
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
10 " Changelog :
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
11 "
10550
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
12 " 0.2.2 - Security fixes by removing custom tempfile creation
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
13 " - Removed need for DiffReviewCleanup/PatchReviewCleanup
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
14 " - Better command execution error detection and display
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
15 " - Improved diff view and folding by ignoring modelines
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
16 " - Improved tab labels display
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
17 "
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
18 " 0.2.1 - Minor temp directory autodetection logic and cleanup
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
19 "
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
20 " 0.2 - Removed the need for filterdiff by implemeting it in pure vim script
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
21 " - Added DiffReview command for reverse (changed repository to
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
22 " pristine state) reviews.
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
23 " (PatchReview does pristine repository to patch review)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
24 " - DiffReview does automatic detection and generation of diffs for
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
25 " various Source Control systems
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
26 " - Skip load if VIM 7.0 or higher unavailable
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
27 "
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
28 " 0.1 - First released
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
29 "}}}
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
30
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
31 " Documentation: "{{{
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
32 " ===========================================================================
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
33 " This plugin allows single or multiple, patch or diff based code reviews to
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
34 " be easily done in VIM. VIM has :diffpatch command to do single file reviews
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
35 " but a) can not handle patch files containing multiple patches or b) do
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
36 " automated diff generation for various version control systems. This plugin
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
37 " attempts to provide those functionalities. It opens each changed / added or
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
38 " removed file diff in new tabs.
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
39 "
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
40 " Installing:
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
41 "
10550
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
42 " For a quick start, unzip patchreview.zip into your ~/.vim directory and
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
43 " restart Vim.
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
44 "
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
45 " Details:
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
46 "
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
47 " Requirements:
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
48 "
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
49 " 1) VIM 7.0 or higher built with +diff option.
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
50 "
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
51 " 2) A gnu compatible patch command installed. This is the standard patch
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
52 " command on Linux, Mac OS X, *BSD, Cygwin or /usr/bin/gpatch on newer
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
53 " Solaris.
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
54 "
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
55 " 3) Optional (but recommended for speed)
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
56 "
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
57 " Install patchutils ( http://cyberelk.net/tim/patchutils/ ) for your
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
58 " OS. For windows it is availble from Cygwin
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
59 "
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
60 " http://www.cygwin.com
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
61 "
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
62 " or GnuWin32
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
63 "
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
64 " http://gnuwin32.sourceforge.net/
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
65 "
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
66 " Install:
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
67 "
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
68 " 1) Extract the zip in your $HOME/.vim or $VIM/vimfiles directory and
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
69 " restart vim. The directory location relevant to your platform can be
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
70 " seen by running :help add-global-plugin in vim.
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
71 "
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
72 " 2) Restart vim.
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
73 "
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
74 " Configuration:
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
75 "
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
76 " Optionally, specify the locations to these filterdiff and patch commands
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
77 " and location of a temporary directory to use in your .vimrc.
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
78 "
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
79 " let g:patchreview_patch = '/path/to/gnu/patch'
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
80 "
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
81 " " If you are using filterdiff
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
82 " let g:patchreview_filterdiff = '/path/to/filterdiff'
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
83 "
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
84 "
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
85 " Usage:
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
86 "
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
87 " Please see :help patchreview or :help diffreview for details.
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
88 "
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
89 ""}}}
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
90
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
91 " Enabled only during development
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
92 " unlet! g:loaded_patchreview " DEBUG
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
93 " unlet! g:patchreview_patch " DEBUG
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
94 " unlet! g:patchreview_filterdiff " DEBUG
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
95 " let g:patchreview_patch = 'patch' " DEBUG
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
96
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
97 if v:version < 700
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
98 finish
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
99 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
100 if ! has('diff')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
101 call confirm('patchreview.vim plugin needs (G)VIM built with +diff support to work.')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
102 finish
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
103 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
104
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
105 " load only once
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
106 if (! exists('g:patchreview_debug') && exists('g:loaded_patchreview')) || &compatible
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
107 finish
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
108 endif
10550
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
109 let g:loaded_patchreview="0.2.2"
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
110
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
111 let s:msgbufname = '-PatchReviewMessages-'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
112
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
113 function! <SID>Debug(str) "{{{
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
114 if exists('g:patchreview_debug')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
115 Pecho 'DEBUG: ' . a:str
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
116 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
117 endfunction
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
118 command! -nargs=+ -complete=expression Debug call s:Debug(<args>)
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
119 "}}}
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
120
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
121 function! <SID>PR_wipeMsgBuf() "{{{
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
122 let winnum = bufwinnr(s:msgbufname)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
123 if winnum != -1 " If the window is already open, jump to it
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
124 let cur_winnr = winnr()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
125 if winnr() != winnum
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
126 exe winnum . 'wincmd w'
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
127 exe 'bw'
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
128 exe cur_winnr . 'wincmd w'
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
129 endif
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
130 endif
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
131 endfunction
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
132 "}}}
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
133
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
134 function! <SID>Pecho(...) "{{{
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
135 " Usage: Pecho(msg, [return_to_original_window_flag])
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
136 " default return_to_original_window_flag = 0
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
137 "
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
138 let cur_winnr = winnr()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
139 let winnum = bufwinnr(s:msgbufname)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
140 if winnum != -1 " If the window is already open, jump to it
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
141 if winnr() != winnum
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
142 exe winnum . 'wincmd w'
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
143 endif
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
144 else
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
145 let bufnum = bufnr(s:msgbufname)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
146 if bufnum == -1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
147 let wcmd = s:msgbufname
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
148 else
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
149 let wcmd = '+buffer' . bufnum
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
150 endif
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
151 exe 'silent! botright 5split ' . wcmd
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
152 endif
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
153 setlocal modifiable
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
154 setlocal buftype=nofile
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
155 setlocal bufhidden=delete
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
156 setlocal noswapfile
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
157 setlocal nowrap
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
158 setlocal nobuflisted
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
159 if a:0 != 0
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
160 silent! $put =a:1
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
161 endif
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
162 exe ':$'
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
163 setlocal nomodifiable
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
164 if a:0 > 1 && a:2
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
165 exe cur_winnr . 'wincmd w'
2350
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 endfunction
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
168
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
169 command! -nargs=+ -complete=expression Pecho call s:Pecho(<args>)
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
170 "}}}
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
171
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
172 function! <SID>PR_checkBinary(BinaryName) "{{{
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
173 " Verify that BinaryName is specified or available
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
174 if ! exists('g:patchreview_' . a:BinaryName)
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
175 if executable(a:BinaryName)
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
176 let g:patchreview_{a:BinaryName} = a:BinaryName
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
177 return 1
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
178 else
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
179 Pecho 'g:patchreview_' . a:BinaryName . ' is not defined and ' . a:BinaryName . ' command could not be found on path.'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
180 Pecho 'Please define it in your .vimrc.'
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
181 return 0
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
182 endif
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
183 elseif ! executable(g:patchreview_{a:BinaryName})
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
184 Pecho 'Specified g:patchreview_' . a:BinaryName . ' [' . g:patchreview_{a:BinaryName} . '] is not executable.'
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
185 return 0
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
186 else
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
187 return 1
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
188 endif
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
189 endfunction
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
190 "}}}
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
191
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
192 function! <SID>ExtractDiffsNative(...) "{{{
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
193 " Sets g:patches = {'reason':'', 'patch':[
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
194 " {
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
195 " 'filename': filepath
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
196 " 'type' : '+' | '-' | '!'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
197 " 'content' : patch text for this file
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
198 " },
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
199 " ...
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
200 " ]}
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
201 let g:patches = {'reason' : '', 'patch' : []}
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
202 " TODO : User pointers into lines list rather then use collect
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
203 if a:0 == 0
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
204 let g:patches['reason'] = "ExtractDiffsNative expects at least a patchfile argument"
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
205 return
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
206 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
207 let patchfile = expand(a:1, ':p')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
208 if a:0 > 1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
209 let patch = a:2
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
210 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
211 if ! filereadable(patchfile)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
212 let g:patches['reason'] = "File " . patchfile . " is not readable"
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
213 return
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
214 endif
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
215 unlet! filterdiffcmd
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
216 let filterdiffcmd = '' . g:patchreview_filterdiff . ' --list -s ' . patchfile
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
217 let fileslist = split(system(filterdiffcmd), '[\r\n]')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
218 for filewithchangetype in fileslist
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
219 if filewithchangetype !~ '^[!+-] '
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
220 Pecho '*** Skipping review generation due to unknown change for [' . filewithchangetype . ']'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
221 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
222 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
223
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
224 unlet! this_patch
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
225 let this_patch = {}
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
226
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
227 unlet! relpath
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
228 let relpath = substitute(filewithchangetype, '^. ', '', '')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
229
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
230 let this_patch['filename'] = relpath
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
231
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
232 if filewithchangetype =~ '^! '
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
233 let this_patch['type'] = '!'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
234 elseif filewithchangetype =~ '^+ '
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
235 let this_patch['type'] = '+'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
236 elseif filewithchangetype =~ '^- '
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
237 let this_patch['type'] = '-'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
238 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
239
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
240 unlet! filterdiffcmd
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
241 let filterdiffcmd = '' . g:patchreview_filterdiff . ' -i ' . relpath . ' ' . patchfile
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
242 let this_patch['content'] = split(system(filterdiffcmd), '[\n\r]')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
243 let g:patches['patch'] += [this_patch]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
244 Debug "Patch collected for " . relpath
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
245 endfor
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
246 endfunction
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
247 "}}}
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
248
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
249 function! <SID>ExtractDiffsPureVim(...) "{{{
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
250 " Sets g:patches = {'reason':'', 'patch':[
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
251 " {
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
252 " 'filename': filepath
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
253 " 'type' : '+' | '-' | '!'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
254 " 'content' : patch text for this file
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
255 " },
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
256 " ...
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
257 " ]}
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
258 let g:patches = {'reason' : '', 'patch' : []}
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
259 " TODO : User pointers into lines list rather then use collect
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
260 if a:0 == 0
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
261 let g:patches['reason'] = "ExtractDiffsPureVim expects at least a patchfile argument"
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
262 return
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
263 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
264 let patchfile = expand(a:1, ':p')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
265 if a:0 > 1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
266 let patch = a:2
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
267 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
268 if ! filereadable(patchfile)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
269 let g:patches['reason'] = "File " . patchfile . " is not readable"
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
270 return
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
271 endif
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
272 call s:PR_wipeMsgBuf()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
273 let collect = []
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
274 let linum = 0
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
275 let lines = readfile(patchfile)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
276 let linescount = len(lines)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
277 State 'START'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
278 while linum < linescount
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
279 let line = lines[linum]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
280 let linum += 1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
281 if State() == 'START'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
282 let mat = matchlist(line, '^--- \([^\t]\+\).*$')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
283 if ! empty(mat) && mat[1] != ''
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
284 State 'MAYBE_UNIFIED_DIFF'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
285 let p_first_file = mat[1]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
286 let collect = [line]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
287 Debug line . State()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
288 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
289 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
290 let mat = matchlist(line, '^\*\*\* \([^\t]\+\).*$')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
291 if ! empty(mat) && mat[1] != ''
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
292 State 'MAYBE_CONTEXT_DIFF'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
293 let p_first_file = mat[1]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
294 let collect = [line]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
295 Debug line . State()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
296 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
297 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
298 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
299 elseif State() == 'MAYBE_CONTEXT_DIFF'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
300 let mat = matchlist(line, '^--- \([^\t]\+\).*$')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
301 if empty(mat) || mat[1] == ''
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
302 State 'START'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
303 let linum -= 1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
304 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
305 Debug 'Back to square one ' . line()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
306 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
307 let p_second_file = mat[1]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
308 if p_first_file == '/dev/null'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
309 if p_second_file == '/dev/null'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
310 let g:patches['reason'] = "Malformed diff found at line " . linum
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
311 return
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
312 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
313 let p_type = '+'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
314 let filepath = p_second_file
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
315 else
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
316 if p_second_file == '/dev/null'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
317 let p_type = '-'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
318 let filepath = p_first_file
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
319 else
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
320 let p_type = '!'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
321 let filepath = p_first_file
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
322 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
323 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
324 State 'EXPECT_15_STARS'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
325 let collect += [line]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
326 Debug line . State()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
327 elseif State() == 'EXPECT_15_STARS'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
328 if line !~ '^*\{15}$'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
329 State 'START'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
330 let linum -= 1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
331 Debug line . State()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
332 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
333 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
334 State 'EXPECT_CONTEXT_CHUNK_HEADER_1'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
335 let collect += [line]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
336 Debug line . State()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
337 elseif State() == 'EXPECT_CONTEXT_CHUNK_HEADER_1'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
338 let mat = matchlist(line, '^\*\*\* \(\d\+,\)\?\(\d\+\) \*\*\*\*$')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
339 if empty(mat) || mat[1] == ''
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
340 State 'START'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
341 let linum -= 1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
342 Debug line . State()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
343 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
344 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
345 let collect += [line]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
346 State 'SKIP_CONTEXT_STUFF_1'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
347 Debug line . State()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
348 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
349 elseif State() == 'SKIP_CONTEXT_STUFF_1'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
350 if line !~ '^[ !+].*$'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
351 let mat = matchlist(line, '^--- \(\d\+\),\(\d\+\) ----$')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
352 if ! empty(mat) && mat[1] != '' && mat[2] != ''
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
353 let goal_count = mat[2] - mat[1] + 1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
354 let c_count = 0
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
355 State 'READ_CONTEXT_CHUNK'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
356 let collect += [line]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
357 Debug line . State() . " Goal count set to " . goal_count
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
358 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
359 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
360 State 'START'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
361 let linum -= 1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
362 Debug line . State()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
363 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
364 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
365 let collect += [line]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
366 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
367 elseif State() == 'READ_CONTEXT_CHUNK'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
368 let c_count += 1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
369 if c_count == goal_count
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
370 let collect += [line]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
371 State 'BACKSLASH_OR_CRANGE_EOF'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
372 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
373 else " goal not met yet
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
374 let mat = matchlist(line, '^\([\\!+ ]\).*$')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
375 if empty(mat) || mat[1] == ''
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
376 let linum -= 1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
377 State 'START'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
378 Debug line . State()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
379 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
380 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
381 let collect += [line]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
382 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
383 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
384 elseif State() == 'BACKSLASH_OR_CRANGE_EOF'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
385 if line =~ '^\\ No newline.*$' " XXX: Can we go to another chunk from here??
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
386 let collect += [line]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
387 let this_patch = {}
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
388 let this_patch['filename'] = filepath
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
389 let this_patch['type'] = p_type
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
390 let this_patch['content'] = collect
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
391 let g:patches['patch'] += [this_patch]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
392 Debug "Patch collected for " . filepath
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
393 State 'START'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
394 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
395 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
396 if line =~ '^\*\{15}$'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
397 let collect += [line]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
398 State 'EXPECT_CONTEXT_CHUNK_HEADER_1'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
399 Debug line . State()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
400 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
401 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
402 let this_patch = {}
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
403 let this_patch['filename'] = filepath
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
404 let this_patch['type'] = p_type
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
405 let this_patch['content'] = collect
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
406 let g:patches['patch'] += [this_patch]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
407 let linum -= 1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
408 State 'START'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
409 Debug "Patch collected for " . filepath
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
410 Debug line . State()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
411 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
412 elseif State() == 'MAYBE_UNIFIED_DIFF'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
413 let mat = matchlist(line, '^+++ \([^\t]\+\).*$')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
414 if empty(mat) || mat[1] == ''
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
415 State 'START'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
416 let linum -= 1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
417 Debug line . State()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
418 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
419 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
420 let p_second_file = mat[1]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
421 if p_first_file == '/dev/null'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
422 if p_second_file == '/dev/null'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
423 let g:patches['reason'] = "Malformed diff found at line " . linum
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
424 return
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
425 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
426 let p_type = '+'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
427 let filepath = p_second_file
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
428 else
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
429 if p_second_file == '/dev/null'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
430 let p_type = '-'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
431 let filepath = p_first_file
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
432 else
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
433 let p_type = '!'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
434 let filepath = p_first_file
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
435 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
436 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
437 State 'EXPECT_UNIFIED_RANGE_CHUNK'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
438 let collect += [line]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
439 Debug line . State()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
440 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
441 elseif State() == 'EXPECT_UNIFIED_RANGE_CHUNK'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
442 let mat = matchlist(line, '^@@ -\(\d\+,\)\?\(\d\+\) +\(\d\+,\)\?\(\d\+\) @@$')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
443 if ! empty(mat)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
444 let old_goal_count = mat[2]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
445 let new_goal_count = mat[4]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
446 let o_count = 0
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
447 let n_count = 0
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
448 Debug "Goal count set to " . old_goal_count . ', ' . new_goal_count
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
449 State 'READ_UNIFIED_CHUNK'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
450 let collect += [line]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
451 Debug line . State()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
452 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
453 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
454 State 'START'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
455 Debug line . State()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
456 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
457 elseif State() == 'READ_UNIFIED_CHUNK'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
458 if o_count == old_goal_count && n_count == new_goal_count
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
459 if line =~ '^\\.*$' " XXX: Can we go to another chunk from here??
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
460 let collect += [line]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
461 let this_patch = {}
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
462 let this_patch['filename'] = filepath
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
463 let this_patch['type'] = p_type
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
464 let this_patch['content'] = collect
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
465 let g:patches['patch'] += [this_patch]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
466 Debug "Patch collected for " . filepath
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
467 State 'START'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
468 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
469 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
470 let mat = matchlist(line, '^@@ -\(\d\+,\)\?\(\d\+\) +\(\d\+,\)\?\(\d\+\) @@$')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
471 if ! empty(mat)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
472 let old_goal_count = mat[2]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
473 let new_goal_count = mat[4]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
474 let o_count = 0
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
475 let n_count = 0
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
476 Debug "Goal count set to " . old_goal_count . ', ' . new_goal_count
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
477 let collect += [line]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
478 Debug line . State()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
479 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
480 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
481 let this_patch = {}
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
482 let this_patch['filename'] = filepath
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
483 let this_patch['type'] = p_type
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
484 let this_patch['content'] = collect
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
485 let g:patches['patch'] += [this_patch]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
486 Debug "Patch collected for " . filepath
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
487 let linum -= 1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
488 State 'START'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
489 Debug line . State()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
490 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
491 else " goal not met yet
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
492 let mat = matchlist(line, '^\([\\+ -]\).*$')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
493 if empty(mat) || mat[1] == ''
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
494 let linum -= 1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
495 State 'START'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
496 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
497 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
498 let chr = mat[1]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
499 if chr == '+'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
500 let n_count += 1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
501 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
502 if chr == ' '
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
503 let o_count += 1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
504 let n_count += 1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
505 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
506 if chr == '-'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
507 let o_count += 1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
508 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
509 let collect += [line]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
510 Debug line . State()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
511 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
512 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
513 else
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
514 let g:patches['reason'] = "Internal error: Do not use the plugin anymore and if possible please send the diff or patch file you tried it with to Manpreet Singh <junkblocker@yahoo.com>"
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
515 return
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
516 endif
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
517 endwhile
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
518 "Pecho State()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
519 if (State() == 'READ_CONTEXT_CHUNK' && c_count == goal_count) || (State() == 'READ_UNIFIED_CHUNK' && n_count == new_goal_count && o_count == old_goal_count)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
520 let this_patch = {}
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
521 let this_patch['filename'] = filepath
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
522 let this_patch['type'] = p_type
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
523 let this_patch['content'] = collect
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
524 let g:patches['patch'] += [this_patch]
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
525 Debug "Patch collected for " . filepath
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
526 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
527 return
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
528 endfunction
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
529 "}}}
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
530
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
531 function! State(...) " For easy manipulation of diff extraction state "{{{
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
532 if a:0 != 0
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
533 let s:STATE = a:1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
534 else
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
535 if ! exists('s:STATE')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
536 let s:STATE = 'START'
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
537 endif
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
538 return s:STATE
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
539 endif
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
540 endfunction
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
541 com! -nargs=+ -complete=expression State call State(<args>)
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
542 "}}}
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
543
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
544 function! <SID>PatchReview(...) "{{{
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
545 let s:save_shortmess = &shortmess
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
546 let s:save_aw = &autowrite
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
547 let s:save_awa = &autowriteall
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
548 set shortmess=aW
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
549 call s:PR_wipeMsgBuf()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
550 let s:reviewmode = 'patch'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
551 call s:_GenericReview(a:000)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
552 let &autowriteall = s:save_awa
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
553 let &autowrite = s:save_aw
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
554 let &shortmess = s:save_shortmess
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
555 endfunction
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
556 "}}}
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
557
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
558 function! <SID>_GenericReview(argslist) "{{{
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
559 " diff mode:
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
560 " arg1 = patchfile
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
561 " arg2 = strip count
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
562 " patch mode:
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
563 " arg1 = patchfile
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
564 " arg2 = strip count
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
565 " arg3 = directory
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
566
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
567 " VIM 7+ required
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
568 if version < 700
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
569 Pecho 'This plugin needs VIM 7 or higher'
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
570 return
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
571 endif
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
572
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
573 " +diff required
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
574 if ! has('diff')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
575 Pecho 'This plugin needs VIM built with +diff feature.'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
576 return
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
577 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
578
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
579
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
580 if s:reviewmode == 'diff'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
581 let patch_R_option = ' -t -R '
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
582 elseif s:reviewmode == 'patch'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
583 let patch_R_option = ''
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
584 else
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
585 Pecho 'Fatal internal error in patchreview.vim plugin'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
586 return
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
587 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
588
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
589 " Check passed arguments
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
590 if len(a:argslist) == 0
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
591 Pecho 'PatchReview command needs at least one argument specifying a patchfile path.'
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
592 return
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
593 endif
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
594 let StripCount = 0
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
595 if len(a:argslist) >= 1 && ((s:reviewmode == 'patch' && len(a:argslist) <= 3) || (s:reviewmode == 'diff' && len(a:argslist) == 2))
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
596 let PatchFilePath = expand(a:argslist[0], ':p')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
597 if ! filereadable(PatchFilePath)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
598 Pecho 'File [' . PatchFilePath . '] is not accessible.'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
599 return
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
600 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
601 if len(a:argslist) >= 2 && s:reviewmode == 'patch'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
602 let s:SrcDirectory = expand(a:argslist[1], ':p')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
603 if ! isdirectory(s:SrcDirectory)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
604 Pecho '[' . s:SrcDirectory . '] is not a directory'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
605 return
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
606 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
607 try
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
608 " Command line has already escaped the path
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
609 exe 'cd ' . s:SrcDirectory
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
610 catch /^.*E344.*/
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
611 Pecho 'Could not change to directory [' . s:SrcDirectory . ']'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
612 return
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
613 endtry
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
614 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
615 if s:reviewmode == 'diff'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
616 " passed in by default
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
617 let StripCount = eval(a:argslist[1])
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
618 elseif s:reviewmode == 'patch'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
619 let StripCount = 1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
620 " optional strip count
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
621 if len(a:argslist) == 3
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
622 let StripCount = eval(a:argslist[2])
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
623 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
624 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
625 else
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
626 if s:reviewmode == 'patch'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
627 Pecho 'PatchReview command needs at most three arguments: patchfile path, optional source directory path and optional strip count.'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
628 elseif s:reviewmode == 'diff'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
629 Pecho 'DiffReview command accepts no arguments.'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
630 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
631 return
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
632 endif
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
633
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
634 " Verify that patch command and temporary directory are available or specified
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
635 if ! s:PR_checkBinary('patch')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
636 return
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
637 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
638
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
639 " Requirements met, now execute
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
640 let PatchFilePath = fnamemodify(PatchFilePath, ':p')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
641 if s:reviewmode == 'patch'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
642 Pecho 'Patch file : ' . PatchFilePath
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
643 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
644 Pecho 'Source directory: ' . getcwd()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
645 Pecho '------------------'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
646 if s:PR_checkBinary('filterdiff')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
647 Debug "Using filterdiff"
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
648 call s:ExtractDiffsNative(PatchFilePath)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
649 else
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
650 Debug "Using own diff extraction (slower)"
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
651 call s:ExtractDiffsPureVim(PatchFilePath)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
652 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
653 for patch in g:patches['patch']
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
654 if patch.type !~ '^[!+-]$'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
655 Pecho '*** Skipping review generation due to unknown change [' . patch.type . ']', 1
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
656 continue
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
657 endif
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
658 unlet! relpath
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
659 let relpath = patch.filename
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
660 " XXX: svn diff and hg diff produce different kind of outputs, one requires
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
661 " XXX: stripping but the other doesn't. We need to take care of that
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
662 let stripmore = StripCount
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
663 let StrippedRelativeFilePath = relpath
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
664 while stripmore > 0
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
665 " strip one
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
666 let StrippedRelativeFilePath = substitute(StrippedRelativeFilePath, '^[^\\\/]\+[^\\\/]*[\\\/]' , '' , '')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
667 let stripmore -= 1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
668 endwhile
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
669 if patch.type == '!'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
670 if s:reviewmode == 'patch'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
671 let msgtype = 'Patch modifies file: '
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
672 elseif s:reviewmode == 'diff'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
673 let msgtype = 'File has changes: '
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
674 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
675 elseif patch.type == '+'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
676 if s:reviewmode == 'patch'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
677 let msgtype = 'Patch adds file : '
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
678 elseif s:reviewmode == 'diff'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
679 let msgtype = 'New file : '
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
680 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
681 elseif patch.type == '-'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
682 if s:reviewmode == 'patch'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
683 let msgtype = 'Patch removes file : '
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
684 elseif s:reviewmode == 'diff'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
685 let msgtype = 'Removed file : '
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
686 endif
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
687 endif
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
688 let bufnum = bufnr(relpath)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
689 if buflisted(bufnum) && getbufvar(bufnum, '&mod')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
690 Pecho 'Old buffer for file [' . relpath . '] exists in modified state. Skipping review.', 1
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
691 continue
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
692 endif
10550
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
693 let tmpname = tempname()
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
694
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
695 " write patch for patch.filename into tmpname
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
696 call writefile(patch.content, tmpname)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
697 if patch.type == '+' && s:reviewmode == 'patch'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
698 let inputfile = ''
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
699 let patchcmd = '!' . g:patchreview_patch . patch_R_option . ' -o "' . tmpname . '.file" "' . inputfile . '" < "' . tmpname . '"'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
700 elseif patch.type == '+' && s:reviewmode == 'diff'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
701 let inputfile = ''
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
702 unlet! patchcmd
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
703 else
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
704 let inputfile = expand(StrippedRelativeFilePath, ':p')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
705 let patchcmd = '!' . g:patchreview_patch . patch_R_option . ' -o "' . tmpname . '.file" "' . inputfile . '" < "' . tmpname . '"'
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
706 endif
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
707 if exists('patchcmd')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
708 let v:errmsg = ''
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
709 Debug patchcmd
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
710 silent exe patchcmd
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
711 if v:errmsg != '' || v:shell_error
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
712 Pecho 'ERROR: Could not execute patch command.'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
713 Pecho 'ERROR: ' . patchcmd
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
714 Pecho 'ERROR: ' . v:errmsg
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
715 Pecho 'ERROR: Diff skipped.'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
716 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
717 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
718 endif
10550
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
719 call delete(tmpname)
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
720 let s:origtabpagenr = tabpagenr()
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
721 silent! exe 'tabedit ' . StrippedRelativeFilePath
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
722 if exists('patchcmd')
10550
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
723 " modelines in loaded files mess with diff comparision
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
724 let s:keep_modeline=&modeline
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
725 let &modeline=0
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
726 silent! exe 'vert diffsplit ' . tmpname . '.file'
10550
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
727 setlocal buftype=nofile
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
728 setlocal noswapfile
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
729 setlocal syntax=none
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
730 setlocal bufhidden=delete
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
731 setlocal nobuflisted
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
732 setlocal modifiable
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
733 setlocal nowrap
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
734 " Remove buffer name
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
735 silent! 0f
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
736 " Switch to original to get a nice tab title
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
737 silent! wincmd p
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
738 let &modeline=s:keep_modeline
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
739 else
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
740 silent! exe 'vnew'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
741 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
742 if filereadable(tmpname . '.file.rej')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
743 silent! exe 'topleft 5split ' . tmpname . '.file.rej'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
744 Pecho msgtype . '*** REJECTED *** ' . relpath, 1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
745 else
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
746 Pecho msgtype . ' ' . relpath, 1
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
747 endif
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
748 silent! exe 'tabn ' . s:origtabpagenr
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
749 endfor
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
750 Pecho '-----'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
751 Pecho 'Done.'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
752
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
753 endfunction
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
754 "}}}
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
755
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
756 function! <SID>DiffReview(...) "{{{
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
757 let s:save_shortmess = &shortmess
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
758 set shortmess=aW
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
759 call s:PR_wipeMsgBuf()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
760
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
761 let vcsdict = {
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
762 \'Mercurial' : {'dir' : '.hg', 'binary' : 'hg', 'diffargs' : 'diff' , 'strip' : 1},
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
763 \'Bazaar-NG' : {'dir' : '.bzr', 'binary' : 'bzr', 'diffargs' : 'diff' , 'strip' : 0},
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
764 \'monotone' : {'dir' : '_MTN', 'binary' : 'mtn', 'diffargs' : 'diff --unified', 'strip' : 0},
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
765 \'Subversion' : {'dir' : '.svn', 'binary' : 'svn', 'diffargs' : 'diff' , 'strip' : 0},
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
766 \'cvs' : {'dir' : 'CVS', 'binary' : 'cvs', 'diffargs' : '-q diff -u' , 'strip' : 0},
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
767 \}
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
768
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
769 unlet! s:theDiffCmd
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
770 unlet! l:vcs
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
771 if ! exists('g:patchreview_diffcmd')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
772 for key in keys(vcsdict)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
773 if isdirectory(vcsdict[key]['dir'])
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
774 if ! s:PR_checkBinary(vcsdict[key]['binary'])
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
775 Pecho 'Current directory looks like a ' . vcsdict[key] . ' repository but ' . vcsdist[key]['binary'] . ' command was not found on path.'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
776 let &shortmess = s:save_shortmess
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
777 return
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
778 else
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
779 let s:theDiffCmd = vcsdict[key]['binary'] . ' ' . vcsdict[key]['diffargs']
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
780 let strip = vcsdict[key]['strip']
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
781
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
782 Pecho 'Using [' . s:theDiffCmd . '] to generate diffs for this ' . key . ' review.'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
783 let &shortmess = s:save_shortmess
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
784 let l:vcs = vcsdict[key]['binary']
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
785 break
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
786 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
787 else
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
788 continue
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
789 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
790 endfor
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
791 else
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
792 let s:theDiffCmd = g:patchreview_diffcmd
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
793 let strip = 0
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
794 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
795 if ! exists('s:theDiffCmd')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
796 Pecho 'Please define g:patchreview_diffcmd and make sure you are in a VCS controlled top directory.'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
797 let &shortmess = s:save_shortmess
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
798 return
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
799 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
800
10550
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
801 let outfile = tempname()
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
802 let cmd = s:theDiffCmd . ' > "' . outfile . '"'
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
803 let v:errmsg = ''
10550
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
804 let cout = system(cmd)
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
805 if v:errmsg == '' && exists('l:vcs') && l:vcs == 'cvs' && v:shell_error == 1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
806 " Ignoring CVS non-error
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
807 elseif v:errmsg != '' || v:shell_error
10550
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
808 Pecho v:errmsg
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
809 Pecho 'Could not execute [' . s:theDiffCmd . ']'
10550
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
810 Pecho 'Error code: ' . v:shell_error
8036bc1871c2 Updated contrib/vim/patchreview.* to version 0.2.2
Manpreet Singh <junkblocker@yahoo.com>
parents: 10545
diff changeset
811 Pecho cout
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
812 Pecho 'Diff review aborted.'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
813 let &shortmess = s:save_shortmess
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
814 return
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
815 endif
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
816 let s:reviewmode = 'diff'
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
817 call s:_GenericReview([outfile, strip])
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
818 let &shortmess = s:save_shortmess
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
819 endfunction
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
820 "}}}
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
821
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
822 " End user commands "{{{
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
823 "============================================================================
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
824 " :PatchReview
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
825 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
826
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
827 " :DiffReview
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
828 command! -nargs=0 DiffReview call s:DiffReview()
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
829 "}}}
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
830
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
831 " Development "{{{
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
832 if exists('g:patchreview_debug')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
833 " Tests
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
834 function! <SID>PRExtractTestNative(...)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
835 "let patchfiles = glob(expand(a:1) . '/?*')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
836 "for fname in split(patchfiles)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
837 call s:PR_wipeMsgBuf()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
838 let fname = a:1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
839 call s:ExtractDiffsNative(fname)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
840 for patch in g:patches['patch']
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
841 for line in patch.content
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
842 Pecho line
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
843 endfor
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
844 endfor
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
845 "endfor
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
846 endfunction
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
847
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
848 function! <SID>PRExtractTestVim(...)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
849 "let patchfiles = glob(expand(a:1) . '/?*')
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
850 "for fname in split(patchfiles)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
851 call s:PR_wipeMsgBuf()
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
852 let fname = a:1
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
853 call s:ExtractDiffsPureVim(fname)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
854 for patch in g:patches['patch']
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
855 for line in patch.content
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
856 Pecho line
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
857 endfor
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
858 endfor
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
859 "endfor
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
860 endfunction
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
861
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
862 command! -nargs=+ -complete=file PRTestVim call s:PRExtractTestVim(<f-args>)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
863 command! -nargs=+ -complete=file PRTestNative call s:PRExtractTestNative(<f-args>)
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
864 endif
2350
091d555653a4 contrib: patch review plugin for vim 7.0
Manpreet Singh <junkblocker@yahoo.com>
parents:
diff changeset
865 "}}}
10545
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
866
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
867 " modeline
b9e4a67329cd Updated contrib/vim/patchreview.* to version 0.2.1
Manpreet Singh <junkblocker@yahoo.com>
parents: 2350
diff changeset
868 " vim: set et fdl=0 fdm=marker fenc=latin ff=unix ft=vim sw=2 sts=0 ts=2 textwidth=78 nowrap :