Crow by Patrick Wilken

Using Perforce for multiple projects

Crafted in California by Tim Trueman   (Wed Jan 09 00:00:00 -0800 2008)

Having used Perforce for multiple projects, I just wanted to share this little trick about using Perforce for multiple projects. You will want to create multiple clients for every logical project you are doing. To get started put this in your ~/.bash_profile:

export P4CONFIG='.P4CONFIG'

cluster

What that does is tells p4 to check for its configuration in whatever directory you execute the p4 command. It then keeps moving up in the directory structure until it finds a .P4CONFIG file. For instance, imagine you're in a web application project and you are exploring the javascript files in a folder called "js" in the root of the project files and run a p4 sync from there. The p4 sync would look for a .P4CONFIG in the current "js" folder, fail to find one and then move up to the root where it would find the project specific .P4CONFIG. Now what shall we put in that project specific .P4CONFIG?

Save the follow snippet into a .P4CONFIG file inside a folder you want to check all the code out to, then run p4 client, edit it to include just the directories you want, then run p4 sync and you're golden!

P4EDITOR=vim P4CLIENT=jschmo-foo P4USER=jschmo P4PASSWD=iknowkungfoo P4PORT=perforce.someinternalserver.domain.com:1666

I use that client name because it's easy to track down who made a change and for what project. If this doesn't work for you try to pull in your bash profile manually with this command:

source ~/.bash_profile

fin

Subscribe Say hi@timtrueman.com