Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Version 1.1.1: Better filepath and strip level calculations and some …

…cleanup.
  • Loading branch information...
commit 668225e8a2b7aec6eec1d81bc0c337055bd2cf55 1 parent e24a94d
Manpreet Singh authored April 03, 2014 vim-scripts committed April 03, 2014
45  autoload/patchreview.vim
... ...
@@ -1,14 +1,17 @@
1 1
 " VIM plugin for doing single, multi-patch or diff code reviews             {{{
2 2
 " Home:  http://www.vim.org/scripts/script.php?script_id=1563
3 3
 
4  
-" Version       : 1.1.0                                                     {{{
  4
+" Version       : 1.1.1                                                     {{{
5 5
 " Author        : Manpreet Singh < junkblocker@yahoo.com >
6  
-" Copyright     : 2006-2013 by Manpreet Singh
  6
+" Copyright     : 2006-2014 by Manpreet Singh
7 7
 " License       : This file is placed in the public domain.
8 8
 "                 No warranties express or implied. Use at your own risk.
9 9
 "
10 10
 " Changelog : {{{
11 11
 "
  12
+"   1.1.1 - Better filepath/strip level calculation
  13
+"           Some cleanup
  14
+"
12 15
 "   1.1.0 - Added option to open diffs on the right
13 16
 "         - Added some basic tests (internal)
14 17
 "
@@ -198,6 +201,7 @@ endfunction
198 201
 " }}}
199 202
 " }}}
200 203
 function! s:me.progress(str)                                                 "{{{
  204
+  " call s:me.debug(a:str)
201 205
   if ! &cmdheight
202 206
     return
203 207
   endif
@@ -251,9 +255,9 @@ function! s:me.buflog(...)                                                   "{{
251 255
       exe l:winnum . 'wincmd w'
252 256
     endif
253 257
   else
254  
-    let bufnum = bufnr(s:msgbufname)
255  
-    let wcmd = bufnum == -1 ? s:msgbufname : '+buffer' . bufnum
256  
-    exe 'silent! botright 5split ' . wcmd
  258
+    let l:bufnum = bufnr(s:msgbufname)
  259
+    let l:wcmd = l:bufnum == -1 ? s:msgbufname : '+buffer' . l:bufnum
  260
+    exe 'silent! botright 5split ' . l:wcmd
257 261
     let s:msgbuftabnr = tabpagenr()
258 262
     setlocal buftype=nofile
259 263
     setlocal bufhidden=delete
@@ -302,6 +306,7 @@ function! s:check_binary(binary_name)                                 "{{{
302 306
 endfunction
303 307
 "}}}
304 308
 function! s:guess_prefix_strip_value(diff_file_path, default_strip) " {{{
  309
+  " call s:me.debug("Trying to guess strip level for " . a:diff_file_path . " with " .a:default_strip . " as default")
305 310
   if stridx(a:diff_file_path, '/') != -1
306 311
     let l:splitchar = '/'
