head	1.2;
access;
symbols
	HELM_PEER_PORT_BRANCH:1.1.1.1
	dlr:1.1.1;
locks; strict;
comment	@# @;


1.2
date	2000.07.12.04.39.41;	author jrobbins;	state dead;
branches;
next	1.1;

1.1
date	2000.02.02.05.39.56;	author jrobbins;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2001.02.21.00.31.47;	author dlr;	state Exp;
branches;
next	;


desc
@@


1.2
log
@removed regular file where .in file exists
@
text
@#!/usr/bin/perl
#
# Perl filter to handle the log messages from the checkin of files in
# a directory.  This script will group the lists of files by log
# message, and mail a single consolidated log message at the end of
# the commit.
#
# This file assumes a pre-commit checking program that leaves the
# names of the first and last commit directories in a temporary file.
#
# Contributed by David Hampton <hampton@@cisco.com>
# Roy Fielding removed useless code and added log/mail of new files
# Ken Coar added special processing (i.e., no diffs) for binary files
#

# Tigris libraries
# CONFIG - set this to /path/to/tigris/perl
use lib "/home/akosut/tigris/perl";
use Tigris::Database;

############################################################
#
# Configurable options
#
############################################################
#
# Where do you want the RCS ID and delta info?
# 0 = none,
# 1 = in mail only,
# 2 = rcsids in both mail and logs.
#
$rcsidinfo = 2;

############################################################
#
# Constants
#
############################################################
$STATE_NONE    = 0;
$STATE_CHANGED = 1;
$STATE_ADDED   = 2;
$STATE_REMOVED = 3;
$STATE_LOG     = 4;

$TMPDIR        = $ENV{'TMPDIR'} || '/tmp';
$FILE_PREFIX   = '#cvs.';

$LAST_FILE     = "$TMPDIR/${FILE_PREFIX}lastdir";
$CHANGED_FILE  = "$TMPDIR/${FILE_PREFIX}files.changed";
$ADDED_FILE    = "$TMPDIR/${FILE_PREFIX}files.added";
$REMOVED_FILE  = "$TMPDIR/${FILE_PREFIX}files.removed";
$LOG_FILE      = "$TMPDIR/${FILE_PREFIX}files.log";
$BRANCH_FILE   = "$TMPDIR/${FILE_PREFIX}files.branch";
$SUMMARY_FILE  = "$TMPDIR/${FILE_PREFIX}files.summary";

$CVSROOT       = $ENV{'CVSROOT'};

$MAIL_TO       = 'cvs';

############################################################
#
# Subroutines
#
############################################################

