Perforce: Avoid using the same absolute local path on all dev machines?
-
09-10-2019 - |
문제
I'm new to Perforce (but am fairly experienced with other systems, mostly SVN).
Now I'm trying to make a simple windows bat build script that needs to check in some build results (controversial to some, I know, but please try to ignore as it's a different discussion). I'm using p4 for this. The problem is that it seems I either:
- Use the same "client" as on other machines (the -c option). This will have a "root", which looks like it specifies the absolute path where the working copy goes locally. Seems rather "wtf?" to me...
- Interactively create a "client" for each machine (matching the local file system layout). The interactivity is obviously a deal-breaker for an automated script.
Can I somehow just use the current directory, like I can with SVN?
Is there a better option?
해결책
Create a workspace with a root of null and map the depot to that client. Here's an example client spec:
Client: client_name Update: 2010/10/20 14:18:23 Access: 2010/10/20 14:20:53 Owner: raven Host: ravens-pc Description: Created by raven. Root: null Options: noallwrite noclobber nocompress unlocked modtime rmdir SubmitOptions: leaveunchanged LineEnd: local View: //depot/... //client_name/...
The first thing your script should do is switch to this client by setting the $P4CLIENT$ environment variable:
p4 set p4client=client_name
You script will now be working in the context of that client. By virtue of the fact that you have specified a root of null, any syncing that you do will be relative to the current directory. So, if you sync //depot/foo/... while in C:\bar, your files will appear in C:\bar\foo.
The last thing your script should do is clear the P4CLIENT variable to restore the system to the default client specification:
p4 set p4client=
다른 팁
I'd suggest creating a new client each time with a client template. First, manually create a client with the view as you'd like it in the actual build clients. Don't specify the Owner, Client, or Root fields. Then, each time you want a new client have it do the following:
p4 client -t my-client-template-name -o my-unique-client-name >clientspec.txt
p4 client -i <clientspec.txt
Where my-client-template-name
is the client you created in the first step. Of course, when you're done be sure to do the following:
p4 client -d my-unique-client-name
You can interactively create a client without an editor by using p4 client -i
:
The -i flag causes a client specification to be read from the standard input. The user's editor is not invoked
So in your builtscript you'd have a template for the client view, which you modify on the fly for the current build machine and pass it to p4 client -i
.
Apparently, you can pre-create a client workspace with a root directory of "null", which will cause perforce to use current working directory as root.