Skip Menu |

This queue is for tickets about the Cvs CPAN distribution.

Report information
The Basics
Id: 5875
Status: open
Priority: 0/
Queue: Cvs

People
Owner: Nobody in particular
Requestors: barnish [...] hotmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.06
Fixed in: (no value)



Subject: StatusItem->basedir appears to be broken
The file Status.pm is looking for the wrong string from the cvs server for the file directory (basedir) At least on my cvs version 1.11.1p1 it is. The following change seems to fix the problem diff Status.pm.orig Status.pm 36c36 < qr/cvs status: Examining (.*)\n$/, sub --- Show quoted text
> qr/cvs server: Examining (.*)\n$/, sub
To: bug-Cvs [...] rt.cpan.org
Subject: Re: [cpan #5875] StatusItem->basedir appears to be broken
From: Olivier Poitrey <olivier [...] pas-tres.net>
Date: Fri, 02 Apr 2004 10:00:31 +0200
RT-Send-Cc:
"Guest via RT" <bug-Cvs@rt.cpan.org> writes: Show quoted text
> The file Status.pm is looking for the wrong string from the cvs > server for the file directory (basedir) At least on my cvs version > 1.11.1p1 it is. > > The following change seems to fix the problem > diff Status.pm.orig Status.pm > 36c36 > < qr/cvs status: Examining (.*)\n$/, sub > ---
>> qr/cvs server: Examining (.*)\n$/, sub
Looks like a change in new cvs versions. I just fixed that in the CVS, problem will be fixed in the next release. Thanks for you help. -- Show quoted text
______________________________________________________________________ O l i v i e r P o i t r e y
Also I noticed that the Basedir does not get set unless the status command is performed on a directory. This seems to be because the server does not output the "cvs server: Examining" string for single files. Why not use the directory string after "Repository version" to populate the Basedir ? [olivier@pas-tres.net - Fri Apr 2 03:07:12 2004]: Show quoted text
> "Guest via RT" <bug-Cvs@rt.cpan.org> writes: >
> > The file Status.pm is looking for the wrong string from the cvs > > server for the file directory (basedir) At least on my cvs version > > 1.11.1p1 it is. > > > > The following change seems to fix the problem > > diff Status.pm.orig Status.pm > > 36c36 > > < qr/cvs status: Examining (.*)\n$/, sub > > ---
> >> qr/cvs server: Examining (.*)\n$/, sub
> > Looks like a change in new cvs versions. I just fixed that in the CVS, > problem will be fixed in the next release. > > Thanks for you help.
[guest - Fri Apr 2 04:45:25 2004]: Show quoted text
> Also I noticed that the Basedir does not get set unless the status > command is performed on a directory. This seems to be because the > server does not output the "cvs server: Examining" string for single > files. Why not use the directory string after "Repository version" to > populate the Basedir ?
Can you elaborate ?
Basically, on the test module shipped with Cvs-0.06, I do the following: my $cvs = new Cvs 'cvs-test'; my $status = $cvs->status('test.txt'); $status->basedir will be undefined because the status command was done on a file only. $status = $cvs->status('.', {multiple=>1}->first; $status->basedir will contain "." because the status command was done on directory. e.g. try: Show quoted text
> pwd
/user/asb/Cvs-0.06 Show quoted text
> perl t/00checkout.t > cd cvs-test > cvs stat .
cvs status: Examining . =================================================================== File: test.txt Status: Locally Modified Working revision: 1.26 Sat Apr 10 15:47:49 2004 Repository revision: 1.26 /user/asb/Cvs-0.06/cvs/test/test.txt,v Sticky Tag: (none) Sticky Date: (none) Sticky Options: (none) Show quoted text
> cvs stat test.txt
=================================================================== File: test.txt Status: Locally Modified Working revision: 1.26 Sat Apr 10 15:47:49 2004 Repository revision: 1.26 /user/asb/Cvs-0.06/cvs/test/test.txt,v Sticky Tag: (none) Sticky Date: (none) Sticky Options: (none) Also, I noticed the string is actually "cvs status: Examining <dir>" for a file based repository, while it is "cvs server: Examining <dir>" for a pserver based repository. So your fix may not be correct in all cases.. I think the directory string after "Repository version" might be a better way to fill the basedir field. [RSOLIV - Tue Apr 6 15:20:36 2004]: Show quoted text
> [guest - Fri Apr 2 04:45:25 2004]: >
> > Also I noticed that the Basedir does not get set unless the status > > command is performed on a directory. This seems to be because the > > server does not output the "cvs server: Examining" string for
single Show quoted text
> > files. Why not use the directory string after "Repository version"
to Show quoted text
> > populate the Basedir ?
> > > Can you elaborate ?
From: whdaffer [...] wabcmail.com
There is an additional consideration. $status->basedir is the *working* directory when status is done on a directory. The item to the right of "Repository version" in the output from `cvs status' is the *repository* directory. They may not be the same, in fact there may be one or more missing directory levels depending on who one used '-d' during checkout. I would like to see both pieces of information provided in the output from Cvs::Status, in fact I'm in such great need of information about the repository that I have to wrap Cvs in an object of my own and then parse the CVS/Root and CVS/Repository files to get it. Perhaps we could have two fields, `basedir' (suitably populated when status is done on a single file) and another (it could be named something like "repository_dir") having whatever is to the right of "Repository Version" from the output of the 'cvs status.' That would certainly suit my needs. William Daffer [guest - Sun Apr 25 17:30:04 2004]: Show quoted text
> Basically, on the test module shipped with Cvs-0.06, I do the > following: > > my $cvs = new Cvs 'cvs-test'; > my $status = $cvs->status('test.txt'); > > $status->basedir will be undefined because the status command was done > on a file only. > > $status = $cvs->status('.', {multiple=>1}->first; > > $status->basedir will contain "." because the status command was done > on directory. > > e.g. try: >
> > pwd
> /user/asb/Cvs-0.06
> > perl t/00checkout.t > > cd cvs-test > > cvs stat .
> > cvs status: Examining . >
========================================================= ========== Show quoted text
> File: test.txt Status: Locally Modified > > Working revision: 1.26 Sat Apr 10 15:47:49 2004 > Repository revision: 1.26 /user/asb/Cvs-0.06/cvs/test/test.txt,v > Sticky Tag: (none) > Sticky Date: (none) > Sticky Options: (none) >
> > cvs stat test.txt
> >
========================================================= ========== Show quoted text
> File: test.txt Status: Locally Modified > > Working revision: 1.26 Sat Apr 10 15:47:49 2004 > Repository revision: 1.26 /user/asb/Cvs-0.06/cvs/test/test.txt,v > Sticky Tag: (none) > Sticky Date: (none) > Sticky Options: (none) > > > > Also, I noticed the string is actually "cvs status: Examining <dir>" > for a file based repository, while it is "cvs server: Examining <dir>" > for a pserver based repository. So your fix may not be correct in all > cases.. > > I think the directory string after "Repository version" might be a > better way to fill the basedir field. > > > [RSOLIV - Tue Apr 6 15:20:36 2004]: >
> > [guest - Fri Apr 2 04:45:25 2004]: > >
> > > Also I noticed that the Basedir does not get set unless the status > > > command is performed on a directory. This seems to be because the > > > server does not output the "cvs server: Examining" string for
> single
> > > files. Why not use the directory string after "Repository version"
> to
> > > populate the Basedir ?
> > > > > > Can you elaborate ?
>
To: bug-Cvs [...] rt.cpan.org
Subject: Re: [cpan #5875] StatusItem->basedir appears to be broken
From: Olivier Poitrey <olivier [...] pas-tres.net>
Date: Thu, 20 May 2004 20:59:01 +0200
RT-Send-Cc:
"Guest via RT" <bug-Cvs@rt.cpan.org> writes: Show quoted text
> There is an additional consideration. $status->basedir is the > *working* directory when status is done on a directory. The item to > the right of "Repository version" in the output from `cvs status' is > the *repository* directory. They may not be the same, in fact there > may be one or more missing directory levels depending on who one > used '-d' during checkout. > > I would like to see both pieces of information provided in the > output from Cvs::Status, in fact I'm in such great need of > information about the repository that I have to wrap Cvs in an > object of my own and then parse the CVS/Root and CVS/Repository > files to get it. > > Perhaps we could have two fields, `basedir' (suitably populated when > status is done on a single file) and another (it could be named > something like "repository_dir") having whatever is to the right of > "Repository Version" from the output of the 'cvs status.' That would > certainly suit my needs.
Sounds not bad to me, could you propose a patch ? -- Show quoted text
______________________________________________________________________ O l i v i e r P o i t r e y
From: whdaffer [...] wabcmail.com
[olivier@pas-tres.net - Thu May 20 14:58:12 2004]: Show quoted text
> "Guest via RT" <bug-Cvs@rt.cpan.org> writes: >
> > There is an additional consideration. $status->basedir is the > > *working* directory when status is done on a directory. The item to > > the right of "Repository version" in the output from `cvs status' is > > the *repository* directory. They may not be the same, in fact there > > may be one or more missing directory levels depending on who one > > used '-d' during checkout. > > > > I would like to see both pieces of information provided in the > > output from Cvs::Status, in fact I'm in such great need of > > information about the repository that I have to wrap Cvs in an > > object of my own and then parse the CVS/Root and CVS/Repository > > files to get it. > > > > Perhaps we could have two fields, `basedir' (suitably populated when > > status is done on a single file) and another (it could be named > > something like "repository_dir") having whatever is to the right of > > "Repository Version" from the output of the 'cvs status.' That would > > certainly suit my needs.
> > Sounds not bad to me, could you propose a patch ?
Okay. See the attached patch file. I'm new to making patchfiles, so I hope I've done it correctly. While I was in there I changed the RE which started this whole discussion about basedir, so the line that captures the "cvs ... Examining ..." will now trip for 'cvs server' as well as 'cvs status...' I've changed Status.pm (to capture the information) and StatusItem.pm (to have some new fields). I added the 'date' and 'repository_file' to the latter. I know I said I wanted the repository directory, but I figure that anyone who wants to use this information (myself included) can do the parsing just as well as Status.pm. Leaving it as the unadulterated output from cvs seemed cleaner to me. I also updated the documentation in StatusItem.pm I've tested only on a local repository, I haven't tested this with a remote pserver setup, as I don't use them yet, nor has it been tested with an 'ssh' type server. I have some questions about another modules, namely Base.pm, but I'll take these up in another message.
diff -Naur Cvs-0.06/lib/Cvs/Command/Status.pm Cvs-0.06.01/lib/Cvs/Command/Status.pm --- Cvs-0.06/lib/Cvs/Command/Status.pm 2003-03-25 14:01:57.000000000 -0800 +++ Cvs-0.06.01/lib/Cvs/Command/Status.pm 2004-05-21 14:05:10.000000000 -0700 @@ -33,7 +33,7 @@ $tags->push_handler ( - qr/cvs status: Examining (.*)\n$/, sub + qr/cvs (?:server|status): Examining (.*)\n$/, sub { $current_directory = shift->[1]; } @@ -90,8 +90,34 @@ { my($match) = @_; my $filename = $match->[1]; - $filename =~ s/^\s+|\s$//g; - $result->basedir($current_directory); + $filename =~ s/^\s+|\s+$//g; + if (!$current_directory) { + my ($path, $name); + my @args=@{$self->{args}}; + my $i; + for($i=0;$i<=@args;$i++) { + last if $args[$i++] =~ /-v/; + } + + # a list of files, possibly unqualified. + @args = @args[ $i .. $#args]; + + foreach (@args) { + use File::Basename; + ($name, $path) = fileparse($_); + if ($name eq $filename) { + $path = $self->cvs->working_directory + if ($path eq "./"); + last; + } + } + $result->basedir($path); + } elsif ($current_directory eq ".") { + $result->basedir($self->cvs->working_directory()); + } else { + $result->basedir($current_directory); + } + $result->status($match->[2]); $result->exists(1); if($filename =~ /^no file (.*)$/) @@ -104,18 +130,24 @@ ); $main->push_handler ( - qr/^\s+Working revision:\s+([\d\.]+|No entry for .*)/, sub + qr/^\s+Working revision:\s+([\d\.]+|No entry for .*)\s*(.*)/, sub { my($match) = @_; - $result->working_revision($match->[1]) if $match->[1] =~ /^[\d.]+$/; - } + if ($match->[1] =~ /^[\d.]+$/){ + $result->working_revision($match->[1]); + $result->date($match->[2]); + } + } ); $main->push_handler ( - qr/^\s+Repository revision:\s+([\d\.]+|No revision control file)/, sub + qr/^\s+Repository revision:\s+([\d\.]+|No revision control file)\s*(.*)$/, sub { - my($match) = @_; - $result->repository_revision($match->[1]) if $match->[1] =~ /^[\d.]+$/; + my($match) = @_; + if ($match->[1] =~ /^[\d.]+$/){ + $result->repository_revision($match->[1]) ; + $result->repository_file($match->[2]); + } } ); $main->push_handler diff -Naur Cvs-0.06/lib/Cvs/Result/StatusItem.pm Cvs-0.06.01/lib/Cvs/Result/StatusItem.pm --- Cvs-0.06/lib/Cvs/Result/StatusItem.pm 2003-01-21 09:18:42.000000000 -0800 +++ Cvs-0.06.01/lib/Cvs/Result/StatusItem.pm 2004-05-21 14:08:13.000000000 -0700 @@ -15,6 +15,8 @@ =head1 FIELDS + All fields are parsed out of the output from `cvs status' command. + =head2 exists Returns a boolean value regarding on the file existence. @@ -23,9 +25,20 @@ Returns the item's filename. +=head2 date + +Returns the date, as listed in the 'Working Revision' line +of `cvs status' + =head2 basedir -Returns the item's basedir. +Returns the item's working directory, see 'repository_file' for where +the file lives in the repository + +=head2 repository_file + +Returns the fully qualified repository file, as listed in +the 'Repository revision' line of `cvs status' =head2 status @@ -58,6 +71,8 @@ exists filename basedir + repository_file + date status working_revision repository_revision