0

有什么方法可以找出 CVS 中是否存在 partiualr 文件?我不想检查该文件,只想通过 Perl 查看该文件是否存在。

4

1 回答 1

1

You can use cvs status command to check. Either

  1. call that directly via a system call

    my @output = `cvs status $filename`;
    

    you can either heuristically grep the resulting text for ",v" string (that always is the suffix for CVS repository file), or actually parse the output looking for "Repository revision:" line

       MISSING: Repository revision: No revision control file
       PRESENT: Repository revision: 10.41   /u1/cvs/dev/myscript.pl,v
    
  2. or use Cvs module:

    use Cvs; 
    my $cvs = new Cvs("/u1/cvs", cvsroot => $ENV{CVSROOT}, password =>"*****") 
        or die $Cvs::ERROR; 
    my $status = $cvs->status("CVS_file"); 
    print $status->status() . "\n";
    
    ====> Needs Checkout
    
    my $status = $cvs->status("bogus_file"); 
    print $status->status() . "\n";
    
    ====> Unknown
    
于 2012-08-09T16:46:27.173 回答