Changeset 12678


Ignore:
Timestamp:
07/20/12 17:17:10 (13 years ago)
Author:
Mathieu Morlighem
Message:

faster script

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/oecreview/oecreview.sh

    r11985 r12678  
    33
    44#Some functions
    5 function parselog() #{{{1
    6 {
    7 cat $1 | while read line
    8 do
    9         if [ "$line" ==  "" ]
    10         then
    11                 #empty line, keep going
    12                 continue
    13         fi
    14         if [ "$line" ==  "------------------------------------------------------------------------" ]
    15         then
    16                 #print previous log if not empty
    17                 if [ "$RELEASE" != "" ]
    18                 then
    19                         echo "$RELEASE $USER  $DATE $TIME"
    20                 fi
    21 
    22                 #new log coming up!
    23                 NEWLOG=1
    24                 LOG=""
    25                 continue
    26         fi
    27 
    28         if [ "$NEWLOG" == "1" ]
    29         then
    30                
    31                 #r2714 | morlighe | 2009-12-09 11:48:20 -0800 (Wed, 09 Dec 2009) | 1 line
    32                 RELEASE=$(echo $line | awk '{print $1}')
    33                 USER=$(   echo $line | awk '{print $3}')
    34                 DATE=$(   echo $line | awk '{print $5}')
    35                 TIME=$(   echo $line | awk '{print $6}')
    36 
    37                 NEWLOG=0
    38                 continue
    39         else
    40                 LOG=$(echo "$LOG $line")
    41         fi
    42 done
    43 } #}}}
    445function parselogchangedpaths() #{{{1
    456{
     
    7435                DATE=$(   echo $line | awk '{print $5}')
    7536                TIME=$(   echo $line | awk '{print $6}')
    76 
    7737                NEWLOG=0
    7838                continue
     
    11474        if [ "$NEWLOG" == "1" ]
    11575        then
    116                
    11776                #r2714 | morlighe | 2009-12-09 11:48:20 -0800 (Wed, 09 Dec 2009) | 1 line
    11877                RELEASE=$(echo $line | awk '{print $1}')
     
    12079                DATE=$(   echo $line | awk '{print $5}')
    12180                TIME=$(   echo $line | awk '{print $6}')
    122 
    12381                NEWLOG=0
    12482                continue
     
    14098} #}}}
    14199
    142 #Only keep pdf file generated?
    143 keeppdf=1;
    144 
    145 #today's date
    146 TODAY=$(todaydate);
    147 
    148100#Archive location:
    149 archiveroot=$ISSM_DIR/oecreview/Archive
    150 templatedir=$ISSM_DIR/oecreview/Template
    151 trunk=$ISSM_DIR/trunk-jpl
     101CLEAN_DIR="/Users/morlighe/Desktop/issmjpl/svn-sync/issm-clean"
     102ARCHIVE_ROOT=$CLEAN_DIR/oecreview/Archive
     103TEMPLATE_DIR=$CLEAN_DIR/oecreview/Template
     104TRUNK_JPL=$CLEAN_DIR/trunk-jpl
    152105
    153106#Range
    154107if test $# -ne 2
    155108then
    156 echo "oecreview.sh needs 2 arguments specifying the svn range on which to apply the review"
    157 exit 1
     109        echo "oecreview.sh needs 2 arguments specifying the svn range on which to apply the review"
     110        exit 1
    158111fi
    159 
    160112r1=$1;
    161113r2=$2;
    162114
    163115#Name of archive  directory:
    164 archivedir="$archiveroot/$r1-$r2"
     116ARCHIVE_DIR="$ARCHIVE_ROOT/$r1-$r2"
    165117
    166118#Create archive subdirectory for this batch of changes
    167 rm -rf  $archivedir &&  mkdir $archivedir
    168 
    169 
    170 #start log template
    171 cat > $archivedir/log.tex << EOF
    172 EOF
     119rm -rf  $ARCHIVE_DIR &&  mkdir $ARCHIVE_DIR
    173120
    174121#create log number
    175 echo "$r1-$r2"  > $archivedir/LogNumber.tex
     122echo "$r1-$r2"  > $ARCHIVE_DIR/LogNumber.tex
    176123
    177124#create date tex
    178 echo $TODAY  > $archivedir/Date.tex
     125echo $(todaydate) > $ARCHIVE_DIR/Date.tex
    179126
    180127#create revision texs
    181 echo $r1 > $archivedir/r1.tex
    182 echo $r2 > $archivedir/r2.tex
     128echo $r1 > $ARCHIVE_DIR/r1.tex
     129echo $r2 > $ARCHIVE_DIR/r2.tex
    183130
    184131#copy template
    185 cp  $templatedir/docreview.tex $archivedir/ISSM-DocReview-$r1-$r2.tex
    186 cp  $templatedir/signature.eps $archivedir/
    187 cat $templatedir/Makefile  | sed "s/name=docreview/name=ISSM-DocReview-$r1-$r2/g" > $archivedir/Makefile
     132cp  $TEMPLATE_DIR/docreview.tex $ARCHIVE_DIR/ISSM-DocReview-$r1-$r2.tex
     133cp  $TEMPLATE_DIR/signature.eps $ARCHIVE_DIR/
     134cat $TEMPLATE_DIR/Makefile  | sed "s/name=docreview/name=ISSM-DocReview-$r1-$r2/g" > $ARCHIVE_DIR/Makefile
    188135
    189 counter=0
     136COUNTER=0
    190137for (( i=$r1; i<$r2; i++ ))
    191138do
     139        echo "Dealing with change #$i"
    192140        j=$(($i+1));
    193141
    194142        #get svn log for this commit
    195         log=`svn log  -v -r $i:$j  $trunk | parselog`
     143        echo " => getting log..."
     144        rm TEMP
     145        svn log -v -r$i $TRUNK_JPL > TEMP
    196146
    197         #retrieve info from the log
    198         release=`echo $log | awk '{printf("%s\n",$1);}'`
    199         user=`echo $log | awk '{printf("%s\n",$2);}'`
    200         date=`echo $log | awk '{printf("%s\n",$3);}'`
    201         time=`echo $log | awk '{printf("%s\n",$4);}'`
    202 
    203         if test -z $user
     147        if [ "$(cat TEMP)" ==  "------------------------------------------------------------------------" ]
    204148        then
    205                 #empty user, nothing was changed on the trunk/, skip
     149                #empty log, nothing was changed on the trunk-jpl/ (this must be a change in another direcoty), skip
     150                echo " => empty log (not affecting trunk-jpl)"
    206151                continue
    207152        fi
     153
     154        #process log
     155        release=$( cat TEMP | sed -n 2p | awk '{print $1}')
     156        user=$(    cat TEMP | sed -n 2p | awk '{print $2}')
     157        date=$(    cat TEMP | sed -n 2p | awk '{print $3}')
     158        time=$(    cat TEMP | sed -n 2p | awk '{print $4}')
    208159       
    209         counter=$(($counter+1))
     160        COUNTER=$(($COUNTER+1))
    210161
    211162        #retrieve files affected
    212         changedpath=`svn log  -v -r $i:$j  $trunk | parselogchangedpaths `
    213         logmessage=`svn log  -v -r $i:$j  $trunk | parselogmessages `
     163        echo " => getting path"
     164        changedpath=$(cat TEMP | parselogchangedpaths)
     165        echo " => getting log message"
     166        logmessage=$(cat TEMP | parselogmessages)
    214167
    215168        #create diff file
    216         svn diff  -r $i:$j  $trunk > $archivedir/ISSM-$i-$j.diff
     169        echo " => getting diff file"
     170        svn diff -r $i:$j $TRUNK_JPL > $ARCHIVE_DIR/ISSM-$i-$j.diff
    217171       
    218172        #add lines to explain the logs
    219         cat $archivedir/log.tex && echo "\\noindent \\textbf{Change \#$counter} with diff file ISSM-$i-$j.diff: \\\\ Function name: \\\\$changedpath \\\\ Export determination: 6. \\\\Rationale: $logmessage \\\\\\\\" >> $archivedir/log.tex
     173        echo " => add to $ARCHIVE_DIR/log.tex"
     174        cat >> $ARCHIVE_DIR/log.tex << EOF
     175\\noindent \\textbf{Change \#$COUNTER} with diff file ISSM-$i-$j.diff: \\\\
     176Function name: \\\\
     177$(echo $changedpath | sed 's/_/\\_/g' )\\\\
     178Export determination: 6. \\\\
     179Rationale: $(echo $logmessage | sed 's/_/\\_/g' )\\\\
     180\\vspace{3em}
     181
     182EOF
    220183done
     184rm TEMP
    221185       
    222 #Make this latex compatible:
    223 cat $archivedir/log.tex | sed 's/_/\\_/g' > $archivedir/log.tex.bak
    224 mv $archivedir/log.tex.bak $archivedir/log.tex
    225 
    226186#create pdf file
    227 cd $archivedir
     187cd $ARCHIVE_DIR
    228188make
    229189
    230190#copy pdf file in Archive directory: 
    231 cp $archivedir/ISSM-DocReview-$r1-$r2.pdf $archiveroot
     191cp $ARCHIVE_DIR/ISSM-DocReview-$r1-$r2.pdf $ARCHIVE_ROOT
    232192
    233 #conclude
    234 cd $archivedir
    235 
     193echo "Done! Now call Eric L."
Note: See TracChangeset for help on using the changeset viewer.