[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: List of files' revision which tag by <TAG NAME>
From: |
Colm Murphy |
Subject: |
Re: List of files' revision which tag by <TAG NAME> |
Date: |
Wed, 06 Mar 2002 09:32:47 +0000 |
User-agent: |
Mozilla/5.0 (Windows; U; WinNT4.0; en-GB; rv:0.9.4) Gecko/20011019 Netscape6/6.2 |
Hi Nir,
Here is a perl script that I use for that very purpose.
Colm A
Nir Harel wrote:
Is there any command to get back the list of files with there revision by
input the tag name only ?
#!/usr/local/bin/perl -w
###############################################################################
#
# Description : Prints either a list of tags for a module or a list of files
for a tag.
# taginfo operates on files in the repository.!!
#
#################################################################################
#------------------------------------------------------------------------------
# Parameters
#------------------------------------------------------------------------------
$usageinfo = "Usage: rtaginfo [-d <cvsroot>] -t <module list>|<dir list> | -f
<Tag>\n";
$usageinfo = $usageinfo." -d <cvsroot> Use the cvsroot
repository\n";
$usageinfo = $usageinfo." -t <module list>|<dir list> Print a list of
tags used in module or dir\n";
$usageinfo = $usageinfo." -f <tag> Print a list of all
files containing tag\n";
$usageinfo = $usageinfo."\nUse taginfo to view tags in your sandbox.\n";
$argno = "1";
foreach $arg (@ARGV)
{
if ($arg eq "-d")
{
$root = $ARGV[$argno];
}
elsif ($arg eq "-t")
{
$mode = "show_tags";
if ($ARGV[$argno])
{
# The splice command removes all entries from a list from an offset
and returns them.
$modulelist = join " ", splice @ARGV, $argno;
}
else
{
print $usageinfo;
exit;
}
}
elsif ($arg eq "-f")
{
$mode = "show_files";
if (!$ARGV[$argno])
{
print $usageinfo;
exit;
}
else
{
$chosentag = $ARGV[$argno];
$modulelist = ".";
}
}
$argno++;
}
if (!$mode)
{
print $usageinfo;
exit;
}
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Parse the logfile
#------------------------------------------------------------------------------
parselog();
if ($mode eq "show_tags")
{
print "----------------------------------------\n";
print "$modulelist contain the following tags\n";
print "----------------------------------------\n";
map{ print "$_\n"; } (sort keys %tagdetails);
print "----------------------------------------\n";
}
elsif ($mode eq "show_files")
{
if ($tagdetails{$chosentag})
{
print "----------------------------------------\n";
print "The following files contain the tag $chosentag \n";
print "----------------------------------------\n";
@filelist = split (/,/,$tagdetails{$chosentag});
foreach $file (@filelist)
{
print "$file\n";
}
print "----------------------------------------\n";
}
else
{
print "Found no files containing the tag $chosentag \n";
}
}
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Subroutine: parselog
#
#------------------------------------------------------------------------------
sub parselog
{
my $Flag = 0;
print "Running cvs rlog. This may take some time ... \n";
if ($root)
{
$cvsopt = "-d $root -q rlog -h $modulelist";
}
else
{
$cvsopt = "-q rlog -h $modulelist";
}
open(CVS_LOG," cvs $cvsopt|")
|| die "Problems running cvs $cvsopt !\n";
# $x is a control variable for the rotating bar indicating that program is
still alive.
$x =0;
# Flushing the output making bar really rotating.
$| = 1;
while ( defined ($line = <CVS_LOG> ) )
{
if($line =~ /^RCS file:\s(\S+),v/)
{
$rcsfile = $1;
}
if($line =~ /symbolic names:/)
{
$Flag = 1;
next;
}
if( $Flag )
{
if($line !~ /^\s+(\S+):\s(\S+)$/ )
{
$Flag = 0;
next;
}
$tagdetails{$1} = "$tagdetails{$1},$rcsfile:$2";
}
# This breathtaking rotating star ...
# Octal \010 is backspace character code.
if ( ($x % 40) == 1)
{
print "\010\/";
}
elsif ( ($x % 40) == 11)
{
print "\010|";
}
elsif ( ($x % 40) == 21)
{
print "\010\\";
}
elsif ( ($x % 40) == 31)
{
print "\010-";
}
elsif ($x == 41)
{
$x=0;
}
$x++;
}
# Closing the pipe from 'cvs log'.
close (CVS_LOG);
return;
}
#------------------------------------------------------------------------------