# This module contains all code for checking API versions for the # VSS to Perforce converter. # # $Id: //public/perforce/utils/vsstop4/main/convert.pm#16 $ # require 5.0; package utils; # This package use Exporter; use vars qw(@ISA @EXPORT); use convert; @ISA = qw(Exporter); @EXPORT = qw(p4api p4exec p4errors_get p4errors_print log_ss_version); # Checks sub p4api { my $version_reqd = "3.5313"; my $usage = "\nP4Perl module (P4) is required for the converter to run. Install P4Perl from http://public.perforce.com//guest/tony_smith/perforce/API/Perl/index.html. Please use version $version_reqd (other versions not tested and unlikely to work). Just double-click on Windows installer and run it (no real need to download and save). E.g.: http://public.perforce.com/guest/tony_smith/perforce/API/Perl/released/p4perl56-setup-$version_reqd.exe or http://public.perforce.com/guest/tony_smith/perforce/API/Perl/released/p4perl58-setup-$version_reqd.exe as appropriate. \n"; # Check that P4 Module is installed eval{require P4; import P4;}; if ($@) { print $usage; exit(1); } if ($P4::VERSION !~ /\s*$version_reqd\s*$/) { print $usage; print "****** Wrong P4Perl version installed - $P4::VERSION is what you have - please install $version_reqd! "; exit(1); } my $p4 = new P4; return $p4; } sub p4exec { my ($p4, $cmd, $errorexit) = @_; $errorexit = 0 if (!defined($errorexit)); my @result = $p4->Run(split(' ', $cmd)); my $result = join("\n", @result); p4errors_print($p4, $cmd, $errorexit); return $result; } sub p4errors_print { my ($p4, $msg, $errorexit) = @_; $errorexit = 0 if (!defined($errorexit)); if ($p4->ErrorCount()) { my $output = "**p4errors - $msg:\n"; print $output; convert::log($output); foreach my $e ($p4->Errors()){ print "$e\n" if $errorexit;; convert::log("$e\n"); } exit(4) if $errorexit; } } sub p4errors_get { my @result; if ($p4->ErrorCount()) { foreach my $e ($p4->Errors()){ push @result, "$e\n"; } } return join("\n", @result); } sub log_ss_version { my $output = convert::run("ss about $convert::ss_options"); convert::log($output); } 1;
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 5974 | Ashish Melanta | Pulling in the Perforce utils into my guest branch | ||
//guest/perforce_software/utils/vsstop4/2006-06-special-chars/utils.pm | |||||
#2 | 5683 | Robert Cowham | Merge main stuff in. | ||
#1 | 5653 | Robert Cowham | Merge changes from Main | ||
//guest/perforce_software/utils/vsstop4/main/utils.pm | |||||
#1 | 5652 | Robert Cowham |
- Add more troubleshooting help to readme.html. - Update to use P4Perl 3.5313 - Added new module utils.pm to detect and fail if wrong P4Perl version used. |