man VCP::Utils::p4 () - utilities for dealing with the p4 command

NAME

VCP::Utils::p4 - utilities for dealing with the p4 command

SYNOPSIS

   use base qw( ... VCP::Utils::p4 ) ;

DESCRIPTION

A mix-in class providing methods shared by VCP::Source::p4 and VCP::Dest::p4, mostly wrappers for calling the p4 command.

P4::Client Support (Experimental)

If the P4::Client module is installed, it can be used to connect to the p4d instead of the command line client. While significantly faster, this mode is not ready for prime time due to unresolved issues with the underlying API (it's been a while since I tested it, but as I recall, there was a reply buffer sequencing problem and a request buffer size limitation that was hard to know how to work around.

P4::Client's Perl-to- adapter layer (XS layer) also needed some modification to support full access.

To experiment with this mode, try doing the following before running VCP:

   C:\> set VCPP4API=1  ## On Win32

   $ export VCPP4API=1  ## Depends on your shell

METHODS

p4
   $self->p4( [ "edit", $fn ] );
   $self->p4( [ "change", "-i" ], \$info_for_p4_stdin );
Calls the p4 command with the appropriate user, client, port, and password.
p4_x
Run p4 -x, feeding args to STDIN.
parse_p4_form
   my %form = $self->parse_p4_form( $form );
   my %form = $self->parse_p4_form( \@command_to_emit_form );
Parses a p4 form and returns a list containing the form's data elements in the order that they were accumulated. This is suitable for initializing a hash if order's not important, or an array if it is. You can pass the form in verbatim, or a reference to a command to run to get the form. If the first parameter is an ARRAY reference, all parameters will be passed to CW$self-p4> with stdout redirected to a temporary variable. Multiline fields will have trailing CW\ns in the data, single-line fields won't. All fields have leading spaces on each line removed. Comments are tagged with a field name of #, blank (containing only spaces if that) are tagged with a . This is to allow accurate reproduction of the file if reemitted. NOTE: This does not implement 100% compatible p4 forms parsing; it should be upwards compatible and one day we should implement full forms parsing.
build_p4_form
   my $form = $self->build_p4_form( @form_fields );
   my $form = $self->build_p4_form( %form_fields );
   $self->build_p4_form( ..., \@command_to_emit_form );
Builds a p4 form and either returns it or submits it to the indicated command.
parse_p4_repo_spec
Calls CW$self->parse_repo_spec, then post-processes the repo_user in to a user name and a client view. If the user specified no client name, then a client name of vcp_tmp_$$ is used by default. This also initializes the client to have a mapping to a working directory under /tmp, and arranges for the current client definition to be restored or deleted on exit.
init_p4_view
   $self->init_p4_view
Borrows or creates a client with the right view. Only called from VCP::Dest::p4, since VCP::Source::p4 uses non-view oriented commands.
p4_clients
Returns a list of known clients.
p4_get_client_spec
Returns the current client spec for the named client. The client may or may not exist first, grep the results from p4_clients to see if it already exists.
p4_get_settings
gets all p4 variables/config info available from the 'p4 set' command, and puts them into a hash and returns a reference to it. These are the settings which were set via a p4 config file or environment variables (*nix), or the registry (windows).
queue_p4_restore_client_spec
   $self->queue_p4_restore_client_spec( $client_spec ) ;
Saves a copy of the named p4 client and arranges for it's restoral on exit (assuming END blocks run). Used when altering a user-specified client that already exists. If CW$client_spec is undefined, then the named client will be deleted on exit. Note that END blocks may be skipped in certain cases, like coredumps, kill -9, or a call to POSIX::exit(). None of these should happen except in debugging, but...
p4_set_client_spec
   $self->p4_set_client_spec( $client_spec ) ;
Writes a client spec to the repository.
split_repo_server
Splits the repo_server field in to CW$host and CW$port sections, where CW$host may be a directory name (when --run-p4d or --init-p4d in effect). This is a separate method in order to encapsulate splitting of paths with a volumn name on Win32 (can extend to other OSs as needed).
run_p4d
Runs a p4d instance in the directory indicated by repo_server (use a directory path in place of a host name). If repo_server contains a port, that port will be used, otherwise a random port will be used (and placed back in to repo_server so the p4 client can find it). Dies unless the directory exists and contains files matching db.* (to help prevent unexpected initting of empty directories).
launch_p4d
VCP can use its own p4d, this sub is used to launch it and queue its demise when the program exits. The CW$p4root argument is required. The CW$p4port is optional; if undefined, a random p4 port is chosen (if the random port is already in use, successive random ports will be chosen up to 10 times until an unused port is found) The return value is the p4 port. TODO: Make VCP.pm kill things when the transfer is over and only use END{} subs if that fails.
kill_all_vcp_p4ds
Kills all p4ds that have been started by this VCP process.
underscorify_name
Converts special characters ('#', '@', whitespace and non-printing character codes) in branch, label, and client names in to other symbols.
   "a " => "a_20_"
NOTE: I have not been able to find a description of the set of legal p4 names (namelength, character set, etc). This is purely a first attempt, if you have details on this, please let me know.

COPYRIGHT

Copyright 2000, Perforce Software, Inc. All Rights Reserved.

This module and the VCP package are licensed according to the terms given in the file LICENSE accompanying this distribution, a copy of which is included in vcp.