#!/bin/sh # tla-file-log -- Output a historical log for a file in an arch project tree # # Written by Miles Bader me="`basename $0`" test "$#" = 1 || { echo 1>&2 "Usage: $me FILE"; exit 1; } test -d {arch} || { echo 1>&2 "$me: Not in an arch project tree"; exit 2; } for V in `tla logs`; do for R in `tla log-ls -f $V`; do echo "@@@" tla cat-log $R done done | nawk ' BEGIN { file = "'"$1"'" sub (/^\.\//, "", file) reset() } function reset() { matches = 0 action = 0 in_hdrs = 1 hdr_cont = 0 } function scan_hdr(first_field, possible_action ,fn) { for (fn = first_field; fn <= NF; fn++) { mf = $fn sub (/^\.\//, "", mf) if (mf == file) { matches = 1 if (possible_action) action = possible_action } } } function hdr_text( txt) { txt = substr ($0, length ($1) + 1) sub (/^ */, "", txt) return txt } /^@@@$/ { reset(); next } in_hdrs && /^Revision:/ { revision = hdr_text(); next } in_hdrs && /^Archive:/ { archive = hdr_text(); next } in_hdrs && /^Creator:/ { creator = hdr_text(); next } in_hdrs && /^Summary: *[^ ]/ { summary = hdr_text(); next } in_hdrs && /^Standard-date: *[^ ]/ { date = hdr_text(); next } in_hdrs && /^Modified-files:/ { hdr_cont = 1; scan_hdr(2, 0); next } in_hdrs && /^(New-files:|New-directories:)/ { hdr_cont = 1; scan_hdr(2, "added"); next } in_hdrs && /^(Removed-files:|Removed-directories:)/ { hdr_cont = 1; scan_hdr(2, "removed"); next } in_hdrs && /^(Renamed-files:|Renamed-directories:)/ { hdr_cont = 1; scan_hdr(2, "renamed"); next } hdr_cont && /^[ ]/ { scan_hdr(1); next } in_hdrs && /^$/ { in_hdrs = 0 if (matches) { print "----------------" print "Revision: " archive "/" revision print "Date: " date print "Creator: " creator if (action) print "Action: " action if (summary) print "Summary: " summary print "" } next } in_hdrs { hdr_cont = 0; next } { if (matches) print } ' # arch-tag: 5bce1323-697f-4d9d-91db-769293429d18