Perforce Client Setup
Listen to this article
For anyone who is is unfortunate enough to work with Perforce—and so I don't have to remember—here's a quick-and-dirty kick-start guide for setting up a client workstation. (Note I'm on a Mac so your mileage may vary.)
First things first, install the perforce software available from http://www.perforce.com/perforce/downloads.
Next, in order to avoid various command-line arguments, I have the following environment variables set:
export P4EDITOR="$EDITOR" export P4USER="username" export P4PORT="1666" export P4HOST="clientname.local" export P4CLIENT="clientname"
If you're using SSH, you'll need to create a tunnel to the server. Something like this should work:
ssh -L1666:server:1666 -p 22 -N -t -x username@server
This sets things up so all requests to localhost:1666 are routed over ssh to the remote server. You can then setup the client:
p4 client
This will launch your default editor—in my case that's TextMate but nano/pico/emacs/vi/etc will do—and allow you to modify the following fields:
Client: clientname Owner: username Host: clientname.local Root: /path/to/projects/ View:
See the documentation for an explanation on how to set-up the View. In my case, I'm running a rails application, so I have some rules to exclude various generated and client specific directories:
-//depot/projectname/config/database.yml //clientname/projectname/config/database.yml -//depot/projectname/db/schema.rb //clientname/projectname/log/schema.rb -//depot/projectname/log/... //clientname/projectname/log/... -//depot/projectname/tmp/... //clientname/projectname/tmp/...
Finally, to get a copy of the latest source code in /path/to/projects/projectname, run:
p4 sync
And because I just can't help myself, by way of comparison, here's the equivalent instructions for subversion:
svn co svn+ssh://username@repositoryurl/trunk/projectname
Gosh, wasn't that difficult.
Comments
Hi, Simon.
I feel your pain. Recently I have added Perforce support to Cerberus Continuous Integration tool. http://cerberus.rubyforge.org
So I was need to learn now to checkout and update sources from P4 repo. I would say that p4 way much less intuitive than Subversion's way.
BTW Could you help test Cerberus with P4?? Now P4 support lays in project repository.
Posted by: Anatol Pomozov | December 2, 2006 05:05 PM
Can't agree on this. We have been using Perforce for several years, and find that it's way better than PVCS, RCS, or CVS. Subversion (at the time we chose Perforce) was kinda-beta feeling, and did not have a 24x7 support line, which is a requirement. I really like the diff and history tools available in Perforce.
Some specific comments:
1. You don't *need* to use environment (or "p4 set") variables, but you can. You could (if you were using it) specify everything to the P4V GUI client, but your use of "p4" demonstrates a preference for command-line usage.
2. The external SSH tunneling setup is environment-specific. I don't need SSH to do work from the office, home, or the coffee shop.
3. Your client view has a lot of "-" (excludes). Just a suggestion, but I think you might find it easier to include what you want (and ONLY what you want) vs. excluding everything else. By the way, the subtleties of understanding Perforce client view mapping consumes about 50% of the support questions I get (as an admin) -- especially in relation to branches. To be fair, only 1 of our 695 users has been to a Perforce class. We just turned everyone else loose with it, so total lack of training is our own fault.
4. It's a personal shortcoming, but I don't appreciate all the additional spewage that SVN deposits all over my local file system.
5. Perforce uses client workspaces as an additional layer to isolate work on multiple projects. SVN uses the native file system organization to accomplish that, which is fine as long as everything you do is related hierarchically.
6. I can never remember how to add a new file into a SVN project.
Posted by: pt | April 15, 2008 07:35 AM
Hi,
Can you tell me how to set the client's Root path by using command or environment variable?
Thanks
Posted by: Vincent | July 23, 2008 04:14 PM