aboutsummaryrefslogtreecommitdiffstats
path: root/CVSROOT
diff options
context:
space:
mode:
authorjoe <joe@FreeBSD.org>2001-12-01 19:38:44 +0800
committerjoe <joe@FreeBSD.org>2001-12-01 19:38:44 +0800
commit4150d60782208f85547a3bdb3250f64422d66c89 (patch)
tree1c286e5bd7ffb905f7dcf926f73b712a2de3a457 /CVSROOT
parenta9b02836cd02e1e4383c1752ec723f86e2ff487b (diff)
downloadfreebsd-ports-graphics-4150d60782208f85547a3bdb3250f64422d66c89.tar.gz
freebsd-ports-graphics-4150d60782208f85547a3bdb3250f64422d66c89.tar.zst
freebsd-ports-graphics-4150d60782208f85547a3bdb3250f64422d66c89.zip
Add the ability to have diffs inserted into the commit email.
Submitted by: jesper
Diffstat (limited to 'CVSROOT')
-rwxr-xr-xCVSROOT/cfg.pm7
-rwxr-xr-xCVSROOT/log_accum.pl73
2 files changed, 78 insertions, 2 deletions
diff --git a/CVSROOT/cfg.pm b/CVSROOT/cfg.pm
index 734827e40fb..afb6b830e71 100755
--- a/CVSROOT/cfg.pm
+++ b/CVSROOT/cfg.pm
@@ -18,8 +18,8 @@ use vars qw(
@COMMIT_HOSTS $COMMITTER $DEBUG $EXCLUDE_FILE $FILE_PREFIX $IDHEADER
$LAST_FILE @LOG_FILE_MAP $MAILADDRS $MAILBANNER $MAILCMD
$MAIL_BRANCH_HDR $MAIL_ON_DIR_CREATION $MAIL_TRANSFORM $MINCVSVERSION
- $PID $PROG_CVS $PROG_MV %TEMPLATE_HEADERS $TMPDIR $UNEXPAND_RCSID
- $WARN_HEADERS
+ $MAX_DIFF_SIZE $PID $PROG_CVS $PROG_MV %TEMPLATE_HEADERS $TMPDIR
+ $UNEXPAND_RCSID $WARN_HEADERS
);
my $CVSROOT = $ENV{'CVSROOT'} || die "Can't determine \$CVSROOT!";
@@ -204,6 +204,9 @@ $MAIL_TRANSFORM = "";
'other' => '.*'
);
+# Include diffs of not greater than this size in kbytes in the
+# commit mail for each file modified. (0 = off).
+$MAX_DIFF_SIZE = 0;
diff --git a/CVSROOT/log_accum.pl b/CVSROOT/log_accum.pl
index cdbfa27f9da..1068d24ac3d 100755
--- a/CVSROOT/log_accum.pl
+++ b/CVSROOT/log_accum.pl
@@ -49,6 +49,7 @@ my $SUMMARY_FILE = "$BASE_FN.summary";
my $LOGNAMES_FILE = "$BASE_FN.lognames";
my $SUBJ_FILE = "$BASE_FN.subj";
my $TAGS_FILE = "$BASE_FN.tags";
+my $DIFF_FILE = "$BASE_FN.diff";
############################################################
@@ -552,6 +553,68 @@ sub format_summaries {
return @text;
}
+
+#
+# Make a diff of the changes.
+#
+sub do_diff {
+ my $outfile = shift;
+ my @filenames = @_; # List of files to check.
+
+ foreach my $file (@filenames) {
+ next unless $file;
+
+ my $diff;
+
+ my ($rev, $rcsfile) = get_revision_number($file);
+
+ #
+ # 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|tar|tgz|gz)$/i) or (-B $file)) {
+ $diff .= "Index: $file\n";
+ $diff .= "=" x 67 . "\n";
+ $diff .= "\t<<Binary file>>\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]+)$/) {
+ my $prev_rev = previous_revision($rev);
+
+ my @args = ();
+ if ($rev eq '1.1') {
+ $diff .= "Index: $file\n"
+ . "=" x 68 . "\n";
+ @args = ('-Qn', 'update', '-p',
+ '-r1.1', $file);
+ } else {
+ @args = ('-Qn', 'diff', '-u',
+ "-r$prev_rev", "-r$rev", $file);
+ }
+
+ print "Generating diff: $cfg::PROG_CVS " .
+ "@args" if $cfg::DEBUG;
+ open(DIFF, "-|") || exec $cfg::PROG_CVS, @args;
+ while(<DIFF>) {
+ $diff .= $_;
+ }
+ close DIFF;
+ }
+ }
+ if (length($diff) > $cfg::MAX_DIFF_SIZE * 1024) {
+ $diff = "File/diff for $file is too large! ";
+ $diff .= "Use cvsweb.\n";
+ }
+ &append_line($outfile, "\n\n$diff");
+ }
+}
+
#############################################################
#
# Main Body
@@ -726,10 +789,14 @@ foreach my $tag ( keys %removed_files ) {
foreach my $tag ( keys %added_files ) {
&change_summary_added("$SUMMARY_FILE.$message_index",
@{ $added_files{$tag} });
+ &do_diff("$DIFF_FILE.$message_index", @{ $added_files{$tag} })
+ if ( $cfg::MAX_DIFF_SIZE > 0 );
}
foreach my $tag ( keys %changed_files ) {
&change_summary_changed("$SUMMARY_FILE.$message_index",
@{ $changed_files{$tag} });
+ &do_diff("$DIFF_FILE.$message_index", @{ $changed_files{$tag} })
+ if ( $cfg::MAX_DIFF_SIZE > 0 );
}
foreach my $tag ( keys %removed_files ) {
&change_summary_removed("$SUMMARY_FILE.$message_index",
@@ -788,6 +855,12 @@ for (my $i = 0; ; $i++) {
#
&do_changes_file(@log_msg);
+ # Add the diff after writing the log files.
+ if (-e "$DIFF_FILE.$i") {
+ push @log_msg, " ", map {" $_"}
+ read_logfile("$DIFF_FILE.$i");
+ }
+
#
# Mail out the notification.
#