Saturday, 6 November 2010

Environmental Variable Hides Registry Definition of P4Client

When the P4CLIENT registry variable is set using the Windows "set" command instead of p4 set P4CLIENT, the Windows registry variable masks the Perforce set registry value.

Example:

C:\bruno_ws>p4 set p4client=c:/bruno_ws Perforce client warning: Warning: environment variable hides registry definition of p4client.
Unset the Windows P4CLIENT registry variable: set P4CLIENT=Set the Perforce P4CLIENT value using p4 set: p4 set P4CLIENT=

View the original article here

Where does Hudson store its last synchronized Perforce changelist number?

One of our Hudson build systems is not automatically starting its jobs since we switched it over to a different Perforce server. The polling log reports:

Last sync'd change was nnnnnn

Where nnnnnn is a changelist number from the old server. The new server has lower CL numbers, which causes the problem.

How do I adjust the CL number that Hudson compares against?


View the original article here

Perforce 2009.2 Introducing Perforce

Perforce 2009.2 Introducing PerforceThis guide describes Perforce concepts that are essential to every Perforce user. If you are new to Perforce or need to start using features that are unfamiliar to you, read this guide before consulting the documentation for your Perforce client programs.

Price:


Click here to buy from Amazon

How can I tell P4SCC to ignore files?

I started on a new project a few months ago and am forced to use perforce (pun intended). I have experience with a variety of distributed and monolithic VCS, especially SVN with Ankh as SC plugin in visual studio...that said, I have been evading some..quirks perforce has by applying various workarounds you can find, mainly here on SO. This issue though is something I do not want to give up on so fast, so I hope some of you guys can help me out with it.

I installed the P4SCC plugin in my VS 2010, and at least I got to open the solution and it seems to work as expected. But since VS creates a bunch of metafiles, namely *.vspscc and other scc files, the plugin lists thos in the "pending checkins" window. In P4V you can just revert files marked for add and they will be ignored, even though they remain in the file system...not so here. Apparently P4 does not consider the files as "added" or "changed", so will not revert. Since the files are not part of the solution or projects (at least according to VS), they do not show up in the solution explorer and therefor I cannot use the "File->Source Control->Remove file from source control" option.

I tried different things to ignore those files, since I do not want to check them into the repository. Sadly, I only find ways to get files out of the view in P4V as described here: http://stackoverflow.com/questions/55449/can-you-ignore-a-file-in-perforce Since I told P4SCC to use the same workspace as I do in P4V, I expected those changes to apply to it as well...but once again perforce has NOT behaved as I would have expected.

