4 # Copyright (C) 1995-2005 The Free Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # Contributed by David G. Grubbs <dgg@ksr.com>
18 # Clean up the history file. 10 Record types: MAR OFT WUCG
20 # WUCG records are thrown out.
21 # MAR records are retained.
22 # T records: retain only last tag with same combined tag/module.
24 # Two passes: Walk through the first time and remember the
25 # 1. Last Tag record with same "tag" and "module" names.
26 # 2. Last O record with unique user/module/directory, unless followed
27 # by a matching F record.
34 eval "print STDERR \$die='Unknown parameter $1\n' if !defined \$$1; \$$1=\$';"
35 while ($ARGV[0] =~ /^(\w+)=/ && shift(@ARGV));
36 exit 255 if $die; # process any variable=value switches
42 # Move history file to safe place and re-initialize a new one.
49 # Pass1 -- remember last tag and checkout.
55 # Save whole line keyed by tag|module
57 @tmp = split(/\|/, $_);
58 $tags{$tmp[4] . '|' . $tmp[5]} = $_;
62 @tmp = split(/\|/, $_);
63 $outs{$tmp[1] . '|' . $tmp[2] . '|' . $tmp[5]} = $_;
68 # Pass2 -- print out what we want to save.
70 open(SAVE, ">$h.work");
75 # If whole line matches saved (i.e. "last") one, print it.
77 @tmp = split(/\|/, $_);
78 next if $tags{$tmp[4] . '|' . $tmp[5]} ne $_;
82 @tmp = split(/\|/, $_);
83 next if $outs{$tmp[1] . '|' . $tmp[2] . '|' . $tmp[5]} ne $_;
90 # Put back the saved stuff
92 system "cat $h >> $h.work";
95 rename ($h, "$h.interim");
96 print "history.interim has non-zero size.\n";
101 rename ("$h.work", $h);