Roll back a submitted Perforce changelist easily and quickly


One of those key features of a version control system is being able to take a change that you submitted (maybe 5 minutes ago, maybe last week) and vaporize it. Like it never existed.

Actually, doing that is hard, but you can apply a change that is the exact mirror image of the one you want to roll back - a kind of antimatter for your change. This has always been a pain with Perforce. You can make it easier with scripts - Perforce publish instructions that involve awk scripts, which tend to make some of my .NET developer friends go pale.

Today, one of my developers broke the CI build and cheerfully went home. Other people needed to know that their checkins had worked, so his checkin needed to be reverted. So I was about to start the usual ritual of synchronizing to the old revision, deleting every file that had been added, adding every file that had been deleted. I got as far as googling the instructions, and found a page by Jim Tilander, who has written a script to do the ritual for you.

That's not the clever bit. What's clever is that he wrote the script to support the Perforce GUI client. So with a little bit of work, you can right click on a submitted change, revert it with a single click, and then submit your change to vaporize the old one.

To make this work you need to:

  • install Python ( I used Python 2.5)
  • put his script somewhere on your computer
  • tell your Perforce client about it.

It's a really helpful script that will save me loads of time. Thank you Jim! (though errant developers may not thank you)

Link

DevOps New Zealand