1998-06-16 21:43:24 +00:00
# !/usr/bonsaitools/bin/mysqltcl
# -*- Mode: tcl; indent-tabs-mode: nil -*-
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
# License for the specific language governing rights and limitations
# under the License.
#
# The Original Code is the Bonsai CVS tool.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are Copyright (C) 1998
# Netscape Communications Corporation. All Rights Reserved.
source globals.tcl
# cmdtrace on
assert { ! [ info exists checkinlist] }
set inheader 1
set foundlogline 0
proc trim { str } {
return [ string trim $str ]
}
set filelist { }
set log { }
set appendjunk { }
set repository { / m / src}
if { [ cequal [ lindex $argv 0 ] " - t r e e i d " ] } {
lvarpop argv
set forcetreeid [ lvarpop argv]
}
# Stupid hack to make empty array
set group( xyzzy ) 1
unset group( xyzzy )
for_file line $argv {
set line [ trim $line ]
if { $inheader } {
switch - glob - - $line {
{ } {
set inheader 0
}
}
} elseif { ! $foundlogline } {
switch - glob - - $line {
{ ? | * } {
append appendjunk " $ l i n e \n "
lassign [ split $line " | " ] chtype date name repository dir \
file version sticky branch addlines removelines
set key [ list $date $branch $repository $dir $name ]
lappend group( $key ) [ list $file $version $addlines \
$removelines $sticky ]
}
{ Tag | * } {
set data [ split $line " | " ]
lvarpop data
set repository [ lvarpop data]
set tagtime [ lvarpop data]
set tagname [ lvarpop data]
regsub - all - - / $repository _ mungedname
set filename " d a t a / t a g i n f o / $ m u n g e d n a m e / [ M u n g e T a g N a m e $ t a g n a m e ] "
Lock
if { [ catch { set fid [ open " $ f i l e n a m e " " a " ] } ] } {
catch { mkdir data/ taginfo}
catch { chmod 0777 data/ taginfo}
catch { mkdir data/ taginfo/ $mungedname }
catch { chmod 0777 data/ taginfo/ $mungedname }
set fid [ open " $ f i l e n a m e " " a " ]
}
puts $fid " $ t a g t i m e | [ j o i n $ d a t a { | } ] "
close $fid
catch { chmod 0666 $filename }
Unlock
}
{ LOGCOMMENT } {
set foundlogline 1
}
}
} else {
if { [ cequal $line " : E N D L O G C O M M E N T " ] } {
break
}
append log " $ l i n e \n "
}
}
set plainlog $log
set log [ html_quote [ trim $log ] ]
regsub - all - - { [ 0-9 ] [ 0-9 ] [ 0-9 ] [ 0-9 ] [ 0-9 ] * } $log $BUGSYSTEMEXPR log
Lock
LoadTreeConfig
if { ! [ info exists forcetreeid] } {
regsub - all - - / $repository _ mungedname
set filename " d a t a / c h e c k i n l o g $ m u n g e d n a m e "
set fid [ open $filename " a " ]
catch { chmod 0666 $filename }
puts $fid " [ s e t a p p e n d j u n k ] L O G C O M M E N T \n $ p l a i n l o g \n : E N D L O G C O M M E N T "
close $fid
ConnectToDatabase
AddToDatabase $appendjunk $plainlog
}
Unlock
if { [ info exists forcetreeid] } {
set treestocheck $forcetreeid
} else {
set treestocheck $treelist
}
foreach key [ array names group] {
lassign $key date branch repository dir name
set branch2 [ crange $branch 1 end]
set files { }
set fullinfo { }
foreach i $group ( $key ) {
lassign $i file version addlines removelines
lappend files $file
lappend fullinfo $i
}
foreach treeid $treestocheck {
if { [ info exists treeinfo( $treeid , nobonsai ) ] } {
continue
}
if { ! [ cequal $branch $treeinfo ( $treeid , branch ) ] && \
! [ cequal $branch2 $treeinfo ( $treeid , branch ) ] } {
continue
}
if { ! [ cequal $repository $treeinfo ( $treeid , repository ) ] } {
continue
}
LoadDirList
set okdir 0
# Sigh. We have some specific files listed as well as modules. So,
# painfully go through *every* file we're checking in, and see if any
# of them are ones we're interested in.
foreach f $files {
set full $dir / $f
foreach d $legaldirs {
if { [ string match $d $full ] } {
set okdir 1
break
}
}
if { $okdir } {
break
}
}
if { $okdir } {
Lock
catch { unset batchid}
catch { unset checkinlist}
LoadCheckins
set id checkin-$date- [ id process]
lappend checkinlist $id
upvar # 0 $id foo
set foo( person ) $name
set foo( date ) $date
set foo( dir ) $dir
set foo( files ) $files
set foo( log ) $log
set foo( treeopen ) $treeopen
set foo( fullinfo ) $fullinfo
WriteCheckins
Log " A d d e d c h e c k i n $ n a m e $ d i r $ f i l e s "
Unlock
if { $treeopen } {
set filename [ DataDir ] / openmessage
foreach i $checkinlist {
upvar # 0 $i info
if { [ cequal $info ( person ) $name ] } {
if { ! [ cequal $id $i ] } {
# This person already has a checkin, so we don't
# need to bother him again.
set filename thisFileDoesntExist
}
}
}
} else {
set filename [ DataDir ] / closemessage
}
if { ! [ info exists forcetreeid] && [ file exists $filename ] } {
set fid [ open $filename " r " ]
set text [ read $fid ]
close $fid
set profile [ GenerateProfileHTML $name ]
set nextclose { [ We don' t remember close times any more...] }
1998-07-27 20:57:51 +00:00
set name [ EmailFromUsername $name ]
1998-06-16 21:43:24 +00:00
foreach k { name dir files log profile nextclose} {
regsub - all - - " % $ k % " $text [ set $k ] text
}
exec / usr/ lib/ sendmail - t << $text
Log " M a i l e d f i l e $ f i l e n a m e t o $ n a m e "
}
}
}
}
NOTDEF {
set tmp $log
while { [ regexp - nocase - - { . * bugfix( [ 0-9 ] * ) ( . * ) $ } $tmp foo list tmp] } {
set fileversions { }
foreach i [ array names group] {
lassign $i file version
lappend $fileversions [ list $file $version ]
}
foreach b $list {
set result [ exec / usr/ local/ bin/ lynx - dump " h t t p : / / s c o p u s . m c o m . c o m / t e r r s p l a t / d o c l o s e b u g . c g i ? i d = $ b & d i r e c t o r y = $ d i r & f i l e v e r s i o n s = $ f i l e v e r s i o n s & w h o = $ n a m e & l o g = $ p l a i n l o g " ]
if { $result != " O K \n " } {
}
}
}
}
exit