Perforce is the Most Ridiculous Thing

So, perforce is pretty great, right? Handles binary files and large projects like it ain’t no thing!

Here’s a fun thing: say you have a large project. Say that large project is about 180gb. LOTS OF FUN RIGHT? 

On any big project, at some point you will encounter a basic tautology: your server will one day kill you in a fit of blind rage. To avoid this sad death by what should be, in most realities, an inanimate object, take care of your server. It loves you. It’s just trying to do right by you. 

Early on in Steel Harvest‘s development, I foolishly — like a small child just inserting cat tails into electrical outlets – checked ALL THE THINGS into the Joy Machine perforce repo. This resulted in this state:

This is not an unusual problem, and I think we should all throw up arms against Royal so we start getting servers measuring their size in terabytes for maximum game development goodness. In the mean time, though, I had to clear out a whole lot of irrelevant files from the depot.

This is not trivial. In fact, this two-line command (in Windows PowerShell) took me about eight hours to put together. Turns out: obliterating a repo through a large swath of files is just not something people do? Alternatively: I missed something very obvious. I don’t think so, but this is me we’re talking about.

I shall impart this knowledge upon the world so no one has to go through a few hundred chrome tabs down a rabbithole of sadness until you realize you forgot what light looked like. Again: this is reliant on Windows PowerShell cmdlets. Also once you execute this you’re basically saying “I no longer care about any deleted files from my repository whatsoever“. WARNING: This execution results in the permanent and non-recoverable purging of any files listed in deletedfiles.txt.

p4 files ... | grep ' - delete' | sed s/#.*// | Out-File F:\deletedfiles.txt
Get-Content F:\deletedfiles.txt | Foreach {p4 obliterate -y $_}

Basically: this just uses p4 files to list out all files in the depot root that have been marked as deleted and funnel those into a text file. The next line grabs all of the content form the text file and obliterates it line-by-line. This is not my favorite solution, but by the time I got to this point, I didn’t want to dig through forums and threads and e-mail mailing lists etc. etc. etc. to figure out how to feed a text list of files directly into a p4 command.

One major issue with this “solution” to quickly clean out the repo is that I frequently ran into a situation where PowerShell would just stall out, requiring me to update the text file (it’s executing linearly, so you can be fairly confident that the last file before the stall is your end-selection and you just delete up to the file beginning). This is annoying. It is not as annoying as manually going through the depot file directory structure to manually do this.

That said, I should probably indicate that this is not the best and most safe and reliable of ideas I’ve ever had.

Leave a Reply