문제

나는 다음 명령을 알고 있습니다.cvs log -N -w<userid> -d"1 day ago"

불행하게도 이렇게 하면 파일 경로, 파일 버전 및 주석 텍스트가 모두 별도의 줄에 표시되는 등 줄 바꿈이 많이 포함된 형식화된 보고서가 생성됩니다.따라서 모든 주석 텍스트(예: grep)를 검색하고 일치 항목을 파일/버전과 연관시키는 것이 어렵습니다.

(cvs만이 기본적으로 필터링을 수행할 수 있다면 로그 출력은 완벽하게 허용될 것입니다.)

편집하다:샘플 출력.다음과 같은 텍스트 블록이 각 저장소 파일에 대해 보고됩니다.

RCS file: /data/cvs/dps/build.xml,v
Working file: build.xml
head: 1.49
branch:
locks: strict
access list:
keyword substitution: kv
total revisions: 57;    selected revisions: 1
description:
----------------------------
revision 1.48
date: 2008/07/09 17:17:32;  author: noec;  state: Exp;  lines: +2 -2
Fixed src.jar references
----------------------------
revision 1.47
date: 2008/07/03 13:13:14;  author: noec;  state: Exp;  lines: +1 -1
Fixed common-src.jar reference.
=============================================================================
도움이 되었습니까?

해결책

그만큼 -w 옵션이 더 잘 작동하는 것 같습니다. -S 옵션.그렇지 않으면 사용자 ID와 관련이 없는 것으로 보이는 추가 결과가 있습니다.아마도 누군가가 그것을 설명할 수 있을 것입니다.

cvs log -N -S -w<userid> -d"1 day ago"

그것으로 나는 그것을 grep으로 연결하여 합리적인 성공을 거두었습니다.

cvs log -N -S -w<userid> -d"1 day ago" | grep -B14 "some text" > afile

cvs 로그에 잡음이 많고 조용하게 만드는 방법을 잘 모르기 때문에 출력을 파일로 리디렉션하고 있습니다.대안은 stderr을 다음으로 리디렉션하는 것입니다. /dev/null.

다른 팁

당신이 원하는 cvsp - CVS 기록에서 패치 세트를 생성합니다.그런 다음 cvsps 출력에는 주석 인스턴스가 하나만 있어야 하며 그 아래에 파일이 깔끔하게 나열되어야 합니다.

내 첫 번째 생각은 egrep(또는 grep -E라고 생각함)을 사용하여 다음과 같은 여러 패턴을 검색하는 것이었습니다.

<Cmd> | egrep 'Filename:|Version:|Comment:'

그런데 좀 더 지능적으로 필터링하고 싶다는 걸 깨달았어요.

이를 위해 awk(또는 perl)를 사용하여 출력을 한 줄씩 처리하고 관심 있는 섹션을 찾으면 echo 변수를 설정합니다.여기에 의사코드가 있습니다:

# Assume the sections are of the format:
#   Filename: <filename>
#   Version:  <version>
#   Comment:  <comment>
#             <more comment>

Set echo to false
While more lines left
    Get line
    If line starts with "Filename: " and <filename> is of interest
        Set echo to true
    If line starts with "Filename: " and <filename> is not of interest
        Set echo to false
    If echo is true
        Output line
End while

제가 한 일은 다음과 같습니다. 간단한 Java 스크립트입니다.

import java.io.IOException;


public class ParseCVSLog
{

    public static final String CVS_LOG_FILE_SEPARATOR = "=============================================================================";
    public static final String CVS_LOG_REVISION_SEPARATOR = "----------------------------";
    public static final String CVS_LOG_HEADER_FILE_NAME = "Working file";
    public static final String CVS_LOG_VERSION_PREFIX = "revision";

    public static void main(String[] args) throws IOException
    {
        String searchString = args[0];

        System.out.println( "SEARCHING FOR: " + searchString );

        StringBuffer cvsLogOutputBuffer = new StringBuffer();
        byte[] bytes = new byte[1024];
        int numBytesRead = 0;
        while( (numBytesRead = System.in.read( bytes )) > 0 )
        {
            String bytesString = new String(bytes, 0,  numBytesRead);
            cvsLogOutputBuffer.append( bytesString );
        }

        String cvsLogOutput = cvsLogOutputBuffer.toString();

        String newLine = System.getProperty("line.separator");
        String[] fileArray = cvsLogOutput.split( CVS_LOG_FILE_SEPARATOR );


        for ( String fileRecord : fileArray )
        {
            if ( !fileRecord.contains( searchString ) )
            {
                continue;
            }

            String[] revisionArray = fileRecord.split( CVS_LOG_REVISION_SEPARATOR );
            String[] fileHeaderLineArray = revisionArray[ 0 ].split( newLine );
            String fileName = "";
            for ( String fileHeadeLine : fileHeaderLineArray )
            {
                if ( fileHeadeLine.contains( CVS_LOG_HEADER_FILE_NAME ) )
                {
                    fileName = fileHeadeLine.split( ": " )[ 1 ];
                    break;
                }
            }
            System.out.print( fileName );
            for ( int i = 1; i < revisionArray.length; i++ )
            {
                String versionRecord = revisionArray[ i ];
                if ( !versionRecord.contains( searchString ) )
                {
                    continue;
                }
                String[] versionLineArray = versionRecord.split( newLine );
                for ( String versionLine : versionLineArray )
                {
                    if ( versionLine.contains( CVS_LOG_VERSION_PREFIX ) )
                    {
                        System.out.print( " " + versionLine.split( " " )[ 1 ] );
                    }
                }

            }
            System.out.println();
        }
    }
}

제가 사용한 방법은 다음과 같습니다.

cvs log -N -S -washamsut | java ParseCVSLog GS-242

이 명령과 gawk 스크립트는 각 로그 항목의 파일 이름, 날짜 및 주석 줄만 찾는 데 도움이 됩니다.

cvs log -N -S -b -w<userid> -d ">1 day ago" 2>/dev/null | gawk 'BEGIN{out=0;} /^Working file:/ { print $0; } /^date:/ { out=1; } /^===/ { print ""; out=0; } (out==1){print $0;}'

이것은 너무 과잉일 수도 있지만 다음을 사용할 수 있습니다. 자식-cvsimport CVS 기록을 Git 저장소로 가져오고 Git 도구를 사용하여 검색합니다.커밋 메시지 내의 텍스트를 검색할 수 있을 뿐만 아니라 추가된 코드도 검색할 수 있습니다. 또는 제거됨 저장소의 파일에서.

CVS검색 도움이 될 수도 있지만 CGI 애플리케이션입니다. :'(

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top