Saturday, March 16, 2013

Creating a branch in Perforce with P4V

I recently wanted to create a private branch to experiment with some stuff in a Perforce repository. Coming from a SVN history, I had to figure out what 'branching' means in Perforce.

Perforce uses the word "integrate" for most branching activities. What's a little strange is that you 'integrate' to create the branch, then you 'integrate' to merge the branch later.

I'm still not completely sure what that means

First, create a new branch spec. Use File > New > Branch Mapping. (To edit it later, use View > Branch Mappings). In it, I created "CLOUD_CRAZE" as the name of my branch, then gave it a branch spec of
//depot/kaptest.com/jboss_apps/kaptest_3.1/DEV/... //depot/kaptest.com/jboss_apps/kaptest_3.1/branches/CLOUD_CRAZE/DEV/...

Next, you need to actually execute the branch creation, which is done with "Integrate..."

Choose the "CLOUD_CRAZE" entry in the Workspace that I currently have sync'd. Context Menu > Integrate ... "Use Branch Specification"

Select my branch mapping "CLOUD_CRAZE"

Use "Preview" to indicate that it seems to have the right mapping together

Use "Integrate" to actually start the branch/copy.

It churns for a while and appears to be creating my copy. NOTE: It appears that P4 does client-side copying and branching, so this takes a LOOOOONG time if you have big files.

When finished, I know have files in ~/MyCodeProjects/juan_rtcap/kaptest.com/jboss_apps/kaptest_3.1/branches/CLOUD_CRAZE/DEV

Finally, you must submit this into perforce in order to see it in your Depot and Voila!!!

You're all set!