Reducing perforce clutter

As I was getting ready to leave work this evening I went into Perforce to find out who all had files checked out despite the request to get everything checked in before a major outage this weekend. I noticed there were a huge number and that there were some really low numbered changelist numbers so I started browsing through them and noticed a huge number of empty changelists. After a little bit of searching, I found out that you can delete an empty changelist from the command line as long as you have admin access using the following:
P4 change -d -f [changelist #]

After getting rid of a couple I decided that this was far too tedious to do one at a time and so then figured out the following command that will run through the pending changelists and delete any that are empty:
for /F "tokens=2" %i IN ('p4 changes -s pending') DO @p4 change -d -f %i

You can actually run this at any time since any changelist that still has open files in it will get a result resembling “Change 218644 has 359 open file(s) associated with it and can’t be deleted.” (BTW, that one is real and it is two years old).

No tag for this post.

Author: Cavorter

Recently divorced SWM seeks, um, stuff. (Formerly used the handle: Glyph)