Search code examples
perforceworkspace

Change perforce workspace view map from commandline


I have searched the internet and the perforce help pages, but couldn't find a solution to my problem.

In a script, so on the commandline, I want to change my workspace view map. For example:

//depot/some/branch/myfolder/mysubfolder/... /home/myuser/perforce/branch/myfolder/myworkspace/... to //depot/some/branch/... /home/myuser/perforce/branch/...

I cannot figure out what command to use. Can you help me out?


Solution

  • You'll need to use the p4 client command. You can script that using the -i and -o options, which let you interact with the workspace form via STDIN and STDOUT.

    An easier path is using a scripting API like P4Python:

    cspec = p4.fetch_client('my_ws_name')
    view = ["//depot/some/branch/... /home/myuser/perforce/branch/..."]
    cspec["View"] = view
    p4.save_client(cspec)