Perforce – How to update depot on one workspace and transfer those updates to another workspace without re-downloading?

Oct 16th, 2016 | By | Category: Technology, Windows

So here’s the situation.. You have one computer with a crazy fast connection and another computer with a slow connection.. Or perhaps you have one server that is crazy cheap to run and another that is crazy expensive to run.. The idea would be that, for whatever reason, you want to download and update your perforce depots on the faster or cheaper machine and then transfer those updates over to the slower or more expensive server to do your business on.  The problem with perforce however is that it doens’t want you to do this easily, not through the gui at least so you have to dive into the command line and use a command called p4 sync -k.

The problem arises when setting everything up for this sync however as you have to manually set all your environmental variables before it will let you connect and sync problems, so let’s go throuhg which ones need to be set one at a time

P4USER

  • Pretty important for the server to know how you are and to let you login.  So open up a command prompt and type:
    • #p4 set P4USER=YourUserName

P4PORT

  • Next you need to tell it your server address and port.
    • #p4 set P4PORT=tcp:your.server.url.or.IP:1666 (or whatever your port number is)

Now that those two are set you can login with

  • #p4 login
    • It will ask you for the password for the user specified above, enter it and you will be logged in

P4CLIENT

  • Finally you need to set your workspace so it knows what to sync up with.
    • #P4 set P4CLIENT=ExactAndFullWorkSpaceName

There ya go, all set for the sync, now just go into the root folder of the depot or whatever folder you want to sync from and type:

#p4 sync -k

It will spew hundreds or thousands of lines for all of the files it is syncing and once after that yoou can restart your P4V client, switch to the workspace that you just synced and you’ll be good to go.

Note: If there have been updates to the depot after you last updated locally they won’t be synced over and you’ll have to do a force sync from the slow or expensive machine in order to get them over if you run this sync -k after they’ve come in.

ie:

  1. I pull all updates on my fast machine.
  2. I copy files onto my USB stick, go over to my slow computer, load everything up
  3. In between my pulling the updates, copying the files over and loading them on to the second machine a developer commits 500MB of new files.
  4. I run my sync -k and then load up PV4 only to see that there is a new update in the history that I don’t have
  5. I right click on the update, click get revision and it tells me ‘no files updated’.
  6. The only way to get these updates is to do a force which then pulls a ton of files down kind of defeating the purpose of this exerciese.

So make doubly sure you are up to date before you start copying those files over.

Tags: , , , ,

Leave a Comment