Jump to content

Pulling files without workspace or create temp workspace

  • Please log in to reply
2 replies to this topic

#1 bhoward



  • Members
  • Pip
  • 1 posts

Posted 30 July 2019 - 04:54 PM

Hey I’m relatively new to using perforce and I would like to pull a set of files from the depot to the local machine  without a client workspace.

If that is not possible, how can I create a temporary workspace without having notepad popup. (p4 client foo)

I’m doing this through python, but not through the perforce api.

#2 Sambwise


    Advanced Member

  • Members
  • PipPipPip
  • 1149 posts

Posted 30 July 2019 - 07:55 PM

p4 -c temp_cli client -o --field "View=//depot/whatever_depot_path/... //temp_cli/..." --field "Root=C:\whatever_local_path" | p4 client -i
p4 -c temp_cli sync -p
p4 client -d temp_cli

I recommend generating a unique name in place of temp_cli (something like "temp_cli_" + uuid4().hex) to make sure that multiple instances of the script don't create colliding clients.

The -p option on sync tells the server not to bother tracking what files you're syncing down, which saves you a bit of thrash on writing a bunch of server state only to turn around and delete it all a second later.  Don't use it on a normal sync operation where you're NOT about to delete the client.  :)

#3 Matt Janulewicz

Matt Janulewicz

    Advanced Member

  • Members
  • PipPipPip
  • 224 posts
  • LocationSan Diego, CA

Posted 18 August 2019 - 10:00 AM

One other thing worth noting is that 'p4 print' does not require a client spec. Most of the commands you might use to figure out what files you want will require one, though. :)

A use case we use often is when a project wants to track and use a certain client spec with a changing view mapping. The client template is checked into Perforce and 'p4 printed', then that output is fed into 'p4 client -i' to create the temporary client spec for builds. In a lot of cases it's a better, more obvious way to keep the history of a client spec that changes over time (normally you might designate some random existing client as your template and track it in the //spec/... depot, but that's a little awkward in many people's opinion.)
-Matt Janulewicz
Currently unemployed, looking for work in Boise, ID!

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users