views:

267

answers:

2

Hi,

I am new to Perforce.

What would you consider P4 best practices in terms of views/branches.

Would you create 1 view with access to many branches, or would you create 1 view / branch ?

I am not sure switching between views/worspaces is that easy in Perforce.

Thanks,

Thomas

+5  A: 

If by "view" you mean workspace (aka client-spec), then I strive to have one client spec for each branch I am working on. I'm assuming by branch you mean you have a typical system where you have mainline, development branches, and maybe release branches too?

The reason for keeping the 1-1 correspondence is it just keeps things simpler. It can also prevent accidents - e.g. when I am in a development client spec, I know I cannot accidentally look at or modify a file of the same name in another branch. This can be a big help when you are down in the depths of a deep source folder hierarchy.

Keeping views "tight" is generally good practice in Peforce - as in anything. It helps server performance, which in turn helps performance of Perforce on your client machine. But beyond performance, I think the concept of only seeing what you need to see - letting the computer do the filtering for you - is just generally a good thing. It lets you concentrate on the job at hand without distraction.

I don't have any difficultly switching workspaces, and there are a number of ways to do this depending on your circumstances and preferences. P4V has a simple drop-down at the top of the left pane, for example. What difficulties are you having switching workspaces?

Greg Whitfield
Hi Greg, thanks for your answer. Yes, switching workspace using P4V is trivial. It's on the CLI that I found it less intuitive. If you have two workspaces, let's say c:\worskpace1 and c:\workspace2, I had the impression that by default you are supposed to work in only one of them (e.g. workspace1), defined at login, but it was easy to do "cd c:\workspace2", "p4 sync", and if I am not mistaken, it would be workspace1 who gets sync, when you would think workspace2 would be. Maybe I am wrong ?
Thomas Corriol
You maybe confusing folders on your hard disk with workspaces in Perforce - the latter map files from the depot into the former. Simply CD'ing from the command line tells Perforce nothing - you are simply acting locally. You need to do 'set P4CLIENT=<name_of_workspace2>', and this will override whatever your default client spec is.Note that if you want Perforce to switch client specs for you depending on your current directory on your filesystem, you can do that using the P4CONFIG mechanism - dig around in the docs. As I said, Perforce is very flexible/
Greg Whitfield
+1  A: 
  • Here's what Perforce says on the subject.
  • Also Eric Sink has a good discussion.
  • I create one view with accesses to many branches. Since branches appear in everyone's view by default, you want to have a user area off the main line.
  • Many engineers are more comfortable with the concept of branches, since they exist in all SCM systems. But views may be concerning, if they haven't seen that concept
Brian Carlton
Thanks Brian, I will read your references.
Thomas Corriol