Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

clearcase to perforce : how to branch?

We are migrating from clearcase to perforce and I have question on branching.

In clearcase once I branch (say my_branch) out I can keep committing incremental changes to a file (say xyz.cpp) without being concerned about the main.

element * CHECKEDOUT
element * .../my_branch/LATEST
element * /main/LATEST -mkbranch my_branch

I can keep checking out and checking in xyz.cpp as many times as I want into my_branch. Suppose I made 23 checkins and I feel the 21st checkin is the one that needs to go into the main, I can get the 21st checkin using ct get and merge it to main.

I can do this for any number of files (say xyz2.cpp, xyz3.cpp ...) in this branch in clearcase. I am not sure how to do this in perforce.

How do I replicate this process in perforce? I see p4 submit but it goes into main. Basically I want to keep saving the incremental changes and also retrieve them as needed for any number of files before merging them to main.

like image 801
Anand Avatar asked Nov 07 '12 20:11

Anand


2 Answers

You can use much the same process but of course the mechanics are different.

Step 1: Make your new branch

Let's say that you have a main branch in Perforce located at //depot/project/main. (That path is in Perforce depot syntax. I can add a link to the relevant docs if you need it.)

I'll define a branch map to capture the information about how the main branch and my new branch relate to one another.

p4 branch my_branch

In the branch map I will add this view:

//depot/project/main/... //depot/project/my_branch/...

Now I will create the branch:

p4 populate -b my_branch

Step 2: Use the new branch

I'll create a workspace that contains both branches. I won't go into all the details but I need a workspace view that looks something like this:

//depot/project/main/... //my_ws/main/...

//depot/project/my_branch/... //my_ws/my_branch/...

Now I'll populate the workspace:

p4 sync

Note that I'll have a copy of both branches in my workspace. Now I'll check out and make changes on my_branch:

p4 edit my_branch/foo.c

p4 submit -d "my_branch changes

I can make as many changes on my_branch as I need.

Step 3: merge to main

Ok, now I'm ready to merge my_branch to main. If I want to merge everything I run:

p4 integ -r -b my_branch

If I want to just merge a single file:

p4 integ -r -b my_branch //depot/project/main/foo.c

Note that I specify the target file.

If I want to just merge a specific revision of a single file:

p4 integ -r -b my_branch //depot/project/main/foo.c#21

like image 116
randy-wandisco Avatar answered Sep 30 '22 06:09

randy-wandisco


The closest from cleartool get would be p4 sync

 p4 sync file.c#4

Copy the fourth revision of file.c to the client workspace.
If the file is already open in the client workspace, or if the latest revision of the file exists in the client workspace, it is not copied.

After that p4 submit remains an obvious choice, but all files in the changelist are submitted to the depot, and files open for edit, add, and branch are closed.

like image 44
VonC Avatar answered Sep 30 '22 08:09

VonC