# Copyright (c) 1997-2007, Perforce Software, Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE SOFTWARE, INC. BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package P4; use strict; require Exporter; require DynaLoader; use AutoLoader; use vars qw( $VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD ); @ISA = qw(Exporter DynaLoader); @EXPORT_OK = qw( ); @EXPORT = qw(); $VERSION = qq( 3.6001 ); bootstrap P4 $VERSION; # # Our taint checking requires Scalar::Util, which isn't included as # standard in Perl 5.6. Thus, we'll use it if it's available, and ignore # taint checking if we don't. # our $HAVE_TAINTED = 0; eval { local $SIG{ '__DIE__' }; require Scalar::Util; import Scalar::Util qw( tainted ); $HAVE_TAINTED = 1; }; # # Execute a command. The return value depends on the context of the call. # # Returns an array of results if the caller's asked for one # Returns undef if result set is empty # Returns a scalar result in scalar context if only one result exists. # Returns an array ref in scalar context if more than one result exists. # sub Run { my $self = shift; # Check for tainted data if in taint mode if( $HAVE_TAINTED ) { foreach my $arg ( @_ ) { if( tainted( $arg ) ) { die( "Can't pass tainted arguments to Perforce commands!"); } } } my $results = $self->_Run( @_ ); return @$results if( wantarray ); return undef if( scalar( @$results ) == 0 ); return $$results[ 0 ] if( scalar( @$results ) == 1 ); return $results; } # Change the current working directory. Returns undef on failure. sub SetCwd { my $self = shift; my $cwd = shift; # First we chdir to the dir if it exists. If successful, then we # update the PWD environment variable (if defined) and call the # API equivalent function, now named _SetCwd() return undef unless chdir( $cwd ); $ENV{ "PWD" } = $cwd if ( defined( $ENV{ "PWD" } ) ); $self->_SetCwd( $cwd ); return $cwd; } # # Run 'p4 login' using the password supplied by the user # sub Login() { my $self = shift; $self->SetInput( $self->GetPassword() ); return $self->Run( "login" ); } # # Run 'p4 passwd' to change the password # sub Password( $$ ) { my $self = shift; my $oldpass = shift; my $newpass = shift; my $args = [ $oldpass, $newpass, $newpass ]; $self->SetInput( $args ); return $self->Run( "password" ); } #******************************************************************************* #* Useful shortcut methods to make common actions easier to code. Nothing #* here that can't be done using the already defined methods. #******************************************************************************* # SubmitSpec - "p4 submit -i" # # Submit a changelist using supplied spec. Spec can be in string form, # or a hash containing the required form elements and a specdef member # telling the API how to create the form. # # Synopsis: $p4->SubmitSpec( $spec ); sub SubmitSpec( $ ) { my $self = shift; $self->SetInput( shift ); $self->Submit( "-i" ); } #******************************************************************************* #* Compatibility-ville. #******************************************************************************* sub Tag() { my $self = shift; $self->Tagged(); } # Makes the Perforce commands usable as methods on the object for # cleaner syntax. If it's not a valid method, you'll find out when # Perforce recommends you read the help. # # Also implements Fetch/Save methods for common Perforce commands. e.g. # # $label = $p4->FetchLabel( "labelname" ); # $change = $p4->FetchChange( [ changeno ] ); # # $p4->SaveChange( $change ); # $p4->SaveUser( $p4->GetUser( "username" ) ); # # Use with care as it's not too clever. SaveSubmit is perfectly valid as # far as this code is concerned, but it doesn't do much! # sub AUTOLOAD { my $self = shift; my $cmd; ($cmd = $AUTOLOAD ) =~ s/.*:://; $cmd = lc $cmd; if ( $cmd =~ /^save(\w+)/i ) { die( "save$1 requires an argument!" ) if ( ! scalar( @_ ) ); $self->SetInput( shift ); return $self->Run( $1, "-i", @_ ); } elsif ( $cmd =~ /^fetch(\w+)/i ) { return $self->Run( $1, "-o", @_ ); } elsif ( $cmd =~ /^parse(\w+)/i ) { die( "parse$1 requires an argument!" ) if ( ! scalar( @_ ) ); return $self->ParseSpec( $1, $_[0] ); } elsif ( $cmd =~ /^format(\w+)/i ) { die( "format$1 requires an argument!" ) if ( ! scalar( @_ ) ); return $self->FormatSpec( $1, $_[0] ); } return $self->Run( $cmd, @_ ); } #******************************************************************************* # Compatibility-ville. #******************************************************************************* sub Final { my $self = shift; $self->Disconnect(); } sub Init { my $self = shift; $self->Connect(); } 1; __END__ =head1 NAME P4 - OO interface to the Perforce SCM System. =head1 SYNOPSIS use P4; my $p4 = new P4; $p4->SetClient( $clientname ); $p4->SetPort ( $p4port ); $p4->SetPassword( $p4password ); $p4->Connect() or die( "Failed to connect to Perforce Server" ); my $info = $p4->Run( "info" ); $p4->Edit( "file.txt" ) or die( "Failed to edit file.txt" ); $p4->Disconnect(); =head1 DESCRIPTION This module provides an OO interface to the Perforce SCM system that is designed to be intuitive to Perl users. Data is returned in Perl arrays and hashes and input can also be supplied in these formats. Each P4 object represents a connection to the Perforce Server, and multiple commands may be executed (serially) over a single connection. =head1 BASE METHODS =over 4 =item P4::new() Construct a new P4 object. e.g. my $p4 = new P4; =item P4::Identify() Print build information including P4Perl version and Perforce API version. print P4::Identify(); =item P4::Connect() Initializes the Perforce client and connects to the server. Returns false on failure and true on success. =item P4::DebugLevel( [ level ] ) Gets and optionally sets the debug level. Without an argument, it just returns the current debug level. With an argument, it first updates the debug level and then returns the new value. For example: $client->DebugLevel( 1 ); $client->DebugLevel( 0 ); print( "Debug level = ", $client->DebugLevel(), "\n" ); =item P4::Dropped() Returns true if the TCP/IP connection between client and server has been dropped. =item P4::ErrorCount() Returns the number of errors encountered during execution of the last command =item P4::Errors() Returns a list of the error messages received during execution of the last command. =item P4::FormatSpec( type, string ) Converts a Perforce form of the specified type (client/label etc.) held in the supplied hash into its string representation. Note that shortcut methods are available that obviate the need to supply the type argument. The following two examples are equivalent: my $client = $p4->FormatSpec( "client", $hash ); my $client = $p4->FormatClient( $hash ); See the section on SHORTCUT METHODS below for more information on the abbreviated forms. =item P4::Disconnect() Terminate the connection and clean up. Should be called before exiting. =item P4::GetCharset() Return the name of the current charset in use. Applicable only when used with Perforce servers running in unicode mode. =item P4::GetClient() Returns the current Perforce client name. This may have previously been set by SetClient(), or may be taken from the environment or P4CONFIG file if any. If all that fails, it will be your hostname. =item P4::GetCwd() Returns the current working directory as your Perforce client sees it. =item P4::GetHost() Returns the client hostname. Defaults to your hostname, but can be overridden with SetHost() =item P4::GetPassword() Returns your Perforce password. Taken from a previous call to SetPassword() or extracted from the environment ( $ENV{P4PASSWD} ), or a P4CONFIG file. =item P4::GetPort() Returns the current address for your Perforce server. Taken from a previous call to SetPort(), or from $ENV{P4PORT} or a P4CONFIG file. =item P4::IsParseForms() Returns true if ParseForms mode is enabled on this client. =item P4::IsTagged() Returns true if Tagged mode is enabled on this client. =item P4::MergeErrors( [0|1] ) For backwards compatibility. In previous versions of P4Perl, errors and warnings were mixed in the same 'Errors' array. This made it tricky for users to ignore warnings, but still look out for errors. This release of P4Perl stores them in two separate arrays. You can get the list of errors, but calling P4::Errors(), and the list of warnings by calling P4::Warnings(). If you want to revert to the old behaviour, you can call this method to revert to the old behaviour and all warnings will go into the error array. i.e. $p4->MergeErrors( 1 ); $p4->Sync(); $p4->MergeErrors( 0 ); =item P4::ParseForms() Request that forms returned by commands such as C<$p4-E<gt>GetChange()>, or C<$p4-E<gt>Client( "-o" )> be parsed and returned as a hash reference for easy manipulation. Must be called prior to calling C<Connect()>. =item P4::ParseSpec( type, string ) Converts a Perforce form of the specified type (client/label etc.) held in the supplied string into a hash and returns a reference to that hash. Note that shortcut methods are available to avoid the need to supply the type argument. The following two examples are equivalent: my $hash = $p4->ParseSpec( "client", $clientspec ); my $hash = $p4->ParseClient( $clientspec ); See the section on SHORTCUT METHODS below for more information on the abbreviated forms. =item P4::Password( $oldpass, $newpass ) Run a C<p4 password> command to change the user's password from $oldpass to $newpass. Not to be confused with P4::SetPassword. =item P4::Run( cmd, [$arg...] ) Run a Perforce command returning the results. Since Perforce commands can partially succeed and partially fail, you should check for errors using C<P4::ErrorCount()>. Results are returned as follows: An array of results in array context. undef in scalar context if result set is empty. A scalar result in scalar context if only one result exists. An array ref in scalar context if more than one result exists. This means you can get the result format you want by correct use of Perl context. For example, if you always want an array, use array context: @results = $p4->Run( "sync" ); Through the magic of the AutoLoader, you can also treat the Perforce commands as methods, so: $p4->Edit( "filename.txt ); is equivalent to $p4->Run( "edit", "filename.txt" ); Note that the format of the scalar or array results you get depends on (a) whether you're using tagged (or form parsing) mode (b) the command you've executed (c) the arguments you supplied and (d) your Perforce server version. In tagged or form parsing mode, ideally each result element will be a hashref, but this is dependent on the command you ran and your server version. In non-tagged mode (the default), each result element will be a string. In this case, also note that as the Perforce server sometimes asks the client to write a blank line between result elements, some of these result elements can be empty. Mostly you will want to use form parsing (and hence tagged) mode. See ParseForms(). Note that the return values of individual Perforce commands are not documented because they may vary between server releases. If you want to be correlate the results returned by the P4 interface with those sent to the command line client try running your command with RPC tracing enabled. For example: Tagged mode: p4 -Ztag -vrpc=1 describe -s 4321 Non-Tagged mode: p4 -vrpc=1 describe -s 4321 Pay attention to the calls to client-FstatInfo(), client-OutputText(), client-OutputData() and client-HandleError(). I<Each call to one of these functions results in either a result element, or an error element.> =item P4::ServerLevel() Returns an integer specifying the server protocol level. This is not the same as, but is closely aligned to, the server version. To find out your server's protocol level run 'p4 -vrpc=5 info' and look for the server2 protocol variable in the output. Must be called after running a command. =item P4::SetApiLevel( integer ) Specify the API compatibility level to use for this script. This is useful when you want your script to continue to work on newer server versions, even if the new server adds tagged output to previously unsupported commands. The additional tagged output support can change the server's output, and confound your scripts. Setting the API level to a specific value allows you to lock the output to an older format, thus increasing the compatibility of your script. Must be called before calling P4::Connect(). e.g. $p4->SetApiLevel( 57 ); # Lock to 2005.1 format $p4->Connect() or die( "Failed to connect to Perforce" ); etc. =item P4::SetCharset( $charset ) Specify the character set to use for local files when used with a Perforce server running in unicode mode. Do not use UNLESS your Perforce server is in unicode mode. Must be called before calling P4::Connect(). e.g. $p4->SetCharset( "winansi" ); $p4->SetCharset( "iso8859-1" ); $p4->SetCharset( "utf8" ); etc. =item P4::SetClient( $client ) Sets the name of your Perforce client. If you don't call this method, then the clientname will default according to the normal Perforce conventions. i.e. 1. Value from file specified by P4CONFIG 2. Value from $ENV{P4CLIENT} 3. Hostname =item P4::SetCwd( $path ) Sets the current working directory for the client. This should be called after the Connect() and before the Run(). =item P4::SetHost( $hostname ) Sets the name of the client host - overriding the actual hostname. This is equivalent to 'p4 -H <hostname>', and really only useful when you want to run commands as if you were on another machine. If you don't know when or why you might want to do that, then don't do it. =item P4::SetInput( arg ) Save the supplied argument as input to be supplied to a subsequent command. The input may be: a hashref, a scalar string or an array of hashrefs or scalar strings. Note that if you pass an array the array will be shifted once each time the Perforce command being executed asks for user input. =item P4::SetMaxResults( value ) Limit the number of results for subsequent commands to the value specified. Perforce will abort the command if continuing would produce more than this number of results. Note that once set, this limit remains in force. You can remove the restriction by setting it to a value of 0. =item P4::SetMaxScanRows( value ) Limit the number of records Perforce will scan when processing subsequent commands to the value specified. Perforce will abort the command once this number of records has been scanned. Note that once set, this limit remains in force. You can remove the restriction by setting it to a value of 0. =item P4::SetPassword( $password ) Specify the password to use when authenticating this user against the Perforce Server - overrides all defaults. Not to be confused with P4::Password(). =item P4::SetPort( [$host:]$port ) Set the port on which your Perforce server is listening. Defaults to: 1. Value from file specified by P4CONFIG 2. Value from $ENV{P4PORT} 3. perforce:1666 =item P4::SetProg( $program_name ) Set the name of your script. This value is displayed in the server log on 2004.2 or later servers. =item P4::SetProtocol( $protflag, $value ) Set protocol options for this session. Deprecated. Use C<Tagged()> or C<ParseForms()> instead. For example: $p4->SetProtocol(tag,''); $p4->Connect(); my @f = $p4->Fstat( "filename" ); my $c = $f[ 0 ]->{ 'clientFile' }; =item P4::SetUser( $username ) Set your Perforce username. Defaults to: 1. Value from file specified by P4CONFIG 2. Value from C<$ENV{P4USER}> 3. OS username =item P4::Tag() Deprecated in favour of C<Tagged> (same functionality). =item P4::Tagged() Responses from commands that support tagged output will be returned in the form of a hashref rather than plain text. Must be called prior to calling C<Connect()>. =item P4::WarningCount() Returns the number of warnings issued by the last command. $p4->WarningCount(); =item P4::Warnings() Returns a list of warnings from the last command $p4->Warnings(); =back =head1 SHORTCUT METHODS The following methods are simply wrappers around the base methods designed to make common actions easy to code. =over 4 =item P4::Fetch<cmd>() Shorthand for running C<$p4-E<gt>Run( "cmd", "-o" )> and returning the results. e.g. $label = $p4->FetchLabel( $labelname ); $change = $p4->FetchChange( $changeno ); $clientspec = $p4->FetchClient( $clientname ); =item P4::Format<spec type>( hash ) Shorthand for running C<$p4->FormatSpec( <spec type>, hash )> and returning the results. e.g. $change = $p4->FetchChange(); $change->{ 'Description' } = 'Some description'; $form = $p4->FormatChange( $change ); printf( "Submitting this change:\n\n%s\n", $form ); $p4->SubmitSpec( $change ); =item P4::Parse<spec type>( buffer ) Shorthand for running C<$p4->ParseSpec( <spec type>, buffer )> and returning the results. e.g. $p4 = new P4; $p4->ParseForms(); $p4->Connect() or die( "Failed to connect to server" ); $client = $p4->FetchClient(); # Returns a hashref $client = $p4->FormatClient( $client ); # Convert to string $client = $p4->ParseClient( $client ); # Convert back to hashref Note that the above example is pointless, but occasionally it's useful to be able to convert specs from hashrefs to strings and back again. =item P4::Save<cmd>() Shorthand for: $p4->SetInput( $spec ); $p4->Run( "cmd", "-i"); e.g. $p4->SaveLabel( $label ); $p4->SaveChange( $changeno ); $p4->SaveClient( $clientspec ); =item P4::SubmitSpec() Submits a changelist using the supplied change specification. Really a shorthand for SetInput() and Run( "submit", "-i" ). For example: $change = $p4->FetchChange(); $change->{ "Description" } = "some text..."; $p4->SubmitSpec( $change ); =back =head1 COMPATIBILITY WITH PREVIOUS VERSIONS This version of P4 is largely backwards compatible with previous versions with the following exceptions: 1. Errors and warnings are now saved in separate arrays by default. The previous behaviour can be reinstated for those with compatibility requirements by calling $p4->MergeErrors( 1 ); Splitting errors and warnings into separate arrays makes it easier to ignore warnings and only have to deal with real errors. 2. The DoPerlDiffs() method in previous versions is no longer defined. It was a legacy from an earlier release and was superceded in more recent versions. Users who still depend on that functionality should use a 1.x build of P4. Similarly, the corresponding DoP4Diffs() method is also removed. It was likely not used and is not necessary anyway. =head1 LICENCE Copyright (c) 1997-2007, Perforce Software, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE SOFTWARE, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =head1 AUTHOR Tony Smith, Perforce Software ( tony@perforce.com or tony@smee.org ) =head1 SEE ALSO perl(1), Perforce API documentation. =cut
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#42 | 6001 | Tony Smith |
Rework change 5787 in which support for taint checking of arguments passed to P4::Run() was introduced. It turns out Scalar::Util, on which this is based isn't distributed with Perl 5.6, so we can't rely on it. This change simply disables the taint checking for Perl 5.6 (no-one's using it because it only ever worked for Perl 5.8 users). |
||
#41 | 5943 | Tony Smith |
Update P4Perl to build against 2007.2 API. The 2007.2 API has a more traditional directory structure and P4Perl needs to take that into account. This change also makes Makefile.PL check that the version of the API being used is less than or equal to the highest API version known when this version was written. Hopefully this will prevent people from struggling to build older (stable) versions of P4Perl against recent APIs only supported by the development builds. |
||
#40 | 5941 | Tony Smith |
Documentation updates. Thanks to Steve Vance for pointing out some of the shortcomings. |
||
#39 | 5869 | Tony Smith |
Fix memory leaks. Thanks to John LoVerso and Sandy Currier for tracking these down and sending me the patch. |
||
#38 | 5868 | Tony Smith |
Port P4Perl to Perl 5.8.8. This change is spectacularly ugly, but then so are the innards of Perl. See the long thread at: http://www.nntp.perl.org/group/perl.perl5.porters/2006/06/msg114383.html for details of the problem, and some discussion of solutions. I've had to come up with a solution that doesn't involve patching people's Perl installations, so my fix is even less easy on the eye but it appears to work, and hopefully hasn't broken things for older Perl versions. |
||
#37 | 5787 | Tony Smith |
Update P4Perl to build against the 2006.2 API, and detect (and reject) the passing of tainted data to P4::Run() as a security measure. |
||
#36 | 5708 | Tony Smith |
Add static P4::Identify() method to report the version of P4Perl, and the API used to build it. |
||
#35 | 5704 | Tony Smith |
Fix bug introduced in change 5677: the quoting of the const_char definition wasn't good on Windows as it doesn't really understand single quotes. Switched to using double-quotes. |
||
#34 | 5692 | Tony Smith |
Add support for $p4->ServerLevel() which returns the server's 'server2' protocol level. This is not the same as, but is closely aligned to, the server version and can be used to test for feature availability. If you need explicit Perforce version strings, run 'p4 info' in tagged mode and parse the 'serverVersion' string. New feature requested by Robert Cowham. |
||
#33 | 5677 | Tony Smith |
Rework P4Perl build script to support 2006.1 API. There were some sweeping changes in the 2006.1 API which did away with the old const_char definition. Unfortunately, since P4Perl has to build with older APIs, I can't quite do the same. This change tweaks the way that Makefile.PL determines the definition for const_char so that (a) it's always 'const char' when a 2006.1 or later API is used, (b) it uses the platform specific hint for older APIs (c) it falls back on 'char' in the absence of a hint. In an ideal world, we'd be able to compute the options based on (a) OS, (b) compiler version (c) Perl version and (d) API version, but that's tough to get right. No functional change. |
||
#32 | 5624 | Tony Smith | Add hints file for Mac OS X from Tim Bunce (thanks Tim!). | ||
#31 | 5592 | Tony Smith |
Bug fix: We were erroneously making a Perl scalar mortal (which causes its reference count to be decremented when it goes out of scope) when receiving binary data from the server. Decrementing the reference count to early meant the scalar was being cleaned up when it was in fact still in use. This change simply removes the sv_2mortal() call. Thanks to Mike Hall at National Instruments for finding this one. |
||
#30 | 5564 | Tony Smith |
Fix memory leaks when dealing with tagged output with array members. One of these days I'll get the hang of Perl's pesky reference counting mechanism... These leaks would have been most noticable with 'p4 filelog' (and that's where they were reported), but in fact any command that returned tagged output with array members would have leaked. |
||
#29 | 5396 | Tony Smith |
x86_64 porting changes. Use INT2PTR and PTR2INT to handle the stashing of the PerlClientApi pointer in a Perl scalar. This is necessary because, despite all documentation to the contrary, an I32 is not 64-bit capable on all 64-bit machines. Also, the hints file now looks for x86_64 in the architecture name and if it finds it, then const_char='const char' rather than the default of 'char'. |
||
#28 | 5313 | Tony Smith |
Add new SetApiLevel() method to allow users to lock scripts to a particular API level. This helps when upgrading to new servers that extend support for tagged output to hitherto unsupported commands (2005.2 did a lot of that). See the C/C++ API Release Notes for the full details, but by way of example, to lock scripts to the 2005.1 interface use: $p4->SetApiLevel( 57 ); |
||
#27 | 5259 | Tony Smith |
Update P4Perl for 2005.2 API changes. The 2005.2 API supplies forms ready-parsed to the client when used in tagged mode. This is fine for P4Perl, except that we were not caching the specdef if no parsing was required and that meant that although forms could be converted to hashes, the reverse direction was broken. This change makes sure that we cache the specdef whenever it's available. |
||
#26 | 5073 | Tony Smith |
Yet another P4::SetProg fix. Turns out the last change fixed everything except the build script and it all worked... unless you used the 2005.1 API which has a different format for the Version file. P4::SetProg is a no-op when P4Perl is built with an older API so not identifying the API build properly breaks it thoroughly. This change adapts P4Perl's setup script to support both pre-2005.1 and 2005.1 formats, and gives the user the chance to enter the API version manually if it can't be automatically determined. Installers also included in this change |
||
#25 | 5067 | Tony Smith |
Bug fix: P4::SetProg() interface method was missing so SetProg wasn't working too well! |
||
#24 | 5038 | Tony Smith |
Bug fix: Fix memory leaks in P4Perl reported by Craig Galley. Perl's reference count garbage collection is not much fun to work with, but hopefully this change plugs P4Perl's leaks. There's still a leak that remains, but whether it's in P4Perl's code or just in Perl I don't know. A loop like this: while( 1 ) { my $p4 = new P4; } will leak like a sieve but I'm pretty sure P4Perl is cleaning up as it should. While it's very difficult to be certain with Perl's memory mode, creating one P4 object and using it multiple times now appears to be pretty steady. Also fixed use of uninitialized debug variable which could produce debug output you hadn't asked for. |
||
#23 | 5035 | Tony Smith |
Bug fix: call ClientApi::SetProg() before every command instead of just once as this value is not retained by the Perforce API. |
||
#22 | 4987 | Tony Smith |
Bug fix for tagged mode output from 'p4 diff2'. Diff2 is one of the few (only?) commands to use variables of the form 'var' and 'var2' rather than 'var1' and 'var2'. Normally, if there's no numeric suffix to a variable, P4Perl can assume it's looking at the only instance of that variable in the output. In the case of 'p4 diff2', that's not true. This change enables P4Perl to adapt to this change of circumstances and convert a previously scalar member of the hash result into an array member. |
||
#21 | 4873 | Tony Smith |
Bug fix: fix typos in test harness that were causing the tests to fail. |
||
#20 | 4864 | Tony Smith |
Bug fix: Introduce workaround for obscure 2000.1/2000.2 protocol bug that I really thought we'd seen the last of. Along the way, a total revamp of the debugging output - required to diagnose the problem. |
||
#19 | 4856 | Tony Smith |
Rework P4::Errors() and P4::Warnings() so that they return a list rather than an array. Perl seems to like this more and it's easy to assign the list to an array should you wish to do so. Note that this may cause some backwards-compatibility issues. |
||
#18 | 4831 | Tony Smith |
Change implementation of P4 class from being a blessed reference to an integer (pointer) to a blessed reference to a hash. The pointer is now stashed in a member of the hash. This makes it easier for those that want to to subclass the P4 class and bolt on their own functionality. No functional change. |
||
#17 | 4804 | Tony Smith |
Add support for P4::SetMaxResults() and P4::SetMaxScanRows() which specify the desired limits for an instance of the P4 class. Note that the limits remain in force until disabled by setting them to zero. |
||
#16 | 4754 | Tony Smith |
Add support for passing multiple items of input to Perforce commands that need them. The prime example is 'p4 password' which prompts the user three times for password input (old password, new password and new password again). Also add a P4::Password( $old, $new ) method to make it nice and easy to use. |
||
#15 | 4698 | Tony Smith |
Bug fix. Correct client initialization so that it no longer causes problems if the connection to the server fails for some reason. Also corrected the number of tests in the test harness. |
||
#14 | 4676 | Tony Smith |
Enable P4Perl to work against a server in unicode mode. This change adds two new methods to the P4 class: SetCharset() and GetCharset() which have the expected behaviour. Thanks to Raymond Danks <raymond.danks@amd.com>. Also cleaned up the test harness a little. |
||
#13 | 4667 | Tony Smith |
Caught by the old "hadn't saved my changes" problem, so the Changes file in the last submission was incomplete. Bumping the version number to retry... |
||
#12 | 4666 | Tony Smith |
New ParseSpec() and FormatSpec() methods allow you to convert specs between hash and string representations easily. Shortcut methods Parse* and Format* are also defined. (i.e. FormatClient() and ParseLabel() etc.) New methods IsTagged() and IsParseForms() tell you if your client is in tagged/form parsing mode respectively. If you care. P4::Tag() is deprecated in favour of P4::Tagged(). P4::Tag() exists for backwards compatibility |
||
#11 | 4608 | Tony Smith |
Bug fix: The SetInput() method was omitted in the big rewrite so quite a lot was broken in builds 3.4579 and later. This change fixes that omission, and adds support for 'p4 login' too (that was how I discovered that SetInput() was missing). |
||
#10 | 4586 | Tony Smith |
Update P4Perl tarball with most recent change. No need for a new installer as there's no functional change. |
||
#9 | 4582 | Tony Smith |
Port new P4Perl architecture to Windows. Fixes a few porting issues and a couple of minor errors in the previous change. |
||
#8 | 4579 | Tony Smith |
Rewrite P4Perl to be more like P4Ruby. This change does away with the old P4/P4::Client split and pulls all the functionality of P4::Client into P4. Hence P4::Client is now deprecated. There are a few gotcha's - see the Changes file, and documentation for the details, but in general it's backwards compatible. As part of this change, I'm also releasing the previous current versions of P4 and P4::Client as released versions - for posterity. P4 now gets a v3.x version number so the old versions will stand out clearly. Hopefully it's all working - works fine for me - but people should consider this a beta build, for now at least. |
||
#7 | 4158 | Tony Smith |
Copyright notice updates. No functional change. |
||
#6 | 3550 | Tony Smith |
Add OutputBinary() support to P4Perl. This allows "p4 print" to work with clients that do not use "local" line endings amongst other things. |
||
#5 | 3537 | Tony Smith |
Documentation update. Added docs for P4::SubmitSpec() and P4::SetInput() which were missing from previous releases |
||
#4 | 2587 | Tony Smith |
Add documentation for P4::Errors() and P4::ErrorCount() which should have been there in the first place |
||
#3 | 2003 | Tony Smith |
MakeMaker tweaks to cheer up the CPAN folks. Just guessing with the PPD file, but it's better than nothing (I'm told). |
||
#2 | 1733 | Tony Smith | Documentation update for P4 Perl module. | ||
#1 | 1011 | Tony Smith |
Moved Perl API stuff one level down to make way for upcoming Ruby interface. |
||
//guest/tony_smith/perforce/API/P4/P4.pm | |||||
#8 | 982 | Tony Smith |
A couple of minor fixes. test.pl was choking on test 6 as ParseForms had not been called, and Run() now correctly returns an empty list in array context rather than returning undef which was confusing. |
||
#7 | 967 | Tony Smith | Online doc update | ||
#6 | 961 | Tony Smith | Current build of P4 - version 0.961 | ||
#5 | 960 | Tony Smith |
Misc changes. Added an example.pl file with sample code. Also Added the PPD file to the manifest (duh!). P4::Run() now returns an array reference instead of a formatted string when used in scalar context where more than one result is returned. Also renamed the shortcut GetXXX and SetXXX methods to be FetchXXX and SaveXXX because GetClient() and SetClient() we already defined by P4::Client. |
||
#4 | 931 | Tony Smith | Latest (931) builds of P4::Client and P4 | ||
#3 | 929 | Tony Smith |
Add support for form parsing to Perl API. Allows Perforce specs (change, client, user etc.) to be parsed by the API and returned as Perl hashes rather than strings which must be parsed by the user. P4 module also has some new methods which make it easy to use this feature. Sample code: ------------------- use P4; my $p4 = new P4; $p4->ParseForms(); $p4->Init() or die( "Can't connect to Perforce" ); $p4->Edit( "filename" ); my $change = p4->GetChange(); $change->{ 'Description' } = "Some text"; $p4->SubmitSpec( $change ); print( $p4->ErrorCount() ? "Submit failed\n" : "Submit OK\n" ); ------------------- |
||
#2 | 925 | Tony Smith | Version number for P4.pm to 0.925 | ||
#1 | 922 | Tony Smith |
First crack at a much simpler perl interface. Just wraps up the P4::Client and P4::UI classes in an easier to use interface returning the output to the caller in Array or Scalar context as they request it. |