Perforce workspaces and multiple branches

902 views Asked by At

I'm trying to figure out the best way to setup Perforce workspaces when working with multiple branches for different parts of the code base.

Let's say that my default workspace mapping is as follows:

//depot/foo/trunk/... //my_client/trunk/foo/...
//depot/foo1/trunk/... //my_client/trunk/foo1/...
//depot/foo2/trunk/... //my_client/trunk/foo2/...

And I need to work with both foo and foo1 together as foo1 is dependent on foo.

Now, I want to create a new branch of foo1 say branch1 but I do not want to create a branch for foo and foo2 but I need to work with foo and foo2 trunk and foo1 branch1 together. Due to the way the code is structured, for compilation purposes foo1 and foo2 needs to be in the same folder.

Should I create another workspace with the following mapping?

//depot/foo/trunk/... //my_client/trunk/foo/...
//depot/foo1/branch1/... //my_client/branch1/foo1/...
//depot/foo2/trunk/... //my_client/branch1/foo/...

And switch to this workspace when I want to work on the branch. Note that foo is still pointing to //my_client/trunk/foo/

My development IDE is Intellij, so I'll create 2 projects. First project that has 3 modules for foo, foo1, foo2 in trunk. The second project will have the existing module foo for the trunk code, new modules for foo1 in branch1 and foo2 in trunk.

I first tried to map all of this in one perforce workspace but soon found out that I cannot map the same location in the depot to 2 separate local locations in the same workspace.

For the project foo for which I'm working on trunk and did not create a branch, I do not want to go through the whole project/Intellij module setup process and would like to reuse the existing local copy and setup.

Is this the right way to approach this or is there a better way to do this? I'm quite new to Perforce and still figuring out how it works. A similar scenario was quite easy to setup with Git.

1

There are 1 answers

2
Samwise On BEST ANSWER

I'm not sure what your mapping looked like when you tried having it all in one workspace, but it sounds like you want:

//depot/foo/trunk/...    //my_client/trunk/foo/...
//depot/foo1/trunk/...   //my_client/trunk/foo1/...
//depot/foo1/branch1/... //my_client/branch1/foo1/...

which is a perfectly valid one-to-one mapping. This on the other hand would not work:

//depot/foo/trunk/...    //my_client/trunk/foo/...
//depot/foo/trunk/...    //my_client/branch1/foo/...
//depot/foo1/trunk/...   //my_client/trunk/foo1/...
//depot/foo1/branch1/... //my_client/branch1/foo1/...

because one set of depot files is mapped to two locations -- but you said that you want "foo" to stay in its existing local location, so having two copies of it isn't necessary (or desired) -- correct?

If you did want two different copies of foo (with a duplicate copy under the "branch1" local directory) then I'd do it by having two client views:

//depot/foo/trunk/...    //my_trunk_client/trunk/foo/...
//depot/foo1/trunk/...   //my_trunk_client/trunk/foo1/...

and

//depot/foo/trunk/...    //my_branch1_client/branch1/foo/...
//depot/foo1/branch1/... //my_branch1_client/branch1/foo1/...

Note that in the "branch1" client, the "trunk" depot path is mapped to the "branch1" client path, which is presumably what you'd want (again, if you just the "trunk" branch in the "trunk" local folder, you can do that within a single workspace).