2013-03-26 2 views
2

"프로젝트의 모든 파일에 대해"통합 diff 형식으로 "cvs diff"출력이 있습니다. 형식은 다음과 같이 될 수있다 :이 같은vim을 사용하여 두 열의 "cvs diff"출력보기

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 
<  ........ 
--- 
>  ........ 

또는 :

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() 
{ 
-  ....... 
+  ....... 
} 
//--------------------------------------------------------------------------- 

정력으로이 텍스트를 나란히 볼 수있는 방법이 있나요? 또는 cvs의 기본 diff 도구를 vimdiff로 변경할 수 있습니까?

+1

http://stackoverflow.com/questions/26195/vimdiff-and-cvs -integration –

+0

감사합니다. 그러나이 솔루션은 저에게 효과적이지 않았습니다. 내 vim은 그의 6.3.71 버전으로 완전히 구식이다. 그는 알 수없는 winsave() 함수에 실패했습니다. 나는 winsave/winrestore 함수에 대해 주석을 달았지만, 이후에는 vim 창에 아무것도 없다 : D vim 명령. – Avega

+0

자신의 질문에 대한 대답을 대답으로 게시해야합니다. –

답변

0

일부 SED 마법 도와 :

\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' 

그것은 완벽한 솔루션이 아니라 아무것도 더 좋은. 다음은이 스크립트가 뭘 : 통일 된 형식 (-u 옵션)에

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

쓰기 CVS은 diff 출력을 임시 파일에 ~ diff.tmp. '\'char는 "cvs"명령의 별칭을 사용하지 못하게합니다.

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

이 명령은 ~ diff.tmp의 텍스트를 출력하고 '+'및 '-'기호로 시작하는 줄을 빈 줄로 바꿉니다.

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

두 개의 창 (-O 옵션)을 각각 sed의 출력으로 엽니 다. 명령 '-'에 따라 srollbind를 설정하고 첫 창에 대해 nowrap하고 'wincmd w'와 함께 두 번째 창으로 전환하고 동일한 작업을 수행합니다.