diff options
Diffstat (limited to 'BitKeeper/triggers')
-rwxr-xr-x | BitKeeper/triggers/post-commit | 134 | ||||
-rwxr-xr-x | BitKeeper/triggers/post-commit.innodb.pl | 22 | ||||
-rwxr-xr-x | BitKeeper/triggers/post-incoming.innodb.pl | 30 | ||||
-rwxr-xr-x | BitKeeper/triggers/pre-commit | 22 | ||||
-rwxr-xr-x | BitKeeper/triggers/pre-commit.check-case.pl | 26 | ||||
-rwxr-xr-x | BitKeeper/triggers/pre-commit.innodb.pl | 21 | ||||
-rwxr-xr-x | BitKeeper/triggers/pre-delta | 22 | ||||
-rwxr-xr-x | BitKeeper/triggers/pre-outgoing.crash-protect.pl | 82 | ||||
-rwxr-xr-x | BitKeeper/triggers/pre-resolve.crash-protect.pl | 82 | ||||
-rw-r--r-- | BitKeeper/triggers/triggers-lib.pl | 356 |
10 files changed, 0 insertions, 797 deletions
diff --git a/BitKeeper/triggers/post-commit b/BitKeeper/triggers/post-commit deleted file mode 100755 index c3a61ed2dde..00000000000 --- a/BitKeeper/triggers/post-commit +++ /dev/null @@ -1,134 +0,0 @@ -#!/bin/sh - -#shift -if [ -n "$BK_USER" ] -then - COMMITTER=$BK_USER -else - COMMITTER=$USER -fi -FROM=$COMMITTER@mysql.com -COMMITS=commits@lists.mysql.com -DOCS=docs-commit@mysql.com -LIMIT=10000 -VERSION="5.1" -BKROOT=`bk root` - -if [ -x /usr/sbin/sendmail ]; then - SENDMAIL=/usr/sbin/sendmail -else - SENDMAIL=sendmail -fi - -if [ "$REAL_EMAIL" = "" ] -then - echo "Warning: you must set REAL_EMAIL in your profile" -else - FROM=$REAL_EMAIL -fi - -BK_STATUS=$BK_STATUS$BK_COMMIT - -if [ "$BK_STATUS" = OK ] -then - -HAS_ACTUAL_CHANGES=`bk cset -r+ -d | grep -v "^#"` -if [ "$HAS_ACTUAL_CHANGES" = "" ] -then - echo ChangeSet had no real changes, not sending emails - exit -fi - -IS_MERGE=`bk changes -r+ -k -m` -if [ "$IS_MERGE" = "" ] -then - echo Merge changeset, not sending mails - exit -fi - -CHANGESET=`bk -R prs -r+ -h -d':P:::I:' ChangeSet` -CSETKEY=`bk -R prs -r+ -h -d':KEY:' ChangeSet` -# -# composing subject lines of commit mails. -# if a fix targets to a WL and there is a bug referred -# then X-Bug mail header will contain the first found bug's number -# -BUG=`bk -R prs -r+ -h -d':C:' ChangeSet | \ - sed -ne 's/[Bb][Uu][Gg] *# *\([0-9][0-9]*\).*$/BUG#\1/ - s/.*BUG#\([0-9][0-9]*\)/\1/p'` -WL=`bk -R prs -r+ -h -d':C:' ChangeSet | \ - sed -ne 's/[Ww][Ll] *# *\([0-9][0-9]*\).*$/WL#\1/ - s/.*\(WL#[0-9][0-9]*\)/ \1/p'` -if [ "$BUG" = "" ] -then -# TO=dev-public@mysql.com - BS="" - BH="" -else -# TO=dev-bugs@mysql.com - BS=" BUG#$BUG" -# need newline here - BH="X-Bug: $BUG -" -fi - -#++ -# commits@ or dev-private@ mail -#-- - -LIST="commits" -TO="commits@lists.mysql.com" -if [ -f .tree-is-private ] -then - LIST="dev-private" - TO="dev-private@mysql.com" -fi - - echo "Notifying $LIST list at $TO" - ( - cat <<EOF -List-ID: <bk.mysql-$VERSION> -From: $FROM -To: $TO -Subject: bk commit into $VERSION tree ($CHANGESET)$BS -X-CSetKey: <$CSETKEY> -$BH -Below is the list of changes that have just been committed into a local -$VERSION repository of $COMMITTER. When $COMMITTER does a push these changes -will be propagated to the main repository and, within 24 hours after the -push, to the public repository. -For information on how to access the public repository -see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html - -EOF - bk changes -v -r+ - bk rset -r+ -ah | bk gnupatch -h -dup -T - ) | bk sed -e ${LIMIT}q > $BKROOT/BitKeeper/tmp/commits.txt - -$SENDMAIL -t < $BKROOT/BitKeeper/tmp/commits.txt - -#++ -# docs-commit@ mail -# Picks up anything under the Docs subdirectory (relevant for docs team). -#-- - bk changes -v -r+ | grep -q " Docs/" - if [ $? -eq 0 ] - then - echo "Notifying docs list at $DOCS" - ( - cat <<EOF -List-ID: <bk.mysql-$VERSION> -From: $FROM -To: $DOCS -Subject: bk commit - $VERSION tree (Manual) ($CHANGESET)$BS - -EOF - bk changes -v -r+ - bk rset -r+ -ah | bk gnupatch -h -dup -T - ) > $BKROOT/BitKeeper/tmp/docs.txt - $SENDMAIL -t < $BKROOT/BitKeeper/tmp/docs.txt - fi - -else - echo "commit failed because '$BK_STATUS', you may need to re-clone..." -fi diff --git a/BitKeeper/triggers/post-commit.innodb.pl b/BitKeeper/triggers/post-commit.innodb.pl deleted file mode 100755 index 44d98b04838..00000000000 --- a/BitKeeper/triggers/post-commit.innodb.pl +++ /dev/null @@ -1,22 +0,0 @@ -#! /usr/bin/perl - -use strict; -use warnings; - -use FindBin; -require "$FindBin::Bin/triggers-lib.pl"; - -# Don't run unless commit was successful -check_status() || exit 0; - -my $cset = latest_cset(); - -# Read most recent ChangeSet's changed files. Send merge changes along, since -# they'll need to be incorporated in InnoDB's source tree eventually. -my $changes = innodb_get_changes('cset', $cset, 'yes') - or exit 0; - -innodb_send_changes_email($cset, $changes) - or exit 1; - -exit 0; diff --git a/BitKeeper/triggers/post-incoming.innodb.pl b/BitKeeper/triggers/post-incoming.innodb.pl deleted file mode 100755 index 4b100d88037..00000000000 --- a/BitKeeper/triggers/post-incoming.innodb.pl +++ /dev/null @@ -1,30 +0,0 @@ -#! /usr/bin/perl - -use strict; -use warnings; - -use FindBin; -require "$FindBin::Bin/triggers-lib.pl"; - -# Don't run unless push/pull was successful -check_status() or exit 0; - -# Don't run if push/pull is in local clones -exit 0 if repository_type() eq 'local'; - -# For each pushed ChangeSet, check it for InnoDB files and send -# diff of entire ChangeSet to InnoDB developers if such changes -# exist. - -my $error = 0; - -foreach my $cset (read_bk_csetlist()) -{ - my $changes = innodb_get_changes('cset', $cset, 'yes') - or next; - - innodb_send_changes_email($cset, $changes) - or $error = 1; -} - -exit ($error == 0 ? 0 : 1); diff --git a/BitKeeper/triggers/pre-commit b/BitKeeper/triggers/pre-commit deleted file mode 100755 index f4664ccf1fe..00000000000 --- a/BitKeeper/triggers/pre-commit +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -if [ "$BK_USER" = "Administrator" -o "$BK_USER" = "mysqldev" ] -then - echo "Error: you cannot commit as 'Administrator' or 'mysqldev' user." - echo "as a workaround set BK_USER to your nickname" - echo "e.g.: export BK_USER='bar'" - echo "" - echo "Checkin FAILED!" - echo "Set BK_USER and retry." - exit 1 -fi - -if [ "$REAL_EMAIL" = "" ] -then - echo "Error: you must set REAL_EMAIL in your profile" - echo "e.g.: export REAL_EMAIL='Joe Dow <joe@foo.bar>'" - echo "" - echo "Commit FAILED!" - echo "Set REAL_EMAIL and retry." - exit 1 -fi diff --git a/BitKeeper/triggers/pre-commit.check-case.pl b/BitKeeper/triggers/pre-commit.check-case.pl deleted file mode 100755 index 4f68f8619e5..00000000000 --- a/BitKeeper/triggers/pre-commit.check-case.pl +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/perl -my $status = 0; - -my $pending = $ENV{'BK_PENDING'}; -exit 0 unless -f $pending; - -open FI, "<", $pending || exit 0; -while(<FI>) { - my ($file, $stuff) = split /\|/, $_, 2; - next unless -f $file; - $file =~ s/^(.*)\/([^\/]*)$/$2/; - my $path = $1; - opendir DIR, $path; - my @files = sort map { lc } readdir DIR; - closedir DIR; - my %count = (); - $count{$_}++ for @files; - @files = grep { $count{$_} > 1 } keys %count; - if(@files > 0) { - print "$path/$file: duplicate file names: " . (join " ", @files) . "\n"; - $status = 1; - } -} -close FI; - -exit $status; diff --git a/BitKeeper/triggers/pre-commit.innodb.pl b/BitKeeper/triggers/pre-commit.innodb.pl deleted file mode 100755 index 6e2b65113b0..00000000000 --- a/BitKeeper/triggers/pre-commit.innodb.pl +++ /dev/null @@ -1,21 +0,0 @@ -#! /usr/bin/perl - -use strict; -use warnings; - -use FindBin; -require "$FindBin::Bin/triggers-lib.pl"; - -die "$0: Script error: \$BK_PENDING is not set in pre-commit trigger\n" - unless defined $ENV{BK_PENDING}; - -# Read changed files from $BK_PENDING directly. Do not bother user about -# merge changes; they don't have any choice, the merge must be done. -my $changes = innodb_get_changes('file', $ENV{BK_PENDING}, undef) - or exit 0; - -innodb_inform_and_query_user($changes) - or exit 1; # Abort commit - -# OK, continue with commit -exit 0; diff --git a/BitKeeper/triggers/pre-delta b/BitKeeper/triggers/pre-delta deleted file mode 100755 index cd861703bb5..00000000000 --- a/BitKeeper/triggers/pre-delta +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -if [ "$BK_USER" = "Administrator" -o "$BK_USER" = "mysqldev" ] -then - echo "Error: you cannot checkin as 'Administrator' or 'mysqldev' user." - echo "as a workaround set BK_USER to your nickname" - echo "e.g.: export BK_USER='bar'" - echo "" - echo "Checkin FAILED!" - echo "Set BK_USER and retry." - exit 1 -fi - -if [ `tail -c1 $BK_FILE` ] -then - echo "File $BK_FILE does not end with a new-line character!" - echo "" - echo "Checkin FAILED!" - echo "Fix the problem and retry." - exit 1 -fi - diff --git a/BitKeeper/triggers/pre-outgoing.crash-protect.pl b/BitKeeper/triggers/pre-outgoing.crash-protect.pl deleted file mode 100755 index b83e356e3f8..00000000000 --- a/BitKeeper/triggers/pre-outgoing.crash-protect.pl +++ /dev/null @@ -1,82 +0,0 @@ -#! /usr/bin/perl - -use strict; -use warnings; - -my $event= $ENV{BK_EVENT}; -unless($event eq 'outgoing pull' || $event eq 'outgoing push' || - $event eq 'resolve') { - exit 0; -} - -my @bad_csets= - ( 'monty@mysql.com|ChangeSet|20060418090255|16983', - 'monty@mysql.com|ChangeSet|20060418090458|02628', - 'monty@mysql.com|ChangeSet|20060419084236|49576', - 'monty@mysql.com|ChangeSet|20060503164655|51444', - 'monty@mysql.com|ChangeSet|20060503225814|60133', - 'monty@mysql.com|ChangeSet|20060504033006|54878', - 'monty@mysql.com|ChangeSet|20060504130520|48660', - 'monty@mysql.com|ChangeSet|20060504164102|03511', - 'monty@mysql.com|ChangeSet|20060504193112|04109', - 'monty@mysql.com|ChangeSet|20060505015314|02799', - 'monty@mysql.com|ChangeSet|20060505084007|16704', - 'monty@mysql.com|ChangeSet|20060505104008|16695', - 'monty@mysql.com|ChangeSet|20060505171041|13924', - 'monty@mysql.com|ChangeSet|20060508121933|13866', - 'monty@mysql.com|ChangeSet|20060508160902|15029', - 'monty@mysql.com|ChangeSet|20060509145448|38636', - 'monty@mysql.com|ChangeSet|20060509224111|40037', - 'monty@mysql.com|ChangeSet|20060510090758|40678', - 'monty@mysql.com|ChangeSet|20060515164104|46760', - 'monty@mysql.com|ChangeSet|20060530114549|35852', - 'monty@mysql.com|ChangeSet|20060605032828|23579', - 'monty@mysql.com|ChangeSet|20060605033011|10641', - 'monty@mysql.com|ChangeSet|20060605060652|09843', - 'msvensson@neptunus.(none)|ChangeSet|20060605094744|10838', - 'msvensson@neptunus.(none)|ChangeSet|20060605105746|11800', - 'msvensson@neptunus.(none)|ChangeSet|20060605122345|12772', - 'jmiller@mysql.com|ChangeSet|20060531210831|36442', - 'jmiller@mysql.com|ChangeSet|20060602151941|36118', - 'jmiller@mysql.com|ChangeSet|20060602152136|27762', - 'jmiller@mysql.com|ChangeSet|20060605121748|12864', - 'jmiller@mysql.com|ChangeSet|20060605160304|14798', - 'jimw@mysql.com|ChangeSet|20060605210201|14667', - 'igor@rurik.mysql.com|ChangeSet|20060605220727|15265', - 'igor@rurik.mysql.com|ChangeSet|20060605221206|15134', - 'stewart@mysql.com|ChangeSet|20060525073521|11169', - 'stewart@mysql.com|ChangeSet|20060605154220|12975', - 'stewart@mysql.com|ChangeSet|20060606040001|15337', - 'hartmut@mysql.com/linux.site|ChangeSet|20070413121444|50289' - ); - -# Read the list of changesets. -my $csetlist = $ENV{BK_CSETLIST}; -if(!defined($csetlist) || !open(FH, '<', $csetlist)) { - die "Failed to open list of incoming changesets '$csetlist': $!.\n"; -} -my @csets = <FH>; -close FH; - -# Reject any attempt to push/pull a bad changeset. -for my $cs (@csets) { - # Do this the raw way, don't want to be bitten by different EOL conventions - # on server and client (Unix/Windows/Mac). - $cs =~ s/\x0d?\x0a?$//s; - if(grep($_ eq $cs, @bad_csets)) { - print <<END; -BAD CHANGESET DETECTED! $event REJECTED! - -The changeset with key '$cs' was detected in the attempted push or pull. -This changeset is from the corrupt part of the crashed mysql-5.1-new tree. -Pushing or pulling this changeset would result in corruption of the new tree, -and therefore the operation has been rejected. - -Contact Kristian Nielsen (knielsen\@mysql.com, IRC knielsen) if you have any -questions regarding this. -END - exit 1; - } -} - -exit 0; diff --git a/BitKeeper/triggers/pre-resolve.crash-protect.pl b/BitKeeper/triggers/pre-resolve.crash-protect.pl deleted file mode 100755 index b83e356e3f8..00000000000 --- a/BitKeeper/triggers/pre-resolve.crash-protect.pl +++ /dev/null @@ -1,82 +0,0 @@ -#! /usr/bin/perl - -use strict; -use warnings; - -my $event= $ENV{BK_EVENT}; -unless($event eq 'outgoing pull' || $event eq 'outgoing push' || - $event eq 'resolve') { - exit 0; -} - -my @bad_csets= - ( 'monty@mysql.com|ChangeSet|20060418090255|16983', - 'monty@mysql.com|ChangeSet|20060418090458|02628', - 'monty@mysql.com|ChangeSet|20060419084236|49576', - 'monty@mysql.com|ChangeSet|20060503164655|51444', - 'monty@mysql.com|ChangeSet|20060503225814|60133', - 'monty@mysql.com|ChangeSet|20060504033006|54878', - 'monty@mysql.com|ChangeSet|20060504130520|48660', - 'monty@mysql.com|ChangeSet|20060504164102|03511', - 'monty@mysql.com|ChangeSet|20060504193112|04109', - 'monty@mysql.com|ChangeSet|20060505015314|02799', - 'monty@mysql.com|ChangeSet|20060505084007|16704', - 'monty@mysql.com|ChangeSet|20060505104008|16695', - 'monty@mysql.com|ChangeSet|20060505171041|13924', - 'monty@mysql.com|ChangeSet|20060508121933|13866', - 'monty@mysql.com|ChangeSet|20060508160902|15029', - 'monty@mysql.com|ChangeSet|20060509145448|38636', - 'monty@mysql.com|ChangeSet|20060509224111|40037', - 'monty@mysql.com|ChangeSet|20060510090758|40678', - 'monty@mysql.com|ChangeSet|20060515164104|46760', - 'monty@mysql.com|ChangeSet|20060530114549|35852', - 'monty@mysql.com|ChangeSet|20060605032828|23579', - 'monty@mysql.com|ChangeSet|20060605033011|10641', - 'monty@mysql.com|ChangeSet|20060605060652|09843', - 'msvensson@neptunus.(none)|ChangeSet|20060605094744|10838', - 'msvensson@neptunus.(none)|ChangeSet|20060605105746|11800', - 'msvensson@neptunus.(none)|ChangeSet|20060605122345|12772', - 'jmiller@mysql.com|ChangeSet|20060531210831|36442', - 'jmiller@mysql.com|ChangeSet|20060602151941|36118', - 'jmiller@mysql.com|ChangeSet|20060602152136|27762', - 'jmiller@mysql.com|ChangeSet|20060605121748|12864', - 'jmiller@mysql.com|ChangeSet|20060605160304|14798', - 'jimw@mysql.com|ChangeSet|20060605210201|14667', - 'igor@rurik.mysql.com|ChangeSet|20060605220727|15265', - 'igor@rurik.mysql.com|ChangeSet|20060605221206|15134', - 'stewart@mysql.com|ChangeSet|20060525073521|11169', - 'stewart@mysql.com|ChangeSet|20060605154220|12975', - 'stewart@mysql.com|ChangeSet|20060606040001|15337', - 'hartmut@mysql.com/linux.site|ChangeSet|20070413121444|50289' - ); - -# Read the list of changesets. -my $csetlist = $ENV{BK_CSETLIST}; -if(!defined($csetlist) || !open(FH, '<', $csetlist)) { - die "Failed to open list of incoming changesets '$csetlist': $!.\n"; -} -my @csets = <FH>; -close FH; - -# Reject any attempt to push/pull a bad changeset. -for my $cs (@csets) { - # Do this the raw way, don't want to be bitten by different EOL conventions - # on server and client (Unix/Windows/Mac). - $cs =~ s/\x0d?\x0a?$//s; - if(grep($_ eq $cs, @bad_csets)) { - print <<END; -BAD CHANGESET DETECTED! $event REJECTED! - -The changeset with key '$cs' was detected in the attempted push or pull. -This changeset is from the corrupt part of the crashed mysql-5.1-new tree. -Pushing or pulling this changeset would result in corruption of the new tree, -and therefore the operation has been rejected. - -Contact Kristian Nielsen (knielsen\@mysql.com, IRC knielsen) if you have any -questions regarding this. -END - exit 1; - } -} - -exit 0; diff --git a/BitKeeper/triggers/triggers-lib.pl b/BitKeeper/triggers/triggers-lib.pl deleted file mode 100644 index 65a334ba926..00000000000 --- a/BitKeeper/triggers/triggers-lib.pl +++ /dev/null @@ -1,356 +0,0 @@ -# To use this convenience library in a trigger, simply require it at -# at the top of the script. For example: -# -# #! /usr/bin/perl -# -# use FindBin; -# require "$FindBin::Bin/triggers-lib.pl"; -# -# FindBin is needed, because sometimes a trigger is called from the -# RESYNC directory, and the trigger dir is ../BitKeeper/triggers - -use strict; -use warnings; - -use Carp; -use FindBin; - - -my $mysql_version = "5.1"; - -# These addresses must be kept current in all MySQL versions. -# See the wiki page InnoDBandOracle. -#my @innodb_to_email = ('dev_innodb_ww@oracle.com'); -#my @innodb_cc_email = ('dev-innodb@mysql.com'); -# FIXME: Keep this for testing; remove it once it's been used for a -# week or two. -my @innodb_to_email = ('tim@mysql.com'); -my @innodb_cc_email = (); - -# This is for MySQL >= 5.1. Regex which defines the InnoDB files -# which should generally not be touched by MySQL developers. -my $innodb_files_description = <<EOF; - storage/innobase/* - mysql-test/t/innodb* (except mysql-test/t/innodb_mysql*) - mysql-test/r/innodb* (except mysql-test/r/innodb_mysql*) -EOF -my $innodb_files_regex = qr{ - ^ - ( - # Case 1: innobase/* - storage/innobase/ - | - # Case 2: mysql-test/[tr]/innodb* (except innodb_mysql*) - mysql-test/(t|r)/SCCS/s.innodb - # The mysql-test/[tr]/innodb_mysql* are OK to edit - (?!_mysql) - ) -}x; - - -# See 'bk help log', and the format of, e.g., $BK_PENDING. -# Important: this already contains the terminating newline! -my $file_rev_dspec = ':SFILE:|:REV:\n'; - -my $bktmp = "$FindBin::Bin/../tmp"; - -my $sendmail; -foreach ('/usr/sbin/sendmail', 'sendmail') { - $sendmail = $_; - last if -x $sendmail; -} -my $from = $ENV{REAL_EMAIL} || $ENV{USER} . '@mysql.com'; - - -# close_or_warn -# $fh file handle to be closed -# $description description of the file handle -# RETURN Return value of close($fh) -# -# Print a nice warning message if close() isn't successful. See -# perldoc perlvar and perldoc -f close for details. - -sub close_or_warn (*$) -{ - my ($fh, $description) = @_; - - my $status = close $fh; - if (not $status) { - warn "$0: error on close of '$description': ", - ($! ? "$!" : "exit status " . ($? >> 8)), "\n"; - } - - return $status; -} - - -# check_status -# $warn If true, warn about bad status -# RETURN TRUE, if $BK_STATUS is "OK"; FALSE otherwise -# -# Also checks the undocumented $BK_COMMIT env variable - -sub check_status -{ - my ($warn) = @_; - - my $status = (grep { defined $_ } - $ENV{BK_STATUS}, $ENV{BK_COMMIT}, '<undef>')[0]; - - unless ($status eq 'OK') - { - warn "Bad BK_STATUS '$status'\n" if $warn; - return undef; - } - - return 1; -} - - -# repository_location -# -# RETURN ('HOST', 'ROOT') for the repository being modified - -sub repository_location -{ - if ($ENV{BK_SIDE} eq 'client') { - return ($ENV{BK_HOST}, $ENV{BK_ROOT}); - } else { - return ($ENV{BKD_HOST}, $ENV{BKD_ROOT}); - } -} - - -# repository_type -# RETURN: -# 'main' for repo on bk-internal with post-incoming.bugdb trigger -# 'team' for repo on bk-internal with post-incoming.queuepush.pl trigger -# 'local' otherwise -# -# This definition may need to be modified if the host name or triggers change. - -sub repository_type -{ - my ($host, $root) = repository_location(); - - return 'local' - unless uc($host) eq 'BK-INTERNAL.MYSQL.COM' - and -e "$root/BitKeeper/triggers/post-incoming.queuepush.pl"; - - return 'main' if -e "$root/BitKeeper/triggers/post-incoming.bugdb"; - - return 'team'; -} - - -# latest_cset -# RETURN Key for most recent ChangeSet - -sub latest_cset { - chomp(my $retval = `bk changes -r+ -k`); - return $retval; -} - - -# read_bk_csetlist -# RETURN list of cset keys from $BK_CSETLIST file -sub read_bk_csetlist -{ - die "$0: script error: \$BK_CSETLIST not set\n" - unless defined $ENV{BK_CSETLIST}; - - open CSETS, '<', $ENV{BK_CSETLIST} - or die "$0: can't read \$BK_CSETLIST='$ENV{BK_CSETLIST}': $!\n"; - chomp(my @csets = <CSETS>); - close_or_warn(CSETS, "\$BK_CSETLIST='$ENV{BK_CSETLIST}'"); - - return @csets; -} - - -# innodb_get_changes -# $type 'file' or 'cset' -# $value file name (e.g., $BK_PENDING) or ChangeSet key -# $want_merge_changes flag; if false, merge changes will be ignored -# RETURN A string describing the InnoDB changes, or undef if no changes -# -# The return value does *not* include ChangeSet comments, only per-file -# comments. - -sub innodb_get_changes -{ - my ($type, $value, $want_merge_changes) = @_; - - if ($type eq 'file') - { - open CHANGES, '<', $value - or die "$0: can't read '$value': $!\n"; - } - elsif ($type eq 'cset') - { - open CHANGES, '-|', "bk changes -r'$value' -v -d'$file_rev_dspec'" - or die "$0: can't exec 'bk changes': $!\n"; - } - else - { - croak "$0: script error: invalid type '$type'"; - } - - my @changes = grep { /$innodb_files_regex/ } <CHANGES>; - - close_or_warn(CHANGES, "($type, '$value')"); - - return undef unless @changes; - - - # Set up a pipeline of 'bk log' commands to weed out unwanted deltas. We - # never want deltas which contain no actual changes. We may not want deltas - # which are merges. - - my @filters; - - # This tests if :LI: (lines inserted) or :LD: (lines deleted) is - # non-zero. That is, did this delta change the file contents? - push @filters, - "bk log -d'" - . "\$if(:LI: -gt 0){$file_rev_dspec}" - . "\$if(:LI: -eq 0){\$if(:LD: -gt 0){$file_rev_dspec}}" - . "' -"; - - push @filters, "bk log -d'\$unless(:MERGE:){$file_rev_dspec}' -" - unless $want_merge_changes; - - my $tmpname = "$bktmp/ibchanges.txt"; - my $pipeline = join(' | ', @filters) . " > $tmpname"; - open TMP, '|-', $pipeline - or die "$0: can't exec [[$pipeline]]: $!\n"; - - print TMP @changes; - close_or_warn(TMP, "| $pipeline"); - - # Use bk log to describe the changes - open LOG, "bk log - < $tmpname |" - or die "$0: can't exec 'bk log - < $tmpname': $!\n"; - my @log = <LOG>; - close_or_warn(LOG, "bk log - < $tmpname |"); - - unlink $tmpname; - - return undef unless @log; - - return join('', @log); -} - - -# Ask user if they really want to commit. -# RETURN TRUE = YES, commit; FALSE = NO, do not commit - -sub innodb_inform_and_query_user -{ - my ($description) = @_; - - my $tmpname = "$bktmp/ibquery.txt"; - - open MESSAGE, "> $tmpname" - or die "$0: can't write message to '$tmpname': $!"; - - print MESSAGE <<EOF; -This ChangeSet modifies some files which should normally be changed by -InnoDB developers only. In general, MySQL developers should not change: - -$innodb_files_description -The following InnoDB files were modified: -========================================================= -$description -========================================================= - -If you understand this, you may Commit these changes. The changes -will be sent to the InnoDB developers at @{[join ', ', @innodb_to_email]}, -CC @{[join ', ', @innodb_cc_email]}. -EOF - - close_or_warn(MESSAGE, "$tmpname"); - - my $status = system('bk', 'prompt', '-w', - '-yCommit these changes', '-nDo not Commit', "-f$tmpname"); - - unlink $tmpname; - - return ($status == 0 ? 1 : undef); -} - - -# innodb_send_changes_email -# $cset The ChangeSet key -# $description A (maybe brief) description of the changes -# RETURN TRUE = Success, e-mail sent; FALSE = Failure -# -# Sends a complete diff of changes in $cset by e-mail. - -sub innodb_send_changes_email -{ - my ($cset, $description) = @_; - - # FIXME: Much of this is duplicated in the 'post-commit' Bourne shell - # trigger - - my $cset_short = `bk changes -r'$cset' -d':P:::I:'`; - my $cset_key = `bk changes -r'$cset' -d':KEY:'`; - - my ($host, $bk_root) = repository_location(); - my $type = repository_type(); - (my $treename = $bk_root) =~ s,^.*/,,; - - print "Nofifying InnoDB developers at ", - (join ', ', @innodb_to_email, @innodb_cc_email), "\n"; - - open SENDMAIL, '|-', "$sendmail -t" - or die "Can't exec '$sendmail -t': $!\n"; - - my @headers; - push @headers, "List-ID: <bk.innodb-$mysql_version>"; - push @headers, "From: $from"; - push @headers, "To: " . (join ', ', @innodb_to_email); - push @headers, "Cc: " . (join ', ', @innodb_cc_email) if @innodb_cc_email; - push @headers, - "Subject: InnoDB changes in $type $mysql_version tree ($cset_short)"; - push @headers, "X-CSetKey: <$cset_key>"; - - print SENDMAIL map { "$_\n" } @headers, ''; - - if ($type eq 'main') - { - print SENDMAIL <<EOF; -Changes pushed to $treename by $ENV{USER} affect the following -files. These changes are in a $mysql_version main tree. They -will be available publicly within 24 hours. -EOF - } - elsif ($type eq 'team') - { - print SENDMAIL <<EOF; -Changes added to $treename by $ENV{USER} affect the -following files. These changes are in a $mysql_version team tree. -EOF - } - else - { - print SENDMAIL <<EOF; -A local commit by $ENV{USER} affects the following files. These -changes are in a clone of a $mysql_version tree. -EOF - } - print SENDMAIL "\n"; - print SENDMAIL qx(bk changes -r'$cset'); - print SENDMAIL "$description"; - print SENDMAIL "The complete ChangeSet diffs follow.\n\n"; - print SENDMAIL qx(bk rset -r'$cset' -ah | bk gnupatch -h -dup -T); - - close_or_warn(SENDMAIL, "$sendmail -t") - or return undef; - - return 1; -} - - -1; |