2

I have "cvs diff" output (for all files in project) in unified diff format. Format could be like this:

Index: somefile.cpp
===================================================================
RCS file: /CVS_repo/SomeProject/somefile.cpp,v
retrieving revision 1.19
diff -r1.19 somefile.cpp
31c31
<       return "Read line four times";
---
>       return "Read line five times";
36c36
<       return "Make a bad thing";
---
>       return "Make a good thing";
Index: otherfile.cpp
===================================================================
RCS file: /CVS_repo/SomeProject/otherfile.cpp,v
retrieving revision 1.19
<       ........
---
>       ........

or even like this:

Index: somefile.cpp
===================================================================
RCS file: /CVS_repo/SomeProject/somefile.cpp,v
retrieving revision 1.19
diff -u -r1.19 somefile.cpp
--- somefile.cpp 13 Mar 2013 08:45:18 -0000      1.19
+++ somefile.cpp 26 Mar 2013 08:10:33 -0000
@@ -28,12 +28,12 @@
 //---------------------------------------------------------------------------
 extern "C" char *FuncGetSomeText()
 {
-       return "Read line four times";
+       return "Read line five times";
 }
 //---------------------------------------------------------------------------
 extern "C" char *FuncGetAwesomeText()
 {
-       return "Make a bad thing";
+       return "Make a good thing";
 }
 //---------------------------------------------------------------------------
Index: otherfile.cpp
===================================================================
RCS file: /CVS_repo/SomeProject/otherfile.cpp,v
retrieving revision 1.19
diff -u -r1.19 otherfile.cpp
--- otherfile.cpp 13 Mar 2013 08:45:18 -0000      1.19
+++ otherfile.cpp 26 Mar 2013 08:10:33 -0000
@@ -28,12 +28,12 @@
 //---------------------------------------------------------------------------
 extern "C" char *Func()
 {
-       .......
+       .......
 }
 //---------------------------------------------------------------------------

Is there any way to view this text side-by-side with vim? Or maybe it's possible to change default diff tool in cvs to vimdiff?

Avega
  • 186
  • 11
  • 1
    http://stackoverflow.com/questions/26195/vimdiff-and-cvs-integration – Burhan Ali Mar 26 '13 at 12:41
  • Thanks, but this solution didn't work for me. My vim is totaly outdated with his 6.3.71 version. He failed on unknown winsave() function. I comment winsave/winrestore functions but I have nothing in my vim window after :D vim command. – Avega Mar 27 '13 at 06:47
  • You should post the answer to your own question as an answer. – Quinn Strahl Apr 11 '13 at 16:52

1 Answers1

0

Some sed magic help me:

\cvs -n diff -u > ~diff.tmp; vim -O <(sed -r -e 's/^\+[^\+]+.*$//g;s/^\+$//g' ~diff.tmp) <(sed -r -e 's/^-[^-]+.*$//g;s/^-$//g' ~diff.tmp) +'set scb | set nowrap | wincmd w | set scb | set nowrap'

It is not perfect solution, but better then nothing. Here what this script doing:

\cvs -n diff -u > ~diff.tmp; 

Write CVS diff output in unified format (-u option) to temp file ~diff.tmp. '\' char prevent from taking alias of "cvs" command.

(sed -r -e 's/^\+[^\+]+.*$//g;s/^\+$//g' ~diff.tmp)
(sed -r -e 's/^-[^-]+.*$//g;s/^-$//g' ~diff.tmp)

This commands output text from ~diff.tmp, replace lines beginning with '+' and '-' symbols with empty line.

vim -O <(sed...) <(sed...) +'set scb | set nowrap | wincmd w | set scb | set nowrap'

Open two windows (-O option) with sed's output in each. Command followed '+' set srollbind on and nowrap for first window, then switch to second window (with 'wincmd w') and do same things

Avega
  • 186
  • 11