Perforce - switch to workspace from command line

旧城冷巷雨未停 提交于 2020-08-01 06:49:05

问题


I am asking how to switch from client1 to client2 where client1 belongs to stream1 and client2 belongs to stream2.

What I am looking for it to do the same as being in p4v and then right click on a workspace and selecting 'switch to workspace'

Note, that if your current workspace is client1 and you use:

p4 client -s -S //DEPOT/stream2

or

p4 client -s S //DEPOT/stream2 client2

it won't change the workspace in the p4v GUI.

Any idea?

Thanks!


回答1:


There are several different concepts here.

You can have a single workspace, or you can have multiple workspaces.

Each workspace has its own root directory on your workstation, and its own copy of whatever files you have most recently sync'd.

If you have a single workspace, you can switch that workspace back and forth from one stream to another, by using the 'client -s' command to switch the stream to which that workspace is bound. This way, you can alternate between working on one stream, and working on another, using a single workspace. In the most recent versions of the Perforce server (2015.1+), there is even a 'p4 switch' command which makes this process simpler still.

Switching your single workspace from one stream to another on the command line using 'client -s' is the equivalent of dragging and dropping your workspace icon from the old stream to the new stream in the Stream Graph, more or less.

You can also have multiple workspaces, each with an independent set of files sync'd, and you can work with each workspace separately. On the command line, to switch from one workspace to another, you simply change the way that you tell the 'p4' command which client you want to use, which you can do with the P4CLIENT variable or the '-c' flag to the client. For example:

p4 -c client1 sync

vs

p4 -c client2 sync

tells the p4 client to sync first client1, then client2. Alternately, you can do:

p4 set P4CLIENT=client1
p4 sync

then

p4 set P4CLIENT=client2
p4 sync

to accomplish the same effect (switching between one workspace and the other at the command line).

P4V, however, has its own notion of the "current workspace", which is separate from the command line, and I don't believe that just changing your P4CLIENT variable is enough to perform the P4V operation of "right click on a workspace and selecting 'switch to workspace'".

The closest thing you can get to a command-line command which changes which workspace P4V considers to be the current workspace, I think, is to invoke a different copy of P4V from the command line, and specify a different client name when you do so, as described here: http://www.perforce.com/blog/100114/p4v-secrets-calling-p4v-command-line

But I think this will get you a new P4V window with the other workspace, rather than changing the current workspace of your current P4V window.

Another possibility you could try would be to use one of the Windows GUI automation tools, such as Autoit (https://www.autoitscript.com/site/), to create a script which will use the Connection menu on the menu bar and operate the Switch to Workspace... dialog via Autoit.



来源:https://stackoverflow.com/questions/30829774/perforce-switch-to-workspace-from-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!