sub format_names {
    local($dir, @@files) = @@_;
    local(@@lines);

    $lines[0] = sprintf(" %-08s", $dir);
    foreach $file (@@files) {
	if (length($lines[$#lines]) + length($file) > 60) {
	    $lines[++$#lines] = sprintf(" %8s", " ");
	}
	$lines[$#lines] .= " ".$file;
    }
    @@lines;
}

sub cleanup_tmpfiles {
    local(@@files);

    opendir(DIR, $TMPDIR);
    push(@@files, grep(/^${FILE_PREFIX}.*\.${id}$/, readdir(DIR)));
    closedir(DIR);
    foreach (@@files) {
	unlink "$TMPDIR/$_";
    }
}

sub write_logfile {
    local($filename, @@lines) = @@_;

    open(FILE, ">$filename") || die ("Cannot open log file $filename: $!\n");
    print(FILE join("\n", @@lines), "\n");
    close(FILE);
}

sub append_to_file {
    local($filename, $dir, @@files) = @@_;

    if (@@files) {
	local(@@lines) = &format_names($dir, @@files);
	open(FILE, ">>$filename") || die ("Cannot open file $filename: $!\n");
	print(FILE join("\n", @@lines), "\n");
	close(FILE);
    }
}

sub write_line {
    local($filename, $line) = @@_;

    open(FILE, ">$filename") || die("Cannot open file $filename: $!\n");
    print(FILE $line, "\n");
    close(FILE);
}

sub append_line {
    local($filename, $line) = @@_;

    open(FILE, ">>$filename") || die("Cannot open file $filename: $!\n");
    print(FILE $line, "\n");
    close(FILE);
}

sub read_line {
    local($filename) = @@_;
    local($line);

    open(FILE, "<$filename") || die("Cannot open file $filename: $!\n");
    $line = <FILE>;
    close(FILE);
    chomp($line);
    $line;
}

sub read_file {
    local($filename, $leader) = @@_;
    local(@@text) = ();

    open(FILE, "<$filename") || return ();
    while (<FILE>) {
	chomp;
	push(@@text, sprintf("  %-10s  %s", $leader, $_));
	$leader = "";
    }
    close(FILE);
    @@text;
}

sub read_logfile {
    local($filename, $leader) = @@_;
    local(@@text) = ();

    open(FILE, "<$filename") || die ("Cannot open log file $filename: $!\n");
    while (<FILE>) {
	chomp;
	push(@@text, $leader.$_);
    }
    close(FILE);
    @@text;
}

#
# do an 'cvs -Qn status' on each file in the arguments, and extract info.
#
sub change_summary {
    local($out, @@filenames) = @@_;
    local(@@revline);
    local($file, $rev, $rcsfile, $line);

    while (@@filenames) {
	$file = shift @@filenames;

	if ("$file" eq "") {
	    next;
	}

	open(RCS, "-|") || exec "$cvsbin/cvs", '-Qn', 'status', $file;

	$rev = "";
	$delta = "";
	$rcsfile = "";


	while (<RCS>) {
	    if (/^[ \t]*Repository revision/) {
		chomp;
		@@revline = split(' ', $_);
		$rev = $revline[2];
		$rcsfile = $revline[3];
		$rcsfile =~ s,^$CVSROOT/,,;
		$rcsfile =~ s/,v$//;
	    }
	}
	close(RCS);


	if ($rev ne '' && $rcsfile ne '') {
	    open(RCS, "-|") || exec "$cvsbin/cvs", '-Qn', 'log', "-r$rev", $file;
	    while (<RCS>) {
		if (/^date:/) {
		    chomp;
		    $delta = $_;
		    $delta =~ s/^.*;//;
		    $delta =~ s/^[\s]+lines://;
		}
	    }
	    close(RCS);
	}

	$diff = "\n\n";

	#
	# If this is a binary file, don't try to report a diff; not only is
	# it meaningless, but it also screws up some mailers.  We rely on
	# Perl's 'is this binary' algorithm; it's pretty good.  But not
	# perfect.
	#
	if (($file =~ /\.(?:pdf|gif|jpg|mpg)$/i) || (-B $file)) {
	    $diff .= "\t<<Binary file>>\n\n";
	}
	else {
	    #
	    # Get the differences between this and the previous revision,
	    # being aware that new files always have revision '1.1' and
	    # new branches always end in '.n.1'.
	    #
	    if ($rev =~ /^(.*)\.([0-9]+)$/) {
		$prev = $2 - 1;
		$prev_rev = $1 . '.' .  $prev;

		$prev_rev =~ s/\.[0-9]+\.0$//;# Truncate if first rev on branch

		if ($rev eq '1.1') {
		    open(DIFF, "-|")
			|| exec "$cvsbin/cvs", '-Qn', 'update', '-p', '-r1.1', $file;
		    $diff .= "Index: $file\n=================================="
			. "=================================\n";
		}
		else {
		    open(DIFF, "-|")
			|| exec "$cvsbin/cvs", '-Qn', 'diff', '-u',
			      "-r$prev_rev", "-r$rev", $file;
		}

		while (<DIFF>) {
		    $diff .= $_;
		}
		close(DIFF);
		$diff .= "\n\n";
	    }
	}

	&append_line($out, sprintf("%-9s%-12s%s%s", $rev, $delta,
				   $rcsfile, $diff));
    }
}


sub build_header {
    local($header);
    delete $ENV{'TZ'};
    local($sec,$min,$hour,$mday,$mon,$year) = localtime(time);

    $header = sprintf("%-8s    %02d/%02d/%02d %02d:%02d:%02d",
		       $login, $year%100, $mon+1, $mday,
		       $hour, $min, $sec);
}

# !!! Mailing-list and history file mappings here !!!
sub mlist_map
{
    local($path) = @@_;
    my $domain = $db->config('domain_dns');
    
    if ($path =~ /^([^\/]+)/) {
	return "cvs\@@$1.$domain";
    } else {
	return "cvs\@@$domain";
    }
}    

sub do_changes_file
{
    local($category, @@text) = @@_;
    local($changes);

    $changes = "$CVSROOT/CVSROOT/commitlogs/$category";

    if (open(CHANGES, ">>$changes")) {
        print(CHANGES join("\n", @@text), "\n\n");
        close(CHANGES);
    }
    else { 
        warn "Cannot open $changes: $!\n";
    }
}

sub mail_notification
{
    local(@@text) = @@_;

    print "Mailing the commit message...\n";

    open(MAIL, "| mail -s \"cvs commit: $ARGV[0]\" $MAIL_TO");
    print(MAIL join("\n", @@text));
    close(MAIL);
}

#############################################################
#
# Main Body
#
############################################################
#
# Setup environment
#
umask (002);

# Connect to the database
$db = new Tigris::Database;
$cvsbin = $db->config('cvs_cvsbin');

#
# Initialize basic variables
#
$id = getpgrp();
$state = $STATE_NONE;
$login = $ENV{'USER'} || getlogin || (getpwuid($<))[0] || sprintf("uid#%d",$<);
@@files = split(' ', $ARGV[0]);
@@path = split('/', $files[0]);
$repository = $path[0];
if ($#path == 0) {
    $dir = ".";
} else {
    $dir = join('/', @@path[1..$#path]);
}
#print("ARGV  - ", join(":", @@ARGV), "\n");
#print("files - ", join(":", @@files), "\n");
#print("path  - ", join(":", @@path), "\n");
#print("dir   - ", $dir, "\n");
#print("id    - ", $id, "\n");

#
# Map the repository directory to a name for commitlogs.
#
$mlist = &mlist_map($files[0]);

##########################
# Uncomment the following if we ever have per-repository cvs mail

 if (defined($mlist)) {
     $MAIL_TO = $mlist
 }
# else { undef $MAIL_TO; }

##########################
#
# Check for a new directory first.  This will always appear as a
# single item in the argument list, and an empty log message.
#
if ($ARGV[0] =~ /New directory/) {
    $header = &build_header;
    @@text = ();
    push(@@text, $header);
    push(@@text, "");
    push(@@text, "  ".$ARGV[0]);
    &do_changes_file($mlist, @@text);
    &mail_notification(@@text) if defined($MAIL_TO);
    exit 0;
}

#
# Iterate over the body of the message collecting information.
#
while (<STDIN>) {
    chomp;			# Drop the newline
    if (/^Revision\/Branch:/) {
        s,^Revision/Branch:,,;
        push (@@branch_lines, split);
        next;
    }
#    next if (/^[ \t]+Tag:/ && $state != $STATE_LOG);
    if (/^Modified Files/) { $state = $STATE_CHANGED; next; }
    if (/^Added Files/)    { $state = $STATE_ADDED;   next; }
    if (/^Removed Files/)  { $state = $STATE_REMOVED; next; }
    if (/^Log Message/)    { $state = $STATE_LOG;     next; }
    s/[ \t\n]+$//;		# delete trailing space
    
    push (@@changed_files, split) if ($state == $STATE_CHANGED);
    push (@@added_files,   split) if ($state == $STATE_ADDED);
    push (@@removed_files, split) if ($state == $STATE_REMOVED);
    if ($state == $STATE_LOG) {
	if (/^PR:$/i ||
	    /^Reviewed by:$/i ||
	    /^Submitted by:$/i ||
	    /^Obtained from:$/i) {
	    next;
	}
	push (@@log_lines,     $_);
    }
}

#
# Strip leading and trailing blank lines from the log message.  Also
# compress multiple blank lines in the body of the message down to a
# single blank line.
# (Note, this only does the mail and changes log, not the rcs log).
#
while ($#log_lines > -1) {
    last if ($log_lines[0] ne "");
    shift(@@log_lines);
}
while ($#log_lines > -1) {
    last if ($log_lines[$#log_lines] ne "");
    pop(@@log_lines);
}
for ($i = $#log_lines; $i > 0; $i--) {
    if (($log_lines[$i - 1] eq "") && ($log_lines[$i] eq "")) {
	splice(@@log_lines, $i, 1);
    }
}

#
# Find the log file that matches this log message
#
for ($i = 0; ; $i++) {
    last if (! -e "$LOG_FILE.$i.$id");
    @@text = &read_logfile("$LOG_FILE.$i.$id", "");
    last if ($#text == -1);
    last if (join(" ", @@log_lines) eq join(" ", @@text));
}

#
# Spit out the information gathered in this pass.
#
&write_logfile("$LOG_FILE.$i.$id", @@log_lines);
&append_to_file("$BRANCH_FILE.$i.$id",  $dir, @@branch_lines);
&append_to_file("$ADDED_FILE.$i.$id",   $dir, @@added_files);
&append_to_file("$CHANGED_FILE.$i.$id", $dir, @@changed_files);
&append_to_file("$REMOVED_FILE.$i.$id", $dir, @@removed_files);
if ($rcsidinfo) {
    &change_summary("$SUMMARY_FILE.$i.$id", (@@changed_files, @@added_files));
}

#
# Check whether this is the last directory.  If not, quit.
#
if (-e "$LAST_FILE.$id") {
   $_ = &read_line("$LAST_FILE.$id");
   $tmpfiles = $files[0];
   $tmpfiles =~ s,([^a-zA-Z0-9_/]),\\$1,g;
   if (! grep(/$tmpfiles$/, $_)) {
	print "More commits to come...\n";
	exit 0
   }
}

#
# This is it.  The commits are all finished.  Lump everything together
# into a single message, fire a copy off to the mailing list, and drop
# it on the end of the Changes file.
#
$header = &build_header;

#
# Produce the final compilation of the log messages
#
@@text = ();
push(@@text, $header);
push(@@text, "");
for ($i = 0; ; $i++) {
    last if (! -e "$LOG_FILE.$i.$id");
    push(@@text, &read_file("$BRANCH_FILE.$i.$id", "Branch:"));
    push(@@text, &read_file("$CHANGED_FILE.$i.$id", "Modified:"));
    push(@@text, &read_file("$ADDED_FILE.$i.$id", "Added:"));
    push(@@text, &read_file("$REMOVED_FILE.$i.$id", "Removed:"));
    push(@@text, "  Log:");
    push(@@text, &read_logfile("$LOG_FILE.$i.$id", "  "));
    if ($rcsidinfo == 2) {
	if (-e "$SUMMARY_FILE.$i.$id") {
	    push(@@text, "  ");
	    push(@@text, "  Revision  Changes    Path");
	    push(@@text, &read_logfile("$SUMMARY_FILE.$i.$id", "  "));
	}
    }
    push(@@text, "");
}
#
# Append the log message to the commitlogs/<module> file
#
&do_changes_file($mlist, @@text);
#
# Now generate the extra info for the mail message..
#
if ($rcsidinfo == 1) {
    $revhdr = 0;
    for ($i = 0; ; $i++) {
	last if (! -e "$LOG_FILE.$i.$id");
	if (-e "$SUMMARY_FILE.$i.$id") {
	    if (!$revhdr++) {
		push(@@text, "Revision  Changes    Path");
	    }
	    push(@@text, &read_logfile("$SUMMARY_FILE.$i.$id", ""));
	}
    }
    if ($revhdr) {
	push(@@text, "");	# consistancy...
    }
}
#
# Mail out the notification.
#
&mail_notification(@@text) if defined($MAIL_TO);
&cleanup_tmpfiles;
exit 0;
@


1.1
log
@iniital checkin
@
text
@@


1.1.1.1
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@a10 19
# IMPORTANT: what the above means is, this script interacts with
# commit_prep, in that they have to agree on the tmpfile name to use.
# See $LAST_FILE below. 
#
# How this works: CVS triggers this script once for each directory
# involved in the commit -- in other words, a single commit can invoke
# this script N times.  It knows when it's on the last invocation by
# examining the contents of $LAST_FILE.  Between invocations, it
# caches information for its future incarnations in various temporary
# files in /tmp, which are named according to the process group and
# the committer (by themselves, neither of these are unique, but
# together they almost always are, unless the same user is doing two
# commits simultaneously).  The final invocation is the one that
# actually sends the mail -- it gathers up the cached information,
# combines that with what it found out on this pass, and sends a
# commit message to the appropriate mailing list.
#
# (Ask Karl Fogel <kfogel@@collab.net> if questions.)
#
d18 2
a19 2
use lib "/home/dlr/sandbox/helm/perl";
use Helm::Database;
d30 1
a30 1
# 2 = in both mail and logs.
a33 10
#if you are using CVS web then set this to some value... if not set it to ""
$CVSWEB = "http://sc-dev2.sp.collab.net/source/browse/";

# Set this to a domain to have CVS pretend that all users who make
# commits have mail accounts within that domain.
$EMULATE_LOCAL_MAIL_USER=""; 

# Set this to '-c' for context diffs; defaults to '-u' for unidiff format.
$difftype = '-u';

d48 1
a48 1
$LAST_FILE     = "$TMPDIR/${FILE_PREFIX}lastdir";  # Created by commit_prep!
d58 1
a58 8
$CVSBIN        = '/usr/local/bin';
$PATH          = "$PATH:/bin:/usr/bin";
#$MAIL_CMD      = "| /usr/lib/sendmail -i -t";
$MAIL_CMD      = "| /var/qmail/bin/qmail-inject";
$MAIL_TO       = 'cvs';   # was user@@mycompany.com
$MAIL_FROM     = 'commitlogger';  #not needed if EMULATE_LOCAL_MAIL_USER
$SUBJECT_PRE   = 'CVS update:';

d72 4
a75 4
        if (length($lines[$#lines]) + length($file) > 60) {
            $lines[++$#lines] = sprintf(" %8s", " ");
        }
        $lines[$#lines] .= " ".$file;
d84 1
a84 1
    push(@@files, grep(/^${FILE_PREFIX}.*\.${id}\.${cvs_user}$/, readdir(DIR)));
d87 1
a87 1
        unlink "$TMPDIR/$_";
d103 4
a106 4
        local(@@lines) = &format_names($dir, @@files);
        open(FILE, ">>$filename") || die ("Cannot open file $filename: $!\n");
        print(FILE join("\n", @@lines), "\n");
        close(FILE);
d143 3
a145 3
        chomp;
        push(@@text, sprintf("  %-10s  %s", $leader, $_));
        $leader = "";
d157 2
a158 2
        chomp;
        push(@@text, $leader.$_);
d173 1
a173 1
        $file = shift @@filenames;
d175 79
a253 81
        if ("$file" eq "") {
            next;
        }

        open(RCS, "-|") || exec "$cvsbin/cvs", '-Qn', 'status', $file;

        $rev = "";
        $delta = "";
        $rcsfile = "";


        while (<RCS>) {
            if (/^[ \t]*Repository revision/) {
                chomp;
                @@revline = split(' ', $_);
                $rev = $revline[2];
                $rcsfile = $revline[3];
                $rcsfile =~ s,^$CVSROOT/,,;
                $rcsfile =~ s/,v$//;
            }
        }
        close(RCS);


        if ($rev ne '' && $rcsfile ne '') {
            open(RCS, "-|") || exec "$cvsbin/cvs", '-Qn', 'log', "-r$rev", $file;
            while (<RCS>) {
                if (/^date:/) {
                    chomp;
                    $delta = $_;
                    $delta =~ s/^.*;//;
                    $delta =~ s/^[\s]+lines://;
                }
            }
            close(RCS);
        }

        $diff = "\n\n";

        #
        # If this is a binary file, don't try to report a diff; not only is
        # it meaningless, but it also screws up some mailers.  We rely on
        # Perl's 'is this binary' algorithm; it's pretty good.  But not
        # perfect.
        #
        if (($file =~ /\.(?:pdf|gif|jpg|mpg)$/i) || (-B $file)) {
            $diff .= "\t<<Binary file>>\n\n";
        }
        else {
            #
            # Get the differences between this and the previous revision,
            # being aware that new files always have revision '1.1' and
            # new branches always end in '.n.1'.
            #
            if ($rev =~ /^(.*)\.([0-9]+)$/) {
                $prev = $2 - 1;
                $prev_rev = $1 . '.' .  $prev;

                $prev_rev =~ s/\.[0-9]+\.0$//;# Truncate if first rev on branch

                if ($rev eq '1.1') {
                    open(DIFF, "-|")
                        || exec "$cvsbin/cvs", '-Qn', 'update', '-p', '-r1.1', $file;
                    $diff .= "Index: $file\n=================================="
                        . "=================================\n";
                }
                else {
                  $diff .= "(In the diff below, changes in quantity "
                      . "of whitespace are not shown.)\n\n";
                    open(DIFF, "-|")
                        || exec "$cvsbin/cvs", '-Qn', 'diff', "$difftype",
                                '-b', "-r$prev_rev", "-r$rev", $file;
                }

                while (<DIFF>) {
                    $diff .= $_;
                }
                close(DIFF);
                $diff .= "\n\n";
            }
        }
d255 2
a256 2
        &append_line($out, sprintf("%-9s%-12s%s%s", $rev, $delta,
                                   $rcsfile, $diff));
d266 3
a268 6
    $header = sprintf("  User: %-8s\n  Date: %02d/%02d/%02d %02d:%02d:%02d",
                       $cvs_user, $year%100, $mon+1, $mday,
                       $hour, $min, $sec);
#    $header = sprintf("%-8s    %02d/%02d/%02d %02d:%02d:%02d",
#                       $login, $year%100, $mon+1, $mday,
#                       $hour, $min, $sec);
d278 1
a278 1
        return "cvs\@@$1.$domain";
d280 1
a280 1
        return "cvs\@@$domain";
d290 1
a299 37
sub derive_subject_from_changes_file ()
{
  my $subj = "";

  for ($i = 0; ; $i++)
  {
    open (CH, "<$CHANGED_FILE.$i.$id.$cvs_user") or last;

    while (my $change = <CH>)
    {
      # A changes file looks like this:
      #
      #  src      foo.c newfile.html
      #  www      index.html project_nav.html
      #
      # Each line is " Dir File1 File2 ..."
      # We only care about Dir, since the subject line should
      # summarize. 
      
      $change =~ s/^[ \t]*//;
      $change =~ /^([^ \t]+)[ \t]*/;
      my $dir = $1;
      # Fold to rightmost directory component
      $dir =~ /([^\/]+)$/;
      $dir = $1;
      if ($subj eq "") {
        $subj = $dir;
      } else {
        $subj .= ", $dir"; 
      }
    }
    close (CH);
  }

  return $subj;
}

d304 1
a304 11
    my $subj = &derive_subject_from_changes_file ();

    if ($EMULATE_LOCAL_MAIL_USER NE "") {
        $MAIL_FROM = "$cvs_user\@@$EMULATE_LOCAL_MAIL_USER";
    }

    print "Mailing the commit message to $MAIL_TO (from $MAIL_FROM)\n";

    $ENV{'MAILUSER'} = $MAIL_FROM;
    # Commented out on hocus, so comment it out here.  -kff
    # $ENV{'QMAILINJECT'} = 'f';
d306 1
a306 4
    open(MAIL, "$MAIL_CMD -f$MAIL_FROM");
    print MAIL "From: $MAIL_FROM\n";
    print MAIL "To: $MAIL_TO\n";
    print MAIL "Subject: $SUBJECT_PRE $subj\n\n";
a308 37
#    print "Mailing the commit message to $MAIL_TO...\n";
#
#    #added by jrobbins@@collab.net 1999/12/15
#    # attempt to get rid of anonymous
#    $ENV{'MAILUSER'} = 'commitlogger';
#    $ENV{'QMAILINJECT'} = 'f';
#
#    open(MAIL, "| /var/qmail/bin/qmail-inject");
#    print(MAIL "To: $MAIL_TO\n"); 
#    print(MAIL "Subject: cvs commit: $ARGV[0]\n"); 
#    print(MAIL join("\n", @@text));
#    close(MAIL);
}

## process the command line arguments sent to this script
## it returns an array of files, %s, sent from the loginfo
## command
sub process_argv
{
    local(@@argv) = @@_;
    local(@@files);
    local($arg);
    print "Processing log script arguments...\n";

    while (@@argv) {
        $arg = shift @@argv;

        if ($arg eq '-u') {
                $cvs_user = shift @@argv;
        } else {
                ($donefiles) && die "Too many arguments!\n";
                $donefiles = 1;
                $ARGV[0] = $arg;
                @@files = split(' ', $arg);
        }
    }
    return @@files;
a310 1

d322 1
a322 1
$db = new Helm::Database;
d330 2
a331 2
$cvs_user = $ENV{'USER'} || getlogin || (getpwuid($<))[0] || sprintf("uid#%d",$<);
@@files = process_argv(@@ARGV);
d378 1
a378 1
    chomp;                      # Drop the newline
d389 1
a389 1
    s/[ \t\n]+$//;              # delete trailing space
d395 7
a401 7
        if (/^PR:$/i ||
            /^Reviewed by:$/i ||
            /^Submitted by:$/i ||
            /^Obtained from:$/i) {
            next;
        }
        push (@@log_lines,     $_);
d421 1
a421 1
        splice(@@log_lines, $i, 1);
d429 2
a430 2
    last if (! -e "$LOG_FILE.$i.$id.$cvs_user");
    @@text = &read_logfile("$LOG_FILE.$i.$id.$cvs_user", "");
d438 5
a442 5
&write_logfile("$LOG_FILE.$i.$id.$cvs_user", @@log_lines);
&append_to_file("$BRANCH_FILE.$i.$id.$cvs_user",  $dir, @@branch_lines);
&append_to_file("$ADDED_FILE.$i.$id.$cvs_user",   $dir, @@added_files);
&append_to_file("$CHANGED_FILE.$i.$id.$cvs_user", $dir, @@changed_files);
&append_to_file("$REMOVED_FILE.$i.$id.$cvs_user", $dir, @@removed_files);
d444 1
a444 1
    &change_summary("$SUMMARY_FILE.$i.$id.$cvs_user", (@@changed_files, @@added_files));
d450 2
a451 2
if (-e "$LAST_FILE.$id.$cvs_user") {
   $_ = &read_line("$LAST_FILE.$id.$cvs_user");
d455 2
a456 2
        print "More commits to come...\n";
        exit 0
d474 5
a478 5
    last if (! -e "$LOG_FILE.$i.$id.$cvs_user");
    push(@@text, &read_file("$BRANCH_FILE.$i.$id.$cvs_user", "Branch:"));
    push(@@text, &read_file("$CHANGED_FILE.$i.$id.$cvs_user", "Modified:"));
    push(@@text, &read_file("$ADDED_FILE.$i.$id.$cvs_user", "Added:"));
    push(@@text, &read_file("$REMOVED_FILE.$i.$id.$cvs_user", "Removed:"));
d480 1
a480 1
    push(@@text, &read_logfile("$LOG_FILE.$i.$id.$cvs_user", "  "));
d482 5
a486 5
        if (-e "$SUMMARY_FILE.$i.$id.$cvs_user") {
            push(@@text, "  ");
            push(@@text, "  Revision  Changes    Path");
            push(@@text, &read_logfile("$SUMMARY_FILE.$i.$id.$cvs_user", "  "));
        }
d500 7
a506 7
        last if (! -e "$LOG_FILE.$i.$id.$cvs_user");
        if (-e "$SUMMARY_FILE.$i.$id.$cvs_user") {
            if (!$revhdr++) {
                push(@@text, "Revision  Changes    Path");
            }
            push(@@text, &read_logfile("$SUMMARY_FILE.$i.$id.$cvs_user", ""));
        }
d509 1
a509 1
        push(@@text, "");        # consistancy...
@


