cln-cvs-hist

cln-cvs-hist-w.sh

#! /bin/sh 
export LC_ALL=zh_CN.UTF-8 
cd /bin2/ 
sh cln-cvs-hist-weekly.sh > cln-cvs-hist-weekly.sh.log 2>&1

/usr/bin/mutt -s "scm1-scm4 cln-cvs-hist-weekly" scm-svr-mtr@scm5.***.cn < cln-cvs-hist-weekly.sh.log

cln-cvs-hist-weekly.sh

#!/bin/sh 
find /cvsroot/ -type d -follow -name CVSROOT -exec perl cln-cvs-hist {} ; 
find /cvsroot/ -type f -follow -name history* -exec chmod g+w {} ; 
find /cvsroot/ -type f -follow -name history -exec du -sh {} ;

cln-cvs-hist

#! /usr/bin/perl 
# -*-Perl-*- 
# Copyright (C) 1995-2005 The Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify 
# it under the terms of the GNU General Public License as published by 
# the Free Software Foundation; either version 2, or (at your option) 
# any later version. 
# 
# This program is distributed in the hope that it will be useful, 
# but WITHOUT ANY WARRANTY; without even the implied warranty of 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
# GNU General Public License for more details. 
# 
# Contributed by David G. Grubbs <[email protected]> 
# 
# Clean up the history file.  10 Record types: MAR OFT WUCG 
# 
# WUCG records are thrown out. 
# MAR records are retained. 
# T records: retain only last tag with same combined tag/module. 
# 
# Two passes:  Walk through the first time and remember the 
#    1. Last Tag record with same "tag" and "module" names. 
#    2. Last O record with unique user/module/directory, unless followed 
#       by a matching F record. 
#

#$r = $ENV{"CVSROOT"}; 
$r = "$ARGV[0]"; 
#$c = "$r/CVSROOT"; 
$h = "$r/history";

eval "print STDERR $die='Unknown parameter $1n' if !defined $$1; $$1=$';" 
while ($ARGV[0] =~ /^(w+)=/ && shift(@ARGV)); 
exit 255 if $die;               # process any variable=value switches

!chdir("$r");

%tags = (); 
%outs = ();

# 
# Move history file to safe place and re-initialize a new one. 
# 
rename($h, "$h.bak"); 
open(XX, ">$h"); 
close(XX);

# 
# Pass1 -- remember last tag and checkout. 
# 
open(HIST, "$h.bak"); 
while (<HIST>) { 
next if /^[MARWUCG]/;

# Save whole line keyed by tag|module 
if (/^T/) { 
@tmp = split(/|/, $_); 
$tags{$tmp[4] . '|' . $tmp[5]} = $_; 
} 
# Save whole line 
if (/^[OF]/) { 
@tmp = split(/|/, $_); 
$outs{$tmp[1] . '|' . $tmp[2] . '|' . $tmp[5]} = $_; 
} 
}

# 
# Pass2 -- print out what we want to save. 
# 
open(SAVE, ">$h.work"); 
open(HIST, "$h.bak"); 
while (<HIST>) { 
next if /^[FWUCG]/;

# If whole line matches saved (i.e. "last") one, print it. 
if (/^T/) { 
@tmp = split(/|/, $_); 
next if $tags{$tmp[4] . '|' . $tmp[5]} ne $_; 
} 
# Save whole line 
if (/^O/) { 
@tmp = split(/|/, $_); 
next if $outs{$tmp[1] . '|' . $tmp[2] . '|' . $tmp[5]} ne $_; 
}

print SAVE $_; 
}

# 
# Put back the saved stuff 
# 
system "cat $h >> $h.work";

if (-s $h) { 
rename ($h, "$h.interim"); 
print "history.interim has non-zero size.n"; 
} else { 
unlink($h); 
}

rename ("$h.work", $h);

exit(0);

你可能感兴趣的:(cln-cvs-hist)