2

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

3 Answers 3

6

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?

2
  • 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 ? Oct 16, 2009 at 11:31
  • 3
    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/ Oct 16, 2009 at 13:12
2

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

It is easy. Assuming you use the command-line, create a p4config.txt at the root directory of each client-spec (aka view). In each p4config.txt, set the P4CLIENT variable to the name of the client-spec. You can leave the other variables as they are.

Here is my sample p4config.txt:

P4USER=deepaknag
P4PORT=SJCPperforce01:1666
P4CLIENT=deepaknag_fbsd

Then set the P4CONFIG environment variable as follows:

export P4CONFIG=p4config.txt

Now it automatically uses the "correct" client-spec whenever you change client directories. Try issuing:

p4 info

in your client directories to verify.


This is also documented in Perforce Knowledge Base (works with p4 for me).

0
  • 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
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.