info-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: How to find out the CVSROOT and location in the repository of a w o


From: Dale . Miller
Subject: RE: How to find out the CVSROOT and location in the repository of a w orking directory
Date: Mon, 24 Jun 2002 08:50:49 -0500

Shlomo,
If the "CVS internals" change for CVS/Root and CVS/Repository many people
would be changing scripts.  

The global "-t" tag suggestion could be used.  You are correct that the
output goes to STDERR but you could redirect STDERR to STDOUT (2>&1) as
shown in this example program:
----------------------------------------------------------------------------
--------------------------
#!/usr/local/bin/perl -w

$file = "no_such_file";    #use non existing file
@result = `cvs -t status $file 2>&1`;

print "DEBUG1: address@hidden @result\n";

($cvsroot) = grep { s/.*main loop with CVSROOT=(.*)/$1/ } @result;
print "DEBUG2: \$cvsroot=\n$cvsroot\n";

$cvsroot =~ s/^.*:(.*)$/$1/;    # remove any pserver stuff
print "DEBUG3: \$cvsroot=\n$cvsroot\n";
----------------------------------------------------------------------------
--------------------------

I tested the above and got the output below.(note I changed the actual IP
address shown)
Using a non existing file makes the program run quickly.

address@hidden:/home/miller/cvs_stage/cm_tools: testit
DEBUG1: @result=
  -> main loop with CVSROOT=:pserver:address@hidden:/sdhs_mnt2/cvsroot
  -> Connecting to cmp(123.123.123.123):2401
 cvs server: nothing known about no_such_file
 ===================================================================
 File: no file no_such_file             Status: Unknown

    Working revision:   No entry for no_such_file
    Repository revision:        No revision control file


DEBUG2: $cvsroot=
:pserver:address@hidden:/sdhs_mnt2/cvsroot

DEBUG3: $cvsroot=
/sdhs_mnt2/cvsroot


Dale Miller

> -----Original Message-----
> From: Reinstein, Shlomo [mailto:address@hidden
> Sent: Monday, June 24, 2002 7:35 AM
> To: 'address@hidden'; Reinstein, Shlomo; address@hidden
> Subject: RE: How to find out the CVSROOT and location in the 
> repository of a w orking directory
> 
> 
> Hi,
> In my question, I was referring ONLY to the CVSROOT (and repository
> location) of a working directory. Inside a working directory, the
> information is stored in the CVS/Root and CVS/Repository 
> files, and the
> CVSROOT environment variable is not at all interesting (because it is
> overriden by the CVS/Root file).
> Like I said, I could read the CVS/Root file, but I consider 
> this file to be
> "CVS internals", and thus reading it is not a clean solution 
> (that is, I
> would have to change my script if the implementation of CVS 
> changed and this
> file was renamed, for example).
> I got another answer that said to run "cvs -t status" (use 
> the global "-t"
> option). The problem with this, as far as I'm concerned, is 
> that the CVSROOT
> information from the "-t" option goes to the standard error, 
> rather than the
> standard output.
> Thanks,
> Shlomo
> 
> -----Original Message-----
> From: address@hidden [mailto:address@hidden
> Sent: Monday, June 24, 2002 3:27 PM
> To: address@hidden; address@hidden
> Subject: RE: How to find out the CVSROOT and location in the 
> repository
> of a w orking directory
> 
> 
> Shlomo,
> 
> You could have your perl program check the environment for 
> CVSROOT as shown
> here:
> 
> my $CVSROOT = "$ENV{'CVSROOT'}";
> if ($CVSROOT eq "") {
>     print "CVSROOT is not defined - aborting\n";
>     exit 1;
> }
> 
> If you are using pserver you could remove the pserver 
> information using:
> $CVSROOT =~ s/^.*:(.*)$/$1/;    # remove any pserver stuff
> 
> You could also check the CVS/Root file at the first directory 
> in a work
> area.  The content of it should match CVSROOT.
> 
> Dale Miller
> 
> 
> > -----Original Message-----
> > From: Reinstein, Shlomo [mailto:address@hidden
> > Sent: Sunday, June 23, 2002 9:11 AM
> > To: 'address@hidden'
> > Subject: How to find out the CVSROOT and location in the 
> > repository of a w orking directory
> > 
> > 
> > Hi,
> > 
> > Is there a "clean" way to find out what is the CVSROOT of a working
> > directory and where in the repository it is located? I need 
> > to find that out
> > from within a Perl script, and by "clean" I mean that I 
> > prefer not to look
> > into the CVS/Root and CVS/Repository files, because I 
> > consider them to be
> > CVS internals that might change some day.
> > I know that using "cvs status" I can find out the whole 
> > repository path, but
> > there is no separation between the CVSROOT and the location 
> inside the
> > repository.
> > 
> > To be more specific about what I need (maybe there's a way to 
> > do it without
> > caring for the CVSROOT and location), I have a file in each 
> > module that has
> > a fixed name and is used by my script to enable users to 
> > "lock" the module
> > for a short time. Whenever a new branch is created for a 
> > module, this file
> > should be "initialized" for that branch, to indicate that the 
> > branch is "not
> > locked". To do this, the script should modify it and commit a 
> > new revision
> > of it into the branch. (This is needed because the file 
> might indicate
> > "locked" state for the root of the branch.) In order to do 
> > this, I want to
> > check-out a fresh copy of that file (okay, with its whole 
> > directory) to a
> > temporary directory, and then do these things on the copy in 
> > the temporary
> > directory. In order to check it out, I need the CVSROOT and 
> > location within
> > the repository.
> > 
> > Thanks,
> > Shlomo
> > 
> > 
> > 
> > _______________________________________________
> > Info-cvs mailing list
> > address@hidden
> > http://mail.gnu.org/mailman/listinfo/info-cvs
> > 
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]