views:

124

answers:

2

I have a large source file in Perforce that has been split up into several smaller files in a branch. I want to create a branch view that can handle this, but perforce (2009.1) only sees the last of the multiple files. For example, I created:

p4 integrate //depot/original/huge_file.c //depot/new/huge_file.c

Later I split the huge file into smaller ones:

p4 integrate //depot/new/huge_file.c //depot/new/small_file_one.c
p4 integrate //depot/new/huge_file.c //depot/new/small_file_two.c
p4 integrate //depot/new/huge_file.c //depot/new/small_file_three.c

Then edit each of those (including //depot/new/huge_file.c) and submit.

Now I make changes to //depot/original/huge_file.c and I want to integrate those changes to //depot/new. If I do this manually, it works fine:

p4 integrate //depot/original/huge_file.c //depot/new/huge_file.c
p4 integrate //depot/original/huge_file.c //depot/new/small_file_one.c
p4 integrate //depot/original/huge_file.c //depot/new/small_file_two.c
p4 integrate //depot/original/huge_file.c //depot/new/small_file_three.c

But I don't want to do that every time I integrate -- this kind of thing belongs in a branch view.

Unfortunately if the branch view includes the same source file multiple times, the subsequent lines override the earlier ones. How can I create a branch view like this:

//depot/original/huge_file.c //depot/new/huge_file.c
//depot/original/huge_file.c //depot/new/small_file_one.c
//depot/original/huge_file.c //depot/new/small_file_two.c
//depot/original/huge_file.c //depot/new/small_file_three.c

When I integrate using this branch spec, I get only small_file_three.c integrated.

+3  A: 

I was going to suggest that you use an overlay mapping (a means to force all the lines of the spec to be processed), but a quick perusal of the page put the kibosh on that:

Overlay mappings are only allowed on client views and do not work with branch views.

It looks like you'll have to script it. This page has some more info that might be of use to you (and emphasizes the fact that this can't be done, "Perforce does not support 1:many file mappings.").

raven
Another possible solution, which I have done with Perforce, is to have multiple branch views to specify each of the different new files. It's clunky, but when I was doing a lot of splitting similar to this, it ended up working fairly well, as you can reuse the same branch specs with different source files.
Caleb Huitt - cjhuitt
A: 

Just as a matter of interest, but why?

Why not have huge_file.c not in Perforce, and then change your build system to assemble it out of the three smaller, source controlled, source files. Or even just #include them if you wanted real simplicity.

In other words, I'm wondering if your're trying to use the wrong tool for the task you want to do?

Greg Whitfield
The source file huge_file.c was already in Perforce, and had become a conglomeration of several independent things that really belonged in separate compilation units. I split it up as a way to clean up the source code. Now each of the source files is much smaller and more manageable.
ScottJ
I should also explain that //depot/original is an old version of the product, and no new development is occurring on that branch, only bug fixes. New development is in //depot/new. Hence the need for integrating between the two in P4.
ScottJ