307 312
   elseif stridx(a:diff_file_path, '\') !=  -1
@@ -390,6 +395,7 @@ function! s:me.generate_diff(shell_escaped_cmd)                            "{{{
390 395
 endfunction
391 396
 " }}}
392 397
 function! patchreview#extract_diffs(lines, default_strip_count)            "{{{
  398
+  " call s:me.debug("patchreview#extract_diffs called with default_strip_count " . a:default_strip_count)
393 399
   " Sets g:patches = {'fail':'', 'patch':[
394 400
   " {
395 401
   "  'filename': filepath
@@ -475,13 +481,10 @@ function! patchreview#extract_diffs(lines, default_strip_count)            "{{{
475 481
           let l:filepath = l:p_first_file
476 482
         else
477 483
           let l:p_type = '!'
478  
-          if l:p_first_file =~ '^//'  " A Perforce diff
479  
-            let l:filepath = l:p_second_file
480  
-          else
481  
-            let l:filepath = l:p_first_file
482  
-          endif
  484
+          let l:filepath = l:p_second_file
483 485
         endif
484 486
       endif
  487
+      " call s:me.debug('l:p_type ' . l:p_type)
485 488
       call s:me.progress('Collecting ' . l:filepath)
486 489
       call s:state('EXPECT_15_STARS')
487 490
       let l:collect += [l:line]
@@ -913,7 +916,7 @@ function! s:generic_review(argslist)                                   "{{{
913 916
   if exists('l:strip_count')
914 917
     let l:defsc = l:strip_count
915 918
   elseif s:reviewmode =~ 'patch'
916  
-    let l:defsc = 1
  919
+    let l:defsc = 0
917 920
   else
918 921
     call s:me.buflog('Fatal internal error in patchreview.vim plugin')
919 922
   endif
@@ -958,25 +961,25 @@ function! s:generic_review(argslist)                                   "{{{
958 961
     endwhile
959 962
     if patch.type == '!'
960 963
       if s:reviewmode =~ 'patch'
961  
-        let msgtype = 'Patch modifies file: '
  964
+        let l:msgtype = 'Patch modifies file: '
962 965
       elseif s:reviewmode == 'diff'
963  
-        let msgtype = 'File has changes: '
  966
+        let l:msgtype = 'File has changes: '
964 967
       endif
965 968
     elseif patch.type == '+'
966 969
       if s:reviewmode =~ 'patch'
967  
-        let msgtype = 'Patch adds file    : '
  970
+        let l:msgtype = 'Patch adds file    : '
968 971
       elseif s:reviewmode == 'diff'
969  
-        let msgtype = 'New file        : '
  972
+        let l:msgtype = 'New file        : '
970 973
       endif
971 974
     elseif patch.type == '-'
972 975
       if s:reviewmode =~ 'patch'
973  
-        let msgtype = 'Patch removes file : '
  976
+        let l:msgtype = 'Patch removes file : '
974 977
       elseif s:reviewmode == 'diff'
975  
-        let msgtype = 'Removed file    : '
  978
+        let l:msgtype = 'Removed file    : '
976 979
       endif
977 980
     endif
978  
-    let bufnum = bufnr(l:relpath)
979  
-    if buflisted(bufnum) && getbufvar(bufnum, '&mod')
  981
+    let l:bufnum = bufnr(l:relpath)
  982
+    if buflisted(l:bufnum) && getbufvar(l:bufnum, '&mod')
980 983
       call s:me.buflog('Old buffer for file [' . l:relpath . '] exists in modified state. Skipping review.')
981 984
       continue
982 985
       unlet! patch
@@ -1165,10 +1168,10 @@ function! s:generic_review(argslist)                                   "{{{
1165 1168
         endif
1166 1169
         wincmd p
1167 1170
         let &modeline=s:keep_modeline
1168  
-        call s:me.buflog(msgtype . '*** REJECTED *** ' . l:relpath)
  1171
+        call s:me.buflog(l:msgtype . '*** REJECTED *** ' . l:relpath)
1169 1172
         call s:wiggle(l:tmp_patched, l:tmp_patched_rej)
1170 1173
       else
1171  
-        call s:me.buflog(msgtype . ' ' . l:relpath)
  1174
+        call s:me.buflog(l:msgtype . ' ' . l:relpath)
1172 1175
       endif
1173 1176
     finally
1174 1177
       if ! exists('g:patchreview_persist')
2  autoload/patchreview/bazaar.vim
... ...
@@ -1,5 +1,5 @@
1 1
 " Author        : Manpreet Singh < junkblocker@yahoo.com >    " {{{
2  
-" Copyright     : 2006-2013 by Manpreet Singh
  2
+" Copyright     : 2006-2014 by Manpreet Singh
3 3
 " License       : This file is placed in the public domain.
4 4
 "                 No warranties express or implied. Use at your own risk.
5 5
 " Initialization {{{
2  autoload/patchreview/cvs.vim
... ...
@@ -1,5 +1,5 @@
1 1
 " Author        : Manpreet Singh < junkblocker@yahoo.com >    " {{{
2  
-" Copyright     : 2006-2013 by Manpreet Singh
  2
+" Copyright     : 2006-2014 by Manpreet Singh
3 3
 " License       : This file is placed in the public domain.
4 4
 "                 No warranties express or implied. Use at your own risk.
5 5
 " Initialization {{{
2  autoload/patchreview/fossil.vim
... ...
@@ -1,5 +1,5 @@
1 1
 " Author        : Manpreet Singh < junkblocker@yahoo.com >    " {{{
2  
-" Copyright     : 2006-2013 by Manpreet Singh
  2
+" Copyright     : 2006-2014 by Manpreet Singh
3 3
 " License       : This file is placed in the public domain.
4 4
 "                 No warranties express or implied. Use at your own risk.
5 5
 " Initialization {{{
2  autoload/patchreview/git.vim
... ...
@@ -1,5 +1,5 @@
1 1
 " Author        : Manpreet Singh < junkblocker@yahoo.com >    " {{{
2  
-" Copyright     : 2006-2013 by Manpreet Singh
  2
+" Copyright     : 2006-2014 by Manpreet Singh
3 3
 " License       : This file is placed in the public domain.
4 4
 "                 No warranties express or implied. Use at your own risk.
5 5
 " Initialization {{{
2  autoload/patchreview/mercurial.vim
... ...
@@ -1,5 +1,5 @@
1 1
 " Author        : Manpreet Singh < junkblocker@yahoo.com >    " {{{
2  
-" Copyright     : 2006-2013 by Manpreet Singh
  2
+" Copyright     : 2006-2014 by Manpreet Singh
3 3
 " License       : This file is placed in the public domain.
4 4
 "                 No warranties express or implied. Use at your own risk.
5 5
 " Initialization {{{
2  autoload/patchreview/monotone.vim
... ...
@@ -1,5 +1,5 @@
1 1
 " Author        : Manpreet Singh < junkblocker@yahoo.com >    " {{{
2  
-" Copyright     : 2006-2013 by Manpreet Singh
  2
+" Copyright     : 2006-2014 by Manpreet Singh
3 3
 " License       : This file is placed in the public domain.
4 4
 "                 No warranties express or implied. Use at your own risk.
5 5
 " Initialization {{{
2  autoload/patchreview/perforce.vim
... ...
@@ -1,5 +1,5 @@
1 1
 " Author        : Manpreet Singh < junkblocker@yahoo.com >    " {{{
2  
-" Copyright     : 2006-2013 by Manpreet Singh
  2
+" Copyright     : 2006-2014 by Manpreet Singh
3 3
 " License       : This file is placed in the public domain.
4 4
 "                 No warranties express or implied. Use at your own risk.
5 5
 " Initialization {{{
2  autoload/patchreview/subversion.vim
... ...
@@ -1,5 +1,5 @@
1 1
 " Author        : Manpreet Singh < junkblocker@yahoo.com >    " {{{
2  
-" Copyright     : 2006-2013 by Manpreet Singh
  2
+" Copyright     : 2006-2014 by Manpreet Singh
3 3
 " License       : This file is placed in the public domain.
4 4
 "                 No warranties express or implied. Use at your own risk.
5 5
 " Initialization {{{
4  doc/patchreview.txt
... ...
@@ -1,8 +1,8 @@
1 1
 *patchreview.txt* Vim global plugin for doing single, multi-patch or diff code reviews
2  
-                    Version 1.1.0 (for Vim version 7.0 or higher)
  2
+                    Version 1.1.1 (for Vim version 7.0 or higher)
3 3
 
4 4
                 Author: Manpreet Singh < junkblocker@yahoo.com >
5  
-                   Copyright (C) 2006-2013 by Manpreet Singh
  5
+                   Copyright (C) 2006-2014 by Manpreet Singh
6 6
               License : This file is placed in the public domain.
7 7
             No warranties express or implied. Use at your own risk.
8 8
 
6  plugin/patchreview.vim
... ...
@@ -1,9 +1,9 @@
1 1
 " VIM plugin for doing single, multi-patch or diff code reviews {{{
2 2
 " Home:     https://github.com/junkblocker/patchreview-vim
3 3
 " vim.org:  http://www.vim.org/scripts/script.php?script_id=1563
4  
-" Version       : 1.1.0 " {{{
  4
+" Version       : 1.1.1 " {{{
5 5
 " Author        : Manpreet Singh < junkblocker@yahoo.com >
6  
-" Copyright     : 2006-2013 by Manpreet Singh
  6
+" Copyright     : 2006-2014 by Manpreet Singh
7 7
 " License       : This file is placed in the public domain.
8 8
 "                 No warranties express or implied. Use at your own risk.
9 9
 "
@@ -40,7 +40,7 @@
40 40
 if &cp || (! exists('g:patchreview_debug') && exists('g:loaded_patchreview'))
41 41
   finish
42 42
 endif
43  
-let g:loaded_patchreview="1.1.0"
  43
+let g:loaded_patchreview="1.1.1"
44 44
 if v:version < 700
45 45
   echomsg 'patchreview: You need at least Vim 7.0'
46 46
   finish

0 notes on commit 668225e

Please sign in to comment.
Something went wrong with that request. Please try again.