Search code examples
perforceworkspace

Perforce: Set up Workspace by copying existing workspace?


My project is somewhere in the order of 100 GB per stream, with an additional 60 GB added to each workspace for local local cache files.

Rather than downloading and rebuilding from the depot every time I need a workspace for a new stream, is there a way to copy a workspace I already have downloaded and set up, then have Perforce recognize it as part of a different stream?


Solution

  • Where your first workspace is clientA rooted at /home/clientA and your new workspace is going to be clientB, do:

    cp -r /home/clientA/ /home/clientB/
    p4 set P4CLIENT=clientB                   # or use P4CONFIG files
    p4 client -t clientA
    p4 sync -k @clientA
    p4 clean
    

    Now you have clientB set up as a copy of clientA -- the sync -k command tells the server "sync everything that clientA has but don't send me the actual files, just pretend that I synced them." The p4 clean command should be a no-op, but if you somehow messed up the copy or you had open files in clientA or something, this will fix it by forcing a re-sync of the files that are wrong.

    Now that you've done that you can do:

    p4 switch STREAMNAME
    

    which will switch you to a different stream, syncing only the files that are different. Many people just have a single workspace and use p4 switch to hop between streams; it automatically stashes your work in progress and everything, and you conserve local disk space by not having multiple copies of everything. (A good case for having multiple workspaces would be if you have the space to spare and you don't want to rebuild those 60GB of cache files each time your workspace contents change...)