User Tools

Site Tools


en:linux:scripts:cvsst

/home/<username>/bin/cvsst

CVS status readable and in color!

#! /usr/bin/perl -w

use Term::ANSIColor;
use IPC::Open3;

#      $field3 = $3 || "";
#	  $field1 =~ s/\/afs\/domain.com\/cms\/sw\/slc3_ia32_gcc323\/cms\/cmssw\/CMSSW_1_2_3\/src\///;

# process argument line
$flagNuptodate = 0;
$flagUnknown = 0;
foreach $argnum (0 .. $#ARGV)
{
   if ($ARGV[$argnum] eq "-n") { $flagNuptodate = 1; }
   if ($ARGV[$argnum] eq "-u") { $flagUnknown = 1; }
}

# run the command
open3('<&STDIN', \*OUT, \*OUT, 'cvs status');

# process command output, line by line
$prefix = "";
while(<OUT>)
{
	# check for unknown files
	if (m/^\? (.*)$/) 
	{
											{ $stat =  color("yellow") . "    unknown" . color("reset"); }
		print("[ $stat ] $1\n");
	} 
	# check for lines with status
	elsif (m/File: (.*)\s*Status: (.*)\s*/ && ! $flagUnknown)
	{
		if ($flagNuptodate && ($2 eq "Up-to-date")) { next }

		$stat = $2;
		if ($stat eq "Up-to-date")			{ $stat =   color("green") . " up-to-date" . color("reset"); }
		if ($stat eq "Locally Modified")	{ $stat =     color("red") . "   modified" . color("reset"); }
		if ($stat eq "Needs Patch")			{ $stat =    color("blue") . "needs patch" . color("reset"); }
		if ($stat eq "Needs Checkout")		{ $stat = color("magenta") . "    missing" . color("reset"); }
		if ($stat eq "Locally Added")		{ $stat =    color("cyan") . "      added" . color("reset"); }
		print("[ $stat ] $prefix/$1\n");
	} elsif (m/^cvs status: Examining (.*)$/) {
		$prefix = $1
	} 
	# what to do else: nothing
	else
	{
			#print($_);
	}
}

# Get the return code of the compiler and exit with that.
#waitpid($compiler_pid, 0);
#exit ($? >> 8);




en/linux/scripts/cvsst.txt · Last modified: 2010/01/19 14:19 (external edit)