4 # Contributed by David G. Grubbs <dgg@ksr.com>
6 # Clean up the history file. 10 Record types: MAR OFT WUCG
8 # WUCG records are thrown out.
9 # MAR records are retained.
10 # T records: retain only last tag with same combined tag/module.
12 # Two passes: Walk through the first time and remember the
13 # 1. Last Tag record with same "tag" and "module" names.
14 # 2. Last O record with unique user/module/directory, unless followed
15 # by a matching F record.
22 eval "print STDERR \$die='Unknown parameter $1\n' if !defined \$$1; \$$1=\$';"
23 while ($ARGV[0] =~ /^(\w+)=/ && shift(@ARGV));
24 exit 255 if $die; # process any variable=value switches
30 # Move history file to safe place and re-initialize a new one.
37 # Pass1 -- remember last tag and checkout.
43 # Save whole line keyed by tag|module
45 @tmp = split(/\|/, $_);
46 $tags{$tmp[4] . '|' . $tmp[5]} = $_;
50 @tmp = split(/\|/, $_);
51 $outs{$tmp[1] . '|' . $tmp[2] . '|' . $tmp[5]} = $_;
56 # Pass2 -- print out what we want to save.
58 open(SAVE
, ">$h.work");
63 # If whole line matches saved (i.e. "last") one, print it.
65 @tmp = split(/\|/, $_);
66 next if $tags{$tmp[4] . '|' . $tmp[5]} ne $_;
70 @tmp = split(/\|/, $_);
71 next if $outs{$tmp[1] . '|' . $tmp[2] . '|' . $tmp[5]} ne $_;
78 # Put back the saved stuff
80 system "cat $h >> $h.work";
83 rename ($h, "$h.interim");
84 print "history.interim has non-zero size.\n";
89 rename ("$h.work", $h);