Monday, March 28, 2005

view_cvs_addfile


#!/usr/bin/perl

#$cvs history -c| view_cvs_addfile
#のように使う

use Getopt::Std;
getopts("peh");#-p path, -e existance file only, -h help

if($opt_h){
print "type\n 'perldoc view_cvs_addfile'\n";
exit 8;
}

while(<>){
#read only output from $cvs histry -c
@words= split;
%files;
if($opt_p){
$fname= "$words[9]/$words[6]";

#expand ~/ to /home/usrname/
$fname =~ s{ ^ ~ ( [^/]* ) }
{ $1
? (getpwnam($1))[7]
: ( $ENV{HOME} || $ENV{LOGDIR}
|| (getpwuid($<))[7]
)
}ex;

}else{
$fname= $words[6];
}
if($words[0] eq "A" or $words[0] eq "M"){
$files{$fname}= 1;
}elsif($words[0] eq "R"){
$files{$fname}= 0;
}
}

foreach (sort keys %files){
if($opt_e){
if(-e $_ && -w $_){
print"$_\n" if $files{$_};
}
}else{
print"$_\n" if $files{$_};
}
}


=head1 NAME

view_cvs_addfile - view cvs add file from cvs histry

=head1 SYNOPSIS

example
$ cvs history -c |grep module_name|view_cvs_addfile

options
-p output with fullpath, -e existance file only, -h help

=head1 DESCRIPTION

cvs に登録しているファイルを抜き出す。

使用例
モジュール module_name に登録しているファイルの確認
$ cvs history -c |grep module_name|view_cvs_addfile

cvs に 登録しているテストファイル以外の行数の確認
$ cvs history -c |grep module_name|view_cvs_addfile

=cut






0 Comments:

Post a Comment

<< Home