The temptation is getting bigger to just check in the darn things (alghough there's easily 100+ of them...), but that just seems wrong. So my question is:

Is there any way, no matter how hacky, to get P4SCC to ignore these files, or any files in that manner?


View the original article here

Build P4PHP on Windows

How do I build P4PHP on Windows?

Note that this article provides further detail for the steps listed in the P4PHP release notes, which can be found in the following location:

http://www.perforce.com/perforce/doc.current/user/p4phpnotes.txt

In order to obtain a P4PHP binary for Windows, you will need to set up a PHP build environment. This article describes the necessary steps needed to set up such an environment, as well as instructions on how to build PHP and P4PHP using that environment.

Building P4PHP on Windows will require the following three things:

A properly set up build environment, including Visual Studio with the right SDK and some binary tools used by the build system.

Prebuilt libraries and headers for third party libraries that PHP uses, placed in the proper location in the build environment.

The P4PHP source (ftp://ftp.perforce.com/perforce/r09.2/bin.tools/p4php.tgz).

This is the hardest part of the PHP windows build system to set up and will take up a lot of space on your hard drive - you need to have several GB of space free.

Microsoft Visual C++ -- PHP officially supports building with Visual C++ 6.0 or with Visual C++ 9 (also known as Visual C++ 2008). You can use the Express versions as well. MinGW and other compilers are NOT supported or even known to work. For more information and how to get the compiler see the supported versions. This article supposes that you are using Visual Studio 2008 Express.  Make sure the compiler has been updated with the latest service patch (SP1 at the time of this writing.)

PHP/P4PHP can also be compiled with Visual Studio 2010, as it includes the VS9 compiler.

The correct Windows SDK or Platform SDK to match your compiler. See Supported Windows/Platform SDK for the supported versions. SDK 6.1 is the one used by Visual Studio 2008, but SDK 7 will work as well.

Various tools. See http://pecl2.php.net/downloads/php-windows-builds/php-libs/binary-tools.zip for binary versions of them. The libbind and pcre libraries are not required.

Get Visual Studio 2008 or 2010. You can use any of the commercial editions or the Express Edition.

Get and install windows SDK 6.1 or SDK 7.1

Get a PHP 5.3 snapshot (do not extract yet!)

Create the folder c:\php-sdk

Unpack the binary-tools.zip archive (http://pecl2.php.net/downloads/php-windows-builds/php-libs/) into this directory; there should be one sub-directory called "bin" and one called "script".

Choose Start -> Microsoft Windows SDK v6.1 -> CMD Shell, and then enter the following commands:

setenv /x86 /xp /releasecd c:\php-sdk\bin\phpsdk_setvars.batbin\phpsdk_buildtree.bat php53dev

Now, extract the snapshot from (3) to C:\php-sdk\php53dev\vc9\x86 with your unpacker of choice (WinRAR should handle it) so that the following directory gets created: C:\php-sdk\php53dev\vc9\x86\php-

In the same directory ( C:\php-sdk\php53dev\vc9\x86 ) there is a "deps" folder, extract any of your required libraries inside that folder ( see http://wiki.php.net/internals/windows/libs ), but make sure their top-level contains "/include" and "/lib" (some of them have an extra directory level in there). You can find the pre-compiled libraries that you need here:  http://pecl2.php.net/downloads/php-windows-builds/php-libs/ ( VC9 is Visual Studio 2008, remember - you do not need libbind or pcre ).

Run in the windows-sdk-shell:

cd C:\php-sdk\php53dev\vc9\x86\php-

buildconf - this will clear any existing configuration.

To get an overview of the compiling flags:
configure --help

Create your configure command:
configure --disable-all --enable-cli --enable-pdo (and use --enable- to enable any other desired extensions).
Warning: some extensions need libraries, header files and helper apps, see libs, fetch the version you need and extract the archive in the deps directory: c:\php-sdk\php53dev\vc9\x86\deps). You will need to enable --with-pdo to be able to create the default PHP.

Run nmake.

The compiled php is now under C:\php-sdk\php53dev\vc9\x86\php-\Release_TS.

Now that you have a build environment capable of building PHP, we can build the P4PHP extension. We will build P4PHP as a DLL that can be added to the PHP installation.

Map p4php to the directory C:\php-sdk\php53dev\vc9\x86\php-\ext\p4_php. Note the directory is "p4_php", not "p4-php". This is because "p4-php" is a macro variable, and using this as a directory name would break the build.

In the SDK shell, go back to C:\php-sdk\php53dev\vc9\x86\php-. Reset the configuration:

buildconf

Configure with the following options. ",shared" instructs the compiler to create a dll.

configure --disable-all --enable-cli --enable-pdo --with-perforce=,shared  

Run nmake

nmake

php_perforce.dll should now be in the Release_TS directory.

To test it, you can copy the dll into the "ext" directory of an existing php installation.

To enable PHP to actually use the dll, you need to either run php from the command line with the option php.exe -d extension=php_perforce.dll, or you can hard-wire it in the php.ini file in the php distribution. See Installation, below.

Once you have built PHP/P4PHP, you will need to install it. This involves three steps:

Copy the PHP release tree (The Release_TS directory) to C:\PHP5. This is the recommended location. It can be placed elsewhere, but then you will need to edit the php.ini file so that it can find its extensions.
Create a php.ini file in the C:\Windows directory, or copy (as Administrator) one of the php.ini files in the PHP source tree to C:\Windows\php.ini: C:\Windows\system32>copy C:\php-sdk\php53dev\vc9\x86\php-\php.ini-production C:\Windows\php.ini 1 file(s) copied.

Edit the php.ini file to add the line extension=php_perforce.dll

NOTE: You can skip this step if not planning on doing anything other than testing P4PHP. Creating/Editing a php.ini file is outside the scope of this document. Just use php -d extension=php_perforce.dll when loading your test scripts. Add the C:\PHP5 directory to the PATH variable. (Start Menu -> Control Panel -> System ->Advanced Settings -> Environment Variables)

You can perform some quick tests of P4PHP. Note that the Windows version of PHP does not support interactive mode, so you will need to write up a script and then run it.

Before you do that, make sure that php is in the PATH and that Perforce is being loaded.

C:\users\bruno\Documents\local>php -VUsage: php [options] [-f] [--] [args...] php [options] -r [--] [args...] php [options] [-B ] -R [-E ] [--] [args...] php [options] [-B ] -F [-E ] [--] [args...] php [options] -- [args...] php [options] -a -a Run interactively -c | Look for php.ini file in this directory -n No php.ini file will be used -d foo[=bar] Define INI entry foo with value 'bar' -e Generate extended information for debugger/profiler -f Parse and execute . -h This help -i PHP information -l Syntax check only (lint) -m Show compiled in modules -r Run PHP without using script tags -B Run PHP before processing input lines -R Run PHP for every input line -F Parse and execute for every input line -E Run PHP after processing all input lines -H Hide any passed arguments from external tools. -s Output HTML syntax highlighted source. -v Version number -w Output source with stripped comments and whitespace. -z Load Zend extension . args... Arguments passed to script. Use -- args when first argument starts with - or script is read from stdin --ini Show configuration file names --rf Show information about function . --rc Show information about class . --re Show information about extension . --ri Show configuration for extension .C:\users\bruno\Documents\local>php -m[PHP Modules]CoredateeregpcrePDOperforceReflectionSPLstandard[Zend Modules]

If you see "perforce" listed in the modules then it is being loaded properly. Proceed to testing.

Place the following in a file named p4php_info.php.

identify());$p4->port = 'localhost:1666';$p4->user = 'bruno';$p4->connect();print_r($p4->run('info'));$p4->disconnect();?>

Now run p4php_info.php. You should see something like the following:

C:\users\bruno\Documents\local>php -f p4php_info.phpPerforce - The Fast Software Configuration Management System.Copyright 1995-2010 Perforce Software. All rights reserved.Rev. P4PHP/NTX86/2009.2/239532 (2009.2 API) (2010/03/24).Array( [0] => Array ( [userName] => bruno [password] => enabled [clientName] => test-ws [clientRoot] => c:\Users\bruno\Documents\local [clientCwd] => C:\Users\bruno\Documents\local [clientHost] => tombstone [clientAddress] => 192.0.0.1:1666 [serverName] => Bruno P4D [serverDescription] => Bruno test service [monitor] => enabled [security] => enabled [serverAddress] => Bruno:1666 [serverRoot] => C:\Program Files\Perforce\Server [serverDate] => 2010/03/29 15:09:00 -0700 Pacific Daylight Time [serverUptime] => 102:44:51 [serverVersion] => P4D/NTX64/2009.2/228098 (2009/12/16) [serverLicense] => none ))

View the original article here

Perforce File Locked By Departed User

"Locked" and "checked out" are two different things which require two different operations to undo. As Peter G. said, an admin can unlock a file with the unlock command:

p4 unlock -f

However, to revert a file checked out by another user, you need to impersonate that user by passing their client (workspace name), host (computer name) and user names to the revert command, like so:

p4 -c theirclient -H theirhost -u theiruser revert filename

So if a Perforce user named jdoe has file foo.txt checked out in workspace ws1 on a host named joesPC, an admin can revert it with the following command:

p4 -c ws1 -H joesPC -u jdoe revert foo.txt


View the original article here

Changing the Windows TEMP Directory

I have been hitting the Windows path length limit of 260 characters on my local workspace, but it is not the workspace root that is causing the problem. Instead, the error message indicates that the temporary file could not be created.


As noted in KB article #978, you can avoid most path length issues by moving the local workspace root to a shorter path. However this does not affect the current location of the Windows TEMP directory, typically located on the path: C:\Users and Documents\{user name}\local settings\tempBefore adding the user name this is a 43 character path. Adding a user name of 8 letters pushes this over 50 characters. The location of the temporary file directory is controlled by the operating system, as noted in the Perforce Command Reference. To set the Windows temporary directory location for a current DOS command prompt, you can to use the "set" command from the command prompt. For example: set TMP=C:\temp set TEMP=%TMP% Note: The temporary directory must already exist. The first command sets the value for %TMP%. The second verifies that the %TEMP% value is the same as %TMP% -- a mismatch of those two values can cause a variety of problems for anything that uses the temporary directory. To permanently set the temporary directory for a Windows user account, go to Control Panel->System->Advanced, and enter the "Environment Variables" dialog window to find and change the TEMP and TMP variable settings in the "User variables".

View the original article here