views:

1673

answers:

3

Let's say I checked in a changelist (in Perforce) with lots of files and I'd like to revert the entire changelist. Is there an easy way to "revert" the entire changelist in one fell swoop?

Currently I do something like this for each file in the changelist:

  • p4 sync //path/to/file#n (where "n" is the previous version of the file)
  • cp file file#n
  • p4 sync //path/to/file
  • p4 edit //path/to/file
  • cp file#n file
  • rm file#n

As you can imagine, this is quite cumbersome for a large changelist.

+3  A: 

This looks interesting. I haven't tried it personally.

ya23
Thanks - I just tried it and it worked great! While I couldn't get the P4V integration working on my Mac, running the script via the command line worked fine.
Marc Novakowski
In case the blog post you linked to goes down, here's a direct link to the script in Google Code: http://code.google.com/p/p4scripts/source/browse/trunk/src/p4revert.py
Marc Novakowski
Also, one note: the python script is (currently) saved in DOS format so you'll need to convert to unix line endings for it to work correctly on unix-based systems such as linux and OS X.
Marc Novakowski
A: 

The official answer from Perforce is at http://kb.perforce.com/UserTasks/ManagingFile..Changelists/RevertingSub..Changelists but the procedure is not all that much easier than the one you suggest. The script suggested by @ya23 looks better.

Douglas Leeder
Yeah with a changelist with just "edits" it's simpler, but once you throw adds and deletes in there, it can get tricky to do manually.
Marc Novakowski
+6  A: 

The posted answers provide correct answers, but note also that there is an actual menu option in P4V to do this for you now. It's in the latest 2008.2 Beta, and so should be officially released the the next week or three.

This link gives details.

It should be a lot simpler to use than the earlier answers, but I've not had the opportunity to try it myself yet.

Update This has now been fully released. See Perforce downloads.

Greg Whitfield
Thanks Greg - I'll give the beta client a try!
Marc Novakowski
I just tried out this beta version of P4V and can confirm that it does have a "back out submitted changelist" feature which does exactly this. Since this is an official Perforce feature rather than a third-party script, I think this should be accepted this as the official answer.
Marc Novakowski