Date:2010-08-31 04:19:12 (9 years 19 days ago)
Author:Werner Almesberger
Commit:a3aac7e80bd612bace666e90cdd697e14d471897
Message:Reorganized cache and output directory structure. Some code cleanup.

- scripts/schhist2web: changed cache and output directory structure from
$dir/$type_$commit/$file to $dir/$commit/$type/$file
- scripts/schhist2web: renamed directory types as follows: "ppm" to "ppm1",
"fat" to "ppm2", and "hard" to "ppm0"
- scripts/schhist2web: replaced `basename $x` with ${x##*/} wherever this
makes sense
- scripts/schhist2web: use {a,b,...} where is makes things clearer
- scripts/schhist2web: changed ... \\n || exit to ... ||\n exit
- scripts/schhist2web: symlinking of unchanged files was only done for
"ppm" (now "ppm1") and "fat" (now "ppm2"), not for "ppm2" and "ps"
- scripts/schhist2web: composition of path names in the output generator is
now more systematic and avoids ad hoc compositions
- scripts/schhist2web: mkdir -p "$out/pdf_$next" at the beginning, not each
time we write a PDF
Files: scripts/schhist2web (7 diffs)

Change Details

scripts/schhist2web
8282{
8383    local dir=$1 commit=$2 file=$3
8484
85    mkdir -p "$dir/html_$commit"
86    echo "<A href=\"html_$commit/$file.html\"><IMG src=\"thumb_$commit/$file.png\"></A>"
87    cat <<EOF >"$dir/html_$commit/$file.html"
85    mkdir -p "$dir/$commit/html"
86    echo "<A href=\"$commit/html/$file.html\"><IMG src=\"$commit/thumb/$file.png\"></A>"
87    cat <<EOF >"$dir/$commit/html/$file.html"
8888<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
8989<HTML>
9090<TITLE>$file</TITLE>
9191<BODY>
92<A href="../pdf_$commit/$file.pdf"><IMG src="../diff_$commit/$file.png"></A>
92<A href="../pdf/$file.pdf"><IMG src="../diff/$file.png"></A>
9393</BODY>
9494EOF
9595}
...... 
188188first=`gitenealogy "$dir" "$sch" | sed '$s/ .*//p;d'`
189189schname=`gitenealogy "$dir" "$sch" | sed '$s/^.* //p;d'`
190190
191rm -rf "$out/diff_*" "$out/thumb_*" "$out/html_*" "$out/pdf_*" "$out/names"
191rm -rf "$out/*/"{diff,thumb,html,pdf} "$out/names"
192192$no_cache && rm -rf "$cache"
193193mkdir -p "$out/names"
194194mkdir -p "$cache"
...... 
210210    schname="$new"
211211    fi
212212    tmp=`pwd`/_schhist2web
213    trap "rm -rf \"$cache/ppm_$n\" \"$cache/fat_$n\" \"$cache/ps_$n\" \
214      \"$cache/hard_$n\" \"$tmp\"" 0
215    if [ ! -d "$cache/ppm_$n" ]; then
216    rm -rf "$cache/ppm_$n" "$cache/fat_$n" "$cache/ps_$n" "$cache/hard_$n"
217    mkdir "$cache/ppm_$n" "$cache/fat_$n" "$cache/ps_$n" "$cache/hard_$n"
213    trap "rm -rf \"$cache/$n/ps\" \"$cache/$n/ppm0\" \"$cache/$n/ppm1\" \
214      \"$cache/$n/ppm2\" \"$tmp\"" 0
215    if [ ! -d "$cache/$n/ppm2" ]; then
216    rm -rf "$cache/$n/"{ps,ppm0,ppm1,ppm2}
217    mkdir -p "$cache/$n/"{ps,ppm0,ppm1,ppm2}
218218    #
219219    # potential optimization here: remember Postscript files from previous
220220    # run (or their md5sum) and check if they have changed. If not, skip
...... 
224224    gitsch2ps $sanitize "$dir" "$schname" $n "$tmp" || exit
225225    for m in "$tmp"/*.ps; do
226226        # Postscript, for making PDFs later
227        ps="$cache/ps_$n/`basename "$m"`"
227        ps="$cache/$n/ps/`basename "$m"`"
228228        normalizeschps "$m" "$ps" || exit
229229
230230        # Unadorned pixmap, for comparison
231        ppm="$cache/hard_$n/`basename "$m" .ps`.ppm"
231        ppm="$cache/$n/ppm0/`basename "$m" .ps`.ppm"
232232        schps2ppm -n "$ps" "$ppm" || exit
233233
234234        # Pixmap with thin lines, for the detail views
235        ppm="$cache/ppm_$n/`basename "$m" .ps`.ppm"
235        ppm="$cache/$n/ppm1/`basename "$m" .ps`.ppm"
236236        normalizeschps -w 120 "$m" | schps2ppm - "$ppm" || exit
237237
238238        # Pixmap with thick lines, for the thumbnails
239        ppm="$cache/fat_$n/`basename "$m" .ps`.ppm"
239        ppm="$cache/$n/ppm2/`basename "$m" .ps`.ppm"
240240        normalizeschps -w 500 "$m" | schps2ppm - "$ppm" || exit
241241    done
242242    rm -rf "$tmp"
243243    fi
244    for m in "$cache/ppm_$n/"*; do
245    [ "$m" = "$cache/ppm_$n/*" ] && break
244    for m in "$cache/$n/ppm0/"*; do
245    [ "$m" = "$cache/$n/ppm0/*" ] && break
246246    if [ ! -z "$head" ]; then
247        prev="$cache/ppm_$head"/`basename "$m"`
247        prev="$cache/$head/ppm0/${m##*/}"
248248        if [ -r "$prev" ] && cmp -s "$prev" "$m"; then
249        symlink "../ppm_$head/`basename \"$m\"`" "$m"
250        symlink "../fat_$head/`basename \"$m\"`" \
251          "$cache/fat_$n/`basename \"$m\"`"
249        for d in ppm0 ppm1 ppm2; do
250            symlink "../../$head/$d/${m##*/}" "$cache/$n/$d/${m##*/}"
251        done
252        m_ps=${m%.ppm}.ps
253        symlink "../../$head/$d/${m_ps##*/}" "$cache/$n/$d/${m_ps##*/}"
252254        fi
253255    fi
254256    touch "$out/names/`basename \"$m\" .ppm`"
...... 
289291<TR bgcolor="$FNAME_COLOR">
290292EOF
291293    while read m; do
292    ps="$cache/ps_$head/$m.ps"
294    ps="$cache/$head/ps/$m.ps"
293295    if [ -r "$ps" ]; then
294296        #
295297        # Note: we read from variable ps_$head but we write to constant
...... 
315317
316318next="$head"
317319for n in `cd "$dir" && git rev-list $first..HEAD~1` $first; do
318    [ -d "$cache/ppm_$n" ] || continue
320    [ -d "$cache/$n/ppm0" ] || continue
319321    empty=true
320322    s="<TR>"
321    mkdir -p "$out/diff_$next" "$out/thumb_$next"
323    mkdir -p "$out/$next/"{diff,thumb,html,pdf}
322324    while read m; do
323    a="$cache/ppm_$n/$m.ppm"
324    fat_a="$cache/fat_$n/$m.ppm"
325    hard_a="$cache/hard_$n/$m.ppm"
326    b="$cache/ppm_$next/$m.ppm"
327    fat_b="$cache/fat_$next/$m.ppm"
328    hard_b="$cache/hard_$next/$m.ppm"
329    diff="$out/diff_$next/$m.png"
330    thumb="$out/thumb_$next/$m.png"
331
332    if [ -f "$a" -a -f "$b" ]; then
325    a0="$cache/$n/ppm0/$m.ppm"
326    a1="$cache/$n/ppm1/$m.ppm"
327    a2="$cache/$n/ppm2/$m.ppm"
328    aps="$cache/$n/ps/$m.ps"
329
330    b0="$cache/$next/ppm0/$m.ppm"
331    b1="$cache/$next/ppm1/$m.ppm"
332    b2="$cache/$next/ppm2/$m.ppm"
333    bps="$cache/$next/ps/$m.ps"
334
335    diff="$out/$next/diff/$m.png"
336    thumb="$out/$next/thumb/$m.png"
337    pdf="$out/$next/pdf/$m.pdf"
338
339    if [ -f "$a0" -a -f "$b0" ]; then
333340        s="$s<TD align=\"center\" valign=\"middle\">"
334        if ! pngdiff cat "$diff" "$a" "$b" "$hard_a" "$hard_b"; then
341        if ! pngdiff cat "$diff" "$a1" "$b1" "$a0" "$b0"; then
335342        s="$s<IMG src=\"unchanged.png\""
336343        continue
337344        fi
338        pngdiff shrink "$thumb" -f $THUMB_OPTS "$fat_a" "$fat_b" \
339          "$hard_a" "$hard_b" || exit
340        mkdir -p "$out/pdf_$next"
341        schps2pdf -T BEFORE -T AFTER -o "$out/pdf_$next/$m.pdf" \
342          "$cache/ps_$n/$m.ps" "$cache/ps_$next/$m.ps" || exit
343    elif [ -f "$a" ]; then
345        pngdiff shrink "$thumb" -f $THUMB_OPTS "$a2" "$b2" "$a0" "$b0" ||
346          exit
347        schps2pdf -T BEFORE -T AFTER -o "$pdf" "$aps" "$bps" || exit
348    elif [ -f "$a0" ]; then
344349        s="$s<TD>"
345        pngdiff cat "$diff" -f -c 1,0,0 "$a" "$a" || exit
346        pngdiff shrink "$thumb" -f $THUMB_OPTS -c 1,0,0 "$fat_a" "$fat_a" \
347          || exit
348        mkdir -p "$out/pdf_$next"
349        schps2pdf -T DELETED -o "$out/pdf_$next/$m.pdf" \
350          "$cache/ps_$n/$m.ps" || exit
351    elif [ -f "$b" ]; then
350        pngdiff cat "$diff" -f -c 1,0,0 "$a1" "$a1" || exit
351        pngdiff shrink "$thumb" -f $THUMB_OPTS -c 1,0,0 "$a2" "$a2" ||
352          exit
353        schps2pdf -T DELETED -o "$pdf" "$aps" || exit
354    elif [ -f "$b0" ]; then
352355        s="$s<TD>"
353        pngdiff cat "$diff" -f -c 0,1,0 "$b" "$b" || exit
354        pngdiff shrink "$thumb" -f $THUMB_OPTS -c 0,1,0 "$fat_b" "$fat_b" \
355          || exit
356        mkdir -p "$out/pdf_$next"
357        schps2pdf -T NEW -o "$out/pdf_$next/$m.pdf" \
358          "$cache/ps_$next/$m.ps" || exit
356        pngdiff cat "$diff" -f -c 0,1,0 "$b1" "$b1" || exit
357        pngdiff shrink "$thumb" -f $THUMB_OPTS -c 0,1,0 "$b2" "$b2" ||
358          exit
359        schps2pdf -T NEW -o "$pdf" "$bps" || exit
359360    else
360361        s="$s<TD>"
361362        continue
362363    fi
363364    echo "$s"
364365    s=
365    empty=false
366366        wrapped_png "$out" "$next" "$m"
367    empty=false
367368    done < <(ls -1 "$out/names")
368369    if ! $empty; then
369370     echo "$s<TD valign=\"middle\">"
...... 
376377# --- Add creation entries for all files in the first commit ------------------
377378
378379
379if [ -d "$cache/ppm_$next" ]; then # could this ever be false ?
380if [ -d "$cache/$next/ppm0" ]; then # could this ever be false ?
380381    empty=true
381382    echo "<TR>"
382    mkdir -p "$out/diff_$next" "$out/thumb_$next"
383    mkdir -p "$out/$next/"{diff,thumb,html,pdf}
383384    while read m; do
384    ppm="$cache/ppm_$next/$m.ppm"
385    fat="$cache/fat_$next/$m.ppm"
386    diff="$out/diff_$next/$m.png"
387    thumb="$out/thumb_$next/$m.png"
385    p1="$cache/$next/ppm1/$m.ppm"
386    p2="$cache/$next/ppm2/$m.ppm"
387    ps="$cache/$next/ps/$m.ps"
388    diff="$out/$next/diff/$m.png"
389    thumb="$out/$next/thumb/$m.png"
390    pdf="$out/$next/pdf/$m.pdf"
388391
389392    echo "<TD>"
390    [ -f "$ppm" ] || continue
391    pngdiff cat "$diff" -f -c 0,1,0 "$ppm" "$ppm" || exit
392    pngdiff shrink "$thumb" -f $THUMB_OPTS -c 0,1,0 "$fat" "$fat" \
393          || exit
394    empty=false
395    mkdir -p "$out/pdf_$next"
396    schps2pdf -T NEW -o "$out/pdf_$next/$m.pdf" \
397      "$cache/ps_$next/$m.ps" || exit
393    [ -f "$p1" ] || continue
394    pngdiff cat "$diff" -f -c 0,1,0 "$p1" "$p1" || exit
395    pngdiff shrink "$thumb" -f $THUMB_OPTS -c 0,1,0 "$p2" "$p2" ||
396      exit
397    schps2pdf -T NEW -o "$pdf" "$ps" || exit
398398    wrapped_png "$out" "$next" "$m"
399    empty=false
399400    done < <(ls -1 "$out/names")
400401    if ! $empty; then
401402     echo "<TD valign=\"middle\">"

Archive Download the corresponding diff file



interactive