Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perforce Howto? Syncing/Merging files between branches

Tags:

perforce

(A) ------- (B) ----------- (C)
 |           |               |
Trunk  ReleaseBranch   DeveloperBranch

Developers work in the C branch and check-in all the files. The modified files are then labeled in the C branch. The binaries that get deployed are built from B branch and labeled. Currently all this is manual.

In Perforce, is there a simple way to accomplish this like merging Branches based on labels etc?

like image 451
Srikar Doddi Avatar asked Apr 16 '10 17:04

Srikar Doddi


People also ask

How does Perforce merge work?

P4Merge enables you to compare two text files with a common base file to locate differences and to select the text that you want in the merged result file. The purple icon ( ) is associated with the file that another user edited (their file), and purple bands highlight text that is unique to that file.

How do you integrate with P4V?

To integrate files, you open them for integration, specifying source and target, then submit the changelist containing the open files. P4V performs three types of integration: Branching, which creates a new codeline or branch. For more information, see Creating Branches.


1 Answers

It's not immediately clear how much automation you already have, or how much automation you seek. Perforce itself provides the tools to keep track of integration and branching, but if you want to do things like automated builds and labeling you'll need to look outside the source code control world into the release management/automation world.

I'm going to assume you have two branches:

(B) //depot/yourcode/rel/...
(C) //depot/yourcode/dev/...

Inside these branches the code layout is roughly similar, though dev will be newer (and possibly buggier) than rel. (Your text doesn't explain what you're doing with trunk, so I'm ignoring it.)

Let's say you're devloping in dev and you want to release code. You create a label (let's call it MYCODE_DEV.1.0) with the files you want to release. You can integrate it into rel with:

p4 integrate //depot/yourcode/dev/...@MYCODE_DEV.1.0 //depot/yourcode/rel/...

That integrates from the MYCODE_DEV.1.0 label to the release branch. Perforce keeps track of which file revisions you've merged and which file revisions you haven't merged, so it'll only merge new code. If you've made changes to rel that weren't in dev, you'll need to resolve the changes (either automatically, or by hand). You can then check the changes into rel, create a new label, and release from there.

(Since Perforce keeps track of what you've merged, if you try to integrate the same label again, Perforce will politely decline to do anything, though you can override it if you think you know better.)

(If you read the Perforce documentation, you'll find references to "branch specs", which let you declare a named branch as a shorthand for specifying both the source and destination branches in your integration command. Branch specs are especially useful for maintaining complicated branches with source files scattered across multiple directories, but don't really add value to the simple example here.)

Perforce gives you the tools you need to set up your branches and releases to meet your goals, which can be easily scripted, but doesn't directly do automated releases.

like image 126
Commodore Jaeger Avatar answered Sep 27 '22 20:09

Commodore Jaeger