[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: repository files
From: |
Mark D. Baushke |
Subject: |
Re: repository files |
Date: |
Tue, 16 Dec 2003 09:11:19 -0800 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Ruud Dozijn <address@hidden> writes:
>
> >Ruud Dozijn <address@hidden> writes:
> >
> > > I am looking for an easy way to determine the file names in the
> > repository:
> > >
> > > - I check out a project
> > > - I cd to the project directory (containing the CVS subdirectory)
> > > - is there a cvs subcommand that returns the names of the files in the
> > > current directory that also exist in the repository?
> >
> >You probably want the 'cvs status -l' or 'cvs log -l -R' command.
> >
> >If you just wanted a list of files, the following commands may be useful
> >to you:
> >
> > cvs -q -n status -l | grep File: | sed 's/File: \(.*\)Status:.*/\1/'
> >or
> > cvs -q -n log -l -N -h | grep '^Working file: ' | sed 's/Working
> > file: //'
> >
> >otherwise, you may get more information than you really wanted.
>
> It is allmost what I meant. The cvs log version is no good because it
> give the names of the repository files. In the cvs status command, the
> subdirectory names are not included.
The 'Working file:' line on the cvs log gives you what you want. Avoid
the -l option if you want names of files in subdirectories (your
original question was for the 'current directory')
> What I want to do is write a script that processes all the files that
> are in the repository. So I need the file names of those files
> relatively to the current directory. I want to get a list like
>
> file_1
> file_2
> in/file3
> in/file4
> out/put
cvs -q -n log -N -h | grep '^Working file: ' | sed 's/Working file: //'
> using cvs -Q -n status -R, further processing would be needed if it
> reports a file FILE that exists in several subdirectories.
>
> I'm not sure this is possible using the cvs subcommands. I thought
> maybe it is easier to use the output of the status subcommand, take
> the 'Repository revision' line and remove from the file name the ,v
> and the part of the filename that is in CVS/Repository and CVS/Root.
> What do you think?
If you are willing to troll thru the CVS files, then the following
script may be what you want.
-- Mark
#!/usr/bin/perl
# find all non-cvs controlled files
use strict;
use File::Find;
my(%globalfind, $key);
File::Find::find(\&wanted, '.');
foreach $key (sort keys %globalfind) {
print $key,"\n" if ($globalfind{$key} eq 'cvs' && -f $key );
}
sub wanted {
my($name) = $File::Find::name;
my($dir) = $File::Find::dir;
if ($_ eq 'CVS') {
$File::Find::prune = 1;
$globalfind{$dir} = 'cvs';
proc_cvs_entries($dir, 'CVS/Entries') if ( -f 'CVS/Entries' );
} else {
# not a CVS controlled entity
$globalfind{$name} = 'non-cvs' if ($globalfind{$name} ne 'cvs');
}
}
# Process a CVS/Entries file
sub proc_cvs_entries {
my($pdir, $entries) = @_;
my($entry, $file, $rest);
# A typical CVS/Entries file looks like this:
# D
#or
# D/<directory-name>////
#or
# <optionaltag>/file/...
if (open(ENTRIES, $entries)) {
while($entry=<ENTRIES>) {
chomp($entry);
# Just 'D' on a line by itself indicates that all
# subdirectories have been enumerated in the Entries file
# already.
next if ($entry eq 'D');
# We don't care about anything but the name of the file
(undef, $file, $rest) = split(/\//, $entry, 3);
$globalfind{$pdir.'/'.$file} = 'cvs'; # mark as processed
}
close(ENTRIES);
} else {
warn "Unable to read $entries: $!";
}
}
__END__
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)
iD8DBQE/3zy23x41pRYZE/gRAhQpAKCCIf8V4hyM6+qWqcdRF+HGKeebUACeN+Hd
XTK7Haudvp5ejuSm0Ozl+So=
=snlD
-----END PGP SIGNATURE-----