info-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: log modifications


From: Josh Baudhuin
Subject: RE: log modifications
Date: Tue, 14 Aug 2001 12:26:39 -0700

Yes, this is one of the lame things about cvs log. (Hmm... What happens if you 
turn off the headers?)

I wrote a wrapper script  cvslog.pl  which eliminates the non-relevant junk, 
that is, the files for which there are no matching revisions. The script also 
contains some code to scan for what we call Product Change Request (PCR) 
references which it can summarize at the end. You can just throw that code 
away. 

One further thing is that it DOESN'T display the header by default--you need to 
specify an option.

Here it is:

--------------snip--------------
#!/usr/local/bin/perl -w

use FileHandle;
autoflush STDOUT 1;

use Getopt::Long;
Getopt::Long::Configure("no_auto_abbrev", "pass_through", "no_ignore_case");
$listOnly = $showHeader = $listPcrsOnly = $listPcrs = 0;
GetOptions( 'list-only|l|L!' => \$listOnly,
            'show-header|h!' => \$showHeader,
            'list-pcrs|p!' => \$listPcrs,
            'list-pcrs-only|P!' => \$listPcrsOnly );

map {
    s/.*/'$&'/  if /[><\" ]/;
} @ARGV;


$cvsCmd = "cvs log @ARGV";
warn "% $cvsCmd\n"  unless $listPcrsOnly;
open LOG, "$cvsCmd 2>&1 |" or die "Can't launch cvs log: $!\n";

#if (!$listOnly && -t STDIN) {
#    open OUT, "| less" or die "Can't pipe output to pager: $!\n";
#    select OUT;
#}

%PCR = ();
$file = '';
while (defined ($_ = <LOG>)) {
    if (/^RCS file: / .. /^={77}$/) {
        if (/^RCS file: /) {
            $file = $1  if m{([\w\-\.]+/(Attic/)?[\w\-\.]+),v};
        }
        if ($hasFish) {
            if (/^revision (\d+(\.\d+)+)\s*$/) {
                chomp($fileRev = "$file:$1");
            } elsif (/^date:.*;\s+author:\s+(\w+);/) {
                $fileRev .= " ($1)";
            }
            while (m/\b(PCR\s*:?\s*)?(\d{5,6})\b/gi) {
                $pcr = $2;
                $PCR{$pcr}{$fileRev} = 1;
                $File{$file}{$pcr} = 1;
            }
            print  unless $listOnly || $listPcrsOnly;
        } else {
            if (!defined($fileName) && /^Working file: /) {
                $fileName = $';
            }
            push @Headers, $_  unless $listOnly;
            if ($hasFish = /^-{28}$/) {
                if ($listOnly && !$listPcrsOnly) {
                    print "$fileName";
                } else {
                    while (my $foo = shift @Headers) {
                        print $foo  
                          unless $listPcrsOnly
                            || !$showHeader
                            && ($foo =~ /^head:/
                                .. $foo =~ /^total revisions/);
                    }
                }
            }
        }
    } else {
        $hasFish = 0;
        undef $fileName;
        undef @Headers;
        $file = '';
        $fileRev = '';
    }
}

if ( $listPcrs || $listPcrsOnly ) {
    if (%PCR || %File) {
        print "\nPCR Summary for $cvsCmd\n";
        if (%PCR) {
            print "\nPCR/File references\n";
            my $tfn = "/tmp/cvslog-$$";
            open PCRIDS, ">$tfn"  or die "Can't open temp file $tfn: $!\n";
            foreach (sort keys %PCR) {
                if (/^\d{6}$/) {
                    print PCRIDS "$_\n";
                } else { 
                    $title{$_} = 
"http://oasis/cgi-bin/scopus/querydoc.cgi?doc_type=B&doc_id=$_";;
                }
            }
            close PCRIDS;
            open PCR, "pcrcquery -f $tfn -pcrid -title 2>/dev/null |"
              or die "Can't popen pcrcquery: $!\n";
            while (<PCR>) {
                chomp($title{$1} = $')  if /^(\d+)\s+\|/;
            }
            close PCR;
            warn "pcrcquery session may have failed: $!\n"  if $?;
            unlink $tfn;

            foreach $pcr (sort {$a <=> $b} keys %PCR) {
                print "\n  $pcr";
                print "  $title{$pcr}"  if exists $title{$pcr};
                print "\n";
                foreach $ref (sort keys %{$PCR{$pcr}}) {
                    print "    $ref\n";
                }
            }
        }
        if (%File) {
            print "\nFile/PCR references:\n";
            foreach $file (sort keys %File) {
                print "\n  $file\n";
                foreach $ref (sort {$a <=> $b} keys %{$File{$file}}) {
                    print "    $ref\n";
                }
            }
        }
    } else {
        warn "No PCRs cited in $cvsCmd\n";
    }
}
--------------snip--------------


> -----Original Message-----
> From: address@hidden [mailto:address@hidden Behalf Of
> Per Akesson
> Sent: Tuesday, August 14, 2001 3:26 AM
> To: address@hidden
> Subject: Re: log modifications
> 
> 
> Josh Baudhuin wrote:
> 
> > See  cvs -H log
> >
> > % cvs log -d dates -w[logins] ...
> >
> > e.g.
> >         cvs log -d">=2001/05/21" -w"luser" ...
> 
> I'm trying that but still I don't understand the output.
> 
> Example:
> 
> First a "normal" cvs log to get complete info:
> 
> cvs log
> 
> RCS file: /home/tlm/cvsroot/isfv/misc/encrypt/encrypt.cpp,v
> Working file: encrypt.cpp
> head: 1.1
> branch: 1.1.1
> locks: strict
> access list:
> symbolic names:
>  latest_from_vss: 1.1.1.1
>  Buildable_swafrap-v1_05p1+: 1.1.1.1
>  swafrap-v1_05p1+: 1.1.1.1
>  Buildable_UndFgO_v_1_0_a: 1.1.1.1
>  undfgo-v1_0_a: 1.1.1.1
>  Carmenta: 1.1.1
> keyword substitution: kv
> total revisions: 2; selected revisions: 2
> description:
> ----------------------------
> revision 1.1
> date: 2001/05/31 08:53:53;  author: pj;  state: Exp;
> branches:  1.1.1;
> Initial revision
> ----------------------------
> revision 1.1.1.1
> date: 2001/05/31 08:53:53;  author: pj;  state: Exp;  lines: +0 -0
> First version imported from Source Safe
> ==================================================================
> ===========
> 
> 
> 
> Then with search criteria:
> 
> cvs log -d">=2001/06/10" -w"pj"
> 
> RCS file: /home/tlm/cvsroot/isfv/misc/encrypt/encrypt.cpp,v
> Working file: encrypt.cpp
> head: 1.1
> branch: 1.1.1
> locks: strict
> access list:
> symbolic names:
>  latest_from_vss: 1.1.1.1
>  Buildable_swafrap-v1_05p1+: 1.1.1.1
>  swafrap-v1_05p1+: 1.1.1.1
>  Buildable_UndFgO_v_1_0_a: 1.1.1.1
>  undfgo-v1_0_a: 1.1.1.1
>  Carmenta: 1.1.1
> keyword substitution: kv
> total revisions: 2; selected revisions: 0
> description:
> ==================================================================
> ===========
> 
> 
> 
> Is above behaviour correct ?
> 
> I would have liked to only have the report of files with revisions
> newer than specified date.
> 
> Comments ?
> 
> --
> Per Ã…kesson
> Carmenta AB
> SWEDEN
> 
> 
> 
> 
> 
> _______________________________________________
> Info-cvs mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/info-cvs
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]