[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Obtaining a list of all projects in CVS
From: |
Dale Miller |
Subject: |
Re: Obtaining a list of all projects in CVS |
Date: |
Tue, 28 Nov 2000 12:27:18 -0600 |
Several people have asked "how do you get a list of all the files in
a CVS repository?"
I use a perl program that creates a file for each Project in the
repository that I need a list for. I use an array (@PROJECTS)
to identify the Projects. I generate the list files and keep
them in my CVS repository so I have a new version anytime
new files are added to a project. The files are kept in a
project I call "locations".
The files contain directory names and file names.
The directory names end with a slash.
The location files are very useful because I can grep the
files to quickly see if and where a file is located in the
repository.
------------------ CUT HERE -------------------------------
#!/usr/local/bin/perl -ws
# update_locations Dale C. Miller 13-AUG-1999
#
# $Id: update_locations,v 1.5 2000/11/28 18:30:15 miller Exp $
#
# This program creates a list file of all the directories and files
# in the CVS repository for each Project.
#
# @PROJECTS defines which projects to include and is changed while
# more projects are added to the repository.
#
# The ${project}_list files are created in a /tmp location and
# are checked in to the repository under a locations project.
#
# This program can be use directly or in a crontab.
#
# The list files are used to quickly determine if and where files exist
# in the repository and are used by several programs that I have
# written for the software engineers to use.
#
# This program runs in about 6 seconds on maiscm with over 16,000 files
# spread across 13 projects.
# I have a CVS repository on three different machines so set @PROJECTS
# using uname -n value (not using hostname because SGI box gives full domain)
$uname = `uname -n`;
chomp $uname;
if ($uname eq "maiscm") {
@PROJECTS = (qw(afwin afwin34 afwin-fs cm_notes cm_tools conus cvs_testing
mais-fs pgs pro pro6 pro
7 sc2));
} elsif ($uname eq "cmp") {
@PROJECTS = (qw(SDHSU swafs));
} elsif ($uname eq "sys3d") {
@PROJECTS = (qw(SDHSU));
} else {
print "This program must be used on maiscm, cmp, or sys3d\n";
exit 1;
}
$cvsroot = "$ENV{'CVSROOT'}" unless defined $cvsroot;
if ("$cvsroot" eq "") {
print "CVSROOT is not defined - aborting\n";
exit 1;
} else {
$cvsroot =~ s/^.*:(.*)$/$1/; #remove :pserver:address@hidden: if present
}
$cvs_stage = "cvs_stage$$"; # unique name for temporary work directory
$cvs_dir = "locations"; # project name to commit generated files to
mkdir ("/tmp/$cvs_stage", 0775) || die "Cannot mkdir /tmp/$cvs_stage: $!\n";
chdir ("/tmp/$cvs_stage") || die "Cannot chdir to /tmp/$cvs_stage: $!\n";
# -- check out any existing files -- the locations directory must exist
# in the repository for this to work
$cvs_status = system("cvs checkout $cvs_dir");
#check status of the cvs commit command
if ($cvs_status) {
print "cvs checkout $cvs_dir FAILED: $!\n";
print "$0 aborted\n";
exit 1;
}
foreach (@PROJECTS) {
$project = $_;
@allfiles = `find $cvsroot/$project`;
$output = "/tmp/$cvs_stage/$cvs_dir/${project}_list";
open(OUTPUT, ">$output") or die "Cannot open $output file: $!\n";
foreach (sort @allfiles) {
chomp;
next if ($_ =~ /\/CVS(\/|$)/); # skip CVS directories
next if ($_ =~ /\/Attic(\/|$)/); # skip files in Attic (dead files)
s/$cvsroot\/(.*)$/$1\//; # remove cvsroot and add trailing /
s/(.*),v\/$/$1/; # remove ,v/ from files
# -- at this point directories will have a slash at the end and
# file names will not have the ,v at the end
print OUTPUT "$_\n";
}
close (OUTPUT);
# -- check if file exist in CVS or needs to be added
if (-e "$cvsroot/$cvs_dir/${project}_list,v") {
#file exists so update cvs file
$cvs_status = system("cvs commit -m \"update\" $cvs_dir/${project}_list");
#check status of the cvs commit command
if ($cvs_status) {
print "cvs commit -m \"update\" $cvs_dir/${project}_list FAILED: $!\n";
exit 1;
}
} else {
# file does not exist so it must be added first
print "$cvsroot/$cvs_dir/${project}_list,v does not exist\n";
chdir ("$cvs_dir");
$cvs_status = system("cvs add -m \"new locations file\" ${project}_list");
#check status of the cvs add command
if ($cvs_status) {
print "cvs add -m \"new locations file\" ${project}_list FAILED: $!\n";
} else {
# add worked so now do the commit
$cvs_status = system("cvs commit -m \"update\" ${project}_list");
#check status of the cvs commit command
if ($cvs_status) {
print "cvs commit -m \"update\" ${project}_list FAILED: $!\n";
exit 1;
}
}
chdir ("..");
}
}
# -- cleanup, remove the temporay work directory
chdir ("/tmp") || die "Cannot chdir to /tmp: $!\n";
$rm_status = system("rm -rf $cvs_stage");
if ($rm_status) {
print "rm -rf $cvs_stage FAILED: $!\n";
}
----------------- END CUT----------------------------
"Derek R. Price" wrote:
> Antony Stace wrote:
>
> > Is there a command which will list information about all the projects in
> > the CVS repository? Ie, what projects exist, what files are being
> > worked on in each project, etc. Or do I need to write a script to get
> > this type of info?
>
> There isn't one. 'cvs co -c' and 'cvs co -s' will work if the modules
> admin file is up to date but you shouldn't set up a modules file for this
> reason.
>
> The easiest way is to use 'ls' in the toplevel of the repo if you have
> access.
>
> You can try the following to get a complete file list, and you might be
> able to deduce the project list from that:
>
> cvs -nq rdiff -s -D"Jan 1, 1970" . |awk '{print $2}'
>
> There's also a wrapper script floating aroud that I'm told does what you
> ask. Search the mail archives.
>
> Derek
>
> --
> Derek Price CVS Solutions Architect ( http://CVSHome.org
> )
> mailto:address@hidden OpenAvenue ( http://OpenAvenue.com )
> --
> "I tried to think but nothing happened!"
> - Curly
>
> _______________________________________________
> Info-cvs mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/info-cvs