brian42miller has asked for the wisdom of the Perl Monks concerning the following question:

Hello All,

I am having difficulty getting the Cvs module to work and I assume that it is due to my ineptitude. Are there any examples of how to use this module?

Here is the code that I am having difficulty with, maybe it is some simple that I am missing and if someone could point it out I would be grateful!

I am assuming that the 'working' directory option is where the working copy of the repository has been previously checked out to.

The cvsroot value is the same as what is in the checked out CVS/Root file.

I have added a '\' before the @ however that does not seem to make a difference.

There already exists a checked out version of the common/scripts/release/regress.pl file.

Thanks

Brian Miller

-----------------------------------------------------------------------------------------

use strict; use Cvs; my $cvs = Cvs->new('workdir' => '/projects/millerb/SR/vhdl' ,'cvsroot'=>':pserver:millerb@172.20.175.10:/hwcvs' ,'password' => '********' ) or die $Cvs::ERROR; print "CVS ERROR ($Cvs::ERROR)\n"; print "CVS OBJ $cvs\n"; print "-----GETTING STATUS----\n"; my $status_obj = $cvs->status('common/scripts/release/regress.pl'); print "-----COMPLETED STATUS----\n"; print "status_obj $status_obj\n"; my $status = $status_obj->status(); print "$status_obj Status $status\n";
-----------------------------------------------------------------------------------

Results

-----------------------------------------------------------------------------------

millerite:release$ perl cvs_test.pl CVS ERROR () CVS OBJ Cvs=HASH(0x1490d78) -----GETTING STATUS---- -----COMPLETED STATUS---- status_obj Cvs::Result::Base=HASH(0x176d010) Can't locate object method "status" via package "Cvs::Result::Base" at + cvs_test.pl line 61. millerite:release$

Replies are listed 'Best First'.
Re: CVS Module examples
by wjw (Priest) on Nov 17, 2014 at 23:34 UTC

    The docs on Cvs actually show the usage pretty clearly. I think that you are not seeing that the return of your $cvs is an object, not a scalar value.

    Try using Dumper to output $cvs, then I suspect your understanding of what $cvs actually is will help you solve your problem.

    ...the majority is always wrong, and always the last to know about it...

    Insanity: Doing the same thing over and over again and expecting different results...

    A solution is nothing more than a clearly stated problem...otherwise, the problem is not a problem, it is simply an inconvenient fact

      I did get, from the cpan documentation, that the result from the $cvs->status command was an object, but the returned object was of type Cvs::Result::Base which does not have the method status.

      However using Dumper (good advice, thanks) I noticed that the 'pwd' field in the cvs object was not pointing to where the checked out view was, so I changed the code from

      my $cvs = Cvs->new('workdir' => '/projects/millerb/SR/vhdl' ,'cvsroot'=>':pserver:millerb@172.20.175.10:/hwcvs' ,'password' => '********' ) or die $Cvs::ERROR; TO my $cvs = Cvs->new('/projects/millerb/SR/vhdl' ,'cvsroot'=>':pserver:millerb@172.20.175.10:/hwcvs' ) or die $Cvs::ERROR;
      Which seems to have resolved the issue. Thanks Brian
      Is there a reason why the Cvs or Cvs::Simple module does not have a log method? (Cvs documentation has something but it doesn't seem to work).

      I wanted to use the Cvs module because I believe that it uses IPC to communicate with the pserver. I figured that would be more efficient than using my own system('cvs....') commands. Does that sound reasonable?

      Brian

        Is there a reason why the Cvs or Cvs::Simple module does not have a log method?
        This problem was reported 9 years ago, and there have been no updates: https://rt.cpan.org/Public/Bug/Display.html?id=15831

        I'd say support for this module (Cvs) has been abandoned by the author. If you want that functionality, you'll probably need to implement it yourself.

        Regarding the other module, Cvs::Simple, by a different author, you could try to contact the author for support.

        This is a darn good question! The link to Cvs::Result::Log goes nowhere on CPAN, and there does not seem to be any reference to why the link is there but it's target is not.

        I am not familiar with the guts of the Cvs module. I used it for a while a long time ago before I switched to git.

        I am sorry that I don't have anything more to offer....

        ...the majority is always wrong, and always the last to know about it...

        Insanity: Doing the same thing over and over again and expecting different results...

        A solution is nothing more than a clearly stated problem...otherwise, the problem is not a problem, it is simply an inconvenient fact