views:

773

answers:

2

Hi,

A path in Perforce contains files a.txt and b.txt. I'll refer to the main path as mainline.

I've create a branch (called initialbranch) from there which contains just a.txt. I make lots of changes to a.txt, and am very happy with it. However, it's not yet ready for submitting back to mainline. I can easily integrate any changes to a.txt that occur in mainline.

Another project comes along, which needs the changes from initialbranch. Now, say I want to make changes to b.txt, and want to be able to integrate changes that happen both in initialbranch and in mainline. At present, I'm branching from initialbranch (call this new branch secondbranch). Previously I've been adding b.txt to initialbranch, and then integrating my changes across to secondbranch. Is there a nicer way to do this?

Sorry if this question seems somewhat convoluted, I've expressed it as best I can!

Thanks,

Dom

+3  A: 

I'm not convinced I understand your question, but I'll try to help.

If you're saying that you don't really want b.txt in initialbranch, you can define a branch specification like this:

initialbranch/a.txt secondbranch/a.txt
mainline/b.txt secondbranch/b.txt

That way, when you integrate using the "secondbranch" branch spec, your changes in secondbranch will get pushed to initialbranch or mainline.

If you don't want to push changes directly from secondbranch to mainline, then do what it sounds like you are already doing: integrate b.txt from mainline to initialbranch, then from initialbranch to secondbranch. Work on it in secondbranch, then integrate the changes successively back to initialbranch and mainline.

erickson
Thanks erickson - that's really helpful!
Dominic Rodger
+1  A: 

Perhaps a diagram might help?

 a,b------------------------------------------------------> mainline
      \ branched                             / integrated back in
       \-a----------------------------------/------------> initialbranch
                     copied from mainline  /
                     -b-------------------/--------------> secondbranch

Branching in perforce is inexpensive, so I would normally branch an entire directory structure rather than individual files.

Its not too late to do this. As erickson says, rather than copy/add the file to secondbranch, you can just branch from mainline into your dev branches.

 a,b--------------------------------------------------> mainline
      \ branched    \                             / integrated back in
       \-a-----------\---------------------------/----> initialbranch
                      \ branched from mainline  /
                       -b-----------------------------> secondbranch
toolkit