Tuesday, August 10, 2010

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.

To create the branch, I used this link: http://www.exogenesis.org/notes/perforce.html which was very helpful.

First, create a new branch spec. Use File > New > Branch Mapping. (To edit it later, use View > Branch Mappings). In it, I created "LogRecords-rmills" as the name of my branch, then gave it a branch spec of

//dev/product/support/tools-internal/LogRecords/... //dev/product/support/tools-internal/LogRecords-rmills/...

which I *think* will create a second version of it right next to where it belongs.

Side project: I also adjusted my current workspace spec to prune down the entire repository that I had. I used View > Workspaces, then edited my workspace to include

//dev/product/support/tools-internal/LogRecords-rmills/... C:/workspace/LogRecords-rmills

Next, you need to actually execute the branch creation, which is done with "Integrate..."
  1. Choose the "LogRecords" entry in the Workspace that I currently have sync'd.
  2. Context Menu > Integrate ... 
    1. "Use Branch Specification"
    2. Select my branch mapping "LogRecords-rmills"
    3. Use "Preview" to indicate that it seems to have the right mapping together
    4. 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 C:\workspace\LogRecords-rmills.

4 comments:

  1. Very useful post. Worked great for me. Thnx.

    ReplyDelete
  2. What a wonderful post

    ReplyDelete
  3. Before integrating dont use default check box for pending change list.
    After clicking on integrate button all the changes added to new change list , where we need to submit so that branch created in depot.

    ReplyDelete