Permalink
Browse files

Version 1.0.6

Convert .rej files to unified format if possible for better readability. Disable via g:patchreview_unified_rejects flag.
  • Loading branch information...
junkblocker authored and vim-scripts committed Feb 12, 2013
1 parent 08f1755 commit e9940fe3a13b604d56d00412912a8bdae42b62b8
Showing with 49 additions and 7 deletions.
  1. +28 −2 autoload/patchreview.vim
  2. +18 −2 doc/patchreview.txt
  3. +3 −3 plugin/patchreview.vim
View
@@ -1,14 +1,16 @@
" VIM plugin for doing single, multi-patch or diff code reviews {{{
" Home: http://www.vim.org/scripts/script.php?script_id=1563
-" Version : 1.0.5 {{{
+" Version : 1.0.6 {{{
" Author : Manpreet Singh < junkblocker@yahoo.com >
-" Copyright : 2006-2012 by Manpreet Singh
+" Copyright : 2006-2013 by Manpreet Singh
" License : This file is placed in the public domain.
" No warranties express or implied. Use at your own risk.
"
" Changelog :
"
+" 1.0.6 - Convert rejects to unified format if possible unless disabled
+"
" 1.0.5 - Fixed context format patch handling
" minor *BSD detection improvement
"
@@ -792,6 +794,8 @@ function! <SID>_GenericReview(argslist) "{{{
return
endif
+ let l:filterdiff_warned = 0
+
if s:reviewmode == 'diff' || s:reviewmode == 'rpatch'
let patch_R_options = ['-t', '-R']
elseif s:reviewmode == 'patch'
@@ -1060,6 +1064,28 @@ function! <SID>_GenericReview(argslist) "{{{
let s:keep_modeline=&modeline
let &modeline=0
silent! exe 'topleft split ' . fnameescape(l:tmp_patched_rej)
+ " Try to convert rejects to unified format unless explicitly disabled
+ if (! exists('g:patchreview_unified_rejects') || g:patchreview_unified_rejects == 1) &&
+ \ getline(1) =~ '\m\*\{15}'
+ if executable('filterdiff')
+ call append(0, '--- ' . l:stripped_rel_path . '.new')
+ call append(0, '*** ' . l:stripped_rel_path . '.old')
+ silent %!filterdiff --format=unified
+ elseif ! l:filterdiff_warned
+ if exists('g:patchreview_unified_rejects')
+ call s:me.Echo('WARNING: Option g:patchreview_unified_rejects requires filterdiff')
+ call s:me.Echo('WARNING: installed which I could not locate on the PATH.')
+ call s:me.Echo('WARNING: Please install it via diffutils package for your platform and make')
+ call s:me.Echo('WARNING: sure it is on the PATH.')
+ else
+ call s:me.Echo('WARNING: Converting rejections to unified format requires filterdiff installed')
+ call s:me.Echo('WARNING: which I could not locate on the PATH.')
+ call s:me.Echo('WARNING: Please install it via diffutils package for your platform and make')
+ call s:me.Echo('WARNING: sure it is on the PATH for better readable .rej output.')
+ endif
+ let l:filterdiff_warned = 1
+ endif
+ endif
setlocal noswapfile
setlocal syntax=none
setlocal bufhidden=delete
View
@@ -1,8 +1,8 @@
*patchreview.txt* Vim global plugin for doing single, multi-patch or diff code reviews
- Version 1.0.5 (for Vim version 7.0 or higher)
+ Version 1.0.6 (for Vim version 7.0 or higher)
Author: Manpreet Singh < junkblocker@yahoo.com >
- Copyright (C) 2006-2011 by Manpreet Singh
+ Copyright (C) 2006-2013 by Manpreet Singh
License : This file is placed in the public domain.
=============================================================================
@@ -133,6 +133,22 @@ PatchReview Options *patchreview-options*
(On *nix systems) >
let g:patchreview_patch = '/usr/bin/gpatch'
<
+
+ *g:patchreview_unified_rejects*
+ *patchreview_unified_rejects*
+ g:patchreview_unified_rejects = {0|1}
+ Usually, the patch utility generates context format reject files (.rej).
+ These can be a bit hard to read. So, we try to automatically convert
+ these to the unified format. You can set this option to 0 to disable this
+ behavior.
+
+ NOTE: Converting to unified format requires the filterdiff utility
+ installed on the PATH. filterdiff can be installed via the patchutils
+ package for your platform.
+
+ Example:
+ let g:patchreview_unified_rejects = 1
+<
Hooks *patchreview-hooks*
g:patchreview_prefunc = '{function}'
View
@@ -1,9 +1,9 @@
" VIM plugin for doing single, multi-patch or diff code reviews {{{
" Home: http://www.vim.org/scripts/script.php?script_id=1563
-" Version : 1.0.5 " {{{
+" Version : 1.0.6 " {{{
" Author : Manpreet Singh < junkblocker@yahoo.com >
-" Copyright : 2006-2012 by Manpreet Singh
+" Copyright : 2006-2013 by Manpreet Singh
" License : This file is placed in the public domain.
" No warranties express or implied. Use at your own risk.
"
@@ -62,7 +62,7 @@
if &cp || (! exists('g:patchreview_debug') && exists('g:loaded_patchreview'))
finish
endif
-let g:loaded_patchreview="1.0.5"
+let g:loaded_patchreview="1.0.6"
if v:version < 700
echomsg 'patchreview: You need at least Vim 7.0'
finish

0 comments on commit e9940fe

Please sign in to comment.