Date: Fri, 14 Sep 2001 02:28:11 +0100 From: Josef Karthauser <joe@tao.org.uk> To: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Proposed patch to log_accum.pl Message-ID: <20010914022811.E28588@tao.org.uk>
next in thread | raw e-mail | index | archive | help
--iBwuxWUsK/REspAd Content-Type: multipart/mixed; boundary="+JUInw4efm7IfTNU" Content-Disposition: inline --+JUInw4efm7IfTNU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, I've attached a patch to CVSROOT/log_accum.pl that I'd like comments on before I commit it. At the moment we get a summary line for each modified file in the commit email, i.e.: =20 Revision Changes Path 1.108 +6 -5 src/sys/kern/kern_descrip.c The attached patch caused us to also get these lines for added and removed files. It's been suggested that the revision number be followed with "(dead)" in the case of removed files. Is this necessary? Thanks in advance, Joe --+JUInw4efm7IfTNU Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch Content-Transfer-Encoding: quoted-printable --- log_accum.pl Sun Aug 19 05:17:05 2001 +++ /d/home/joe/cvsroot-test/CVSROOT/log_accum.pl Thu Sep 13 18:17:03 2001 @@ -222,8 +222,33 @@ =20 =20 # -# Summarise the file changes in the commit using 'cvs -Qn status' -# on each file to extract the info. +# Use 'cvs status' to obtain the current revision number of a given file. +# +sub get_revision_number { + my $file =3D shift; + + my $rcsfile =3D ""; + my $revision =3D ""; + + open(RCS, "-|") || exec 'cvs', '-Qn', 'status', $file; + while (<RCS>) { + if (/^[ \t]*Repository revision/) { + chomp; + my @revline =3D split; + $revision =3D $revline[2]; + $revline[3] =3D~ m|^$CVSROOT/+(.*),v$|; + $rcsfile =3D $1; + last; + } + } + close RCS; + + return($revision, $rcsfile); +} + + +# +# Summarise details of the file modifications. # sub change_summary_changed { my $outfile =3D shift; # File name of output file. @@ -232,22 +257,8 @@ foreach my $file (@filenames) { next unless $file; =20 - my $rev =3D ""; my $delta =3D ""; - my $rcsfile =3D ""; - - open(RCS, "-|") || exec 'cvs', '-Qn', 'status', $file; - while (<RCS>) { - if (/^[ \t]*Repository revision/) { - chomp; - my @revline =3D split; - $rev =3D $revline[2]; - $revline[3] =3D~ m|^$CVSROOT/+(.*),v$|; - $rcsfile =3D $1; - last; - } - } - close RCS; + my ($rev, $rcsfile) =3D get_revision_number($file); =20 if ($rev and $rcsfile) { open(RCS, "-|") || exec 'cvs', '-Qn', 'log', "-r$rev", $file; @@ -264,10 +275,64 @@ } } =20 -# Write these one day. +# +# Summarise details of added files. +# sub change_summary_added { + my $outfile =3D shift; # File name of output file. + my @filenames =3D @_; # List of files to check. + + foreach my $file (@filenames) { + next unless $file; + + my $delta =3D ""; + my ($rev, $rcsfile) =3D get_revision_number($file); + + # Fake up a delta. + if (open(FILE, "<$file")) { + my $lines =3D 0; + while (<FILE>) { + ++$lines; + } + + $delta =3D "+$lines -0"; + close FILE; + } + + &append_line($outfile, "$rev,$delta,$rcsfile"); + } } + +# +# Summarise details of removed files. +# sub change_summary_removed { + my $outfile =3D shift; # File name of output file. + my @filenames =3D @_; # List of files to check. + + foreach my $file (@filenames) { + next unless $file; + + my $delta =3D ""; + my ($rev, $rcsfile) =3D get_revision_number($file); + $rcsfile =3D~ s|/Attic/|/|; # Remove 'Attic/' if present. + + if ($rev and $rcsfile) { + $rev =3D~ /(.*)\.([^\.]+)$/; + my $oldrev =3D "$1." . ($2 - 1); + + my $lines =3D 0; + open(RCS, "-|") || exec 'cvs', '-Qn', 'update', '-p', "-r$oldrev", $fil= e; + while (<RCS>) { + ++$lines; + } + close RCS; + + $delta =3D "+0 -$lines"; + } + + &append_line($outfile, "$rev,$delta,$rcsfile"); + } } =20 sub build_header { @@ -445,7 +510,9 @@ my @text; my $fmt =3D "%-" . $r_max . "s%-" . $d_max . "s%s"; push @text, sprintf $fmt, "Revision", "Changes", "Path"; - foreach (0 .. $#revs) { + + my @order =3D sort { $files[$a] cmp $files[$b] } (0 .. $#revs); + foreach (@order) { push @text, sprintf $fmt, $revs[$_], $deltas[$_], $files[$_]; } =20 --+JUInw4efm7IfTNU-- --iBwuxWUsK/REspAd Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (FreeBSD) Comment: For info see http://www.gnupg.org iEYEARECAAYFAjuhXSoACgkQXVIcjOaxUBbbswCdHi2yR5zlJzul+EhDc8ROQOwt BS8AnAngtd674C91NLcnubZUIu+1gVfn =WuYh -----END PGP SIGNATURE----- --iBwuxWUsK/REspAd-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010914022811.E28588>