Perforce Changelist Search

April 14th, 2009

Several months ago, I found myself in a situation where I wanted to search Perforce changelist descriptions. After exploring the UI, talking to coworkers, and asking the internet, I came to the conclusion that it simply wasn't possible using P4V or P4Win. There are ways to do this using the command line (run p4 changes and redirect the output to a text file, then use grep) or p4sql, but neither solution is simple and elegant. This turned out to be one of those little things that most people brush off but for some reason I couldn't forget about it. After all, if you're working with good, disciplined developers, the changelist description is usually the juiciest part of a commit. It should contain a brief description of the feature the developer added, the bug she fixed, or the content she changed. If you're like me, software annoyances such as this one occasionally turn into pet programming projects. After a month or two, this is what I ended up with:

(I recommend watching the HD version and exanding it to fullscreen so you can actually see what's going on. Turn up your volume for my voice-over.)

In short, the program allows you to sync all of the changes in a Perforce repository and search them locally. Just for fun, you can also view graphs of changes over time. I wrote it in Python, using wxPython for the user interface. Changes are stored in an sqlite database which makes searching fairly easy. The graphing is done using matplotlib and to bundle everything into a .exe I used py2exe. (Note: I wasn't able to cleanly pack the required matplotlib modules into the executable. If you have experience with this and can offer advice, please share.) Finally, to interface with Perforce I'm using P4Python. Although developers seem to have their fair share of complaints about P4V and P4Win, Perforce certainly does a great job of providing API's for several languages (C/C++, Perl, Python, Ruby). And from what I've heard, many companies use the API's to integrate their tools with perforce or add a layer on top of Perforce with custom behavior. However, it doesn't make sense for everyone to be writing the same custom tools (especially for things like version control). If Perforce were to add a good plugin architecture, that allowed you to insert features in the UI as first-class citizens, common tools could be written once and shared. This would especially help small and medium sized companies that might not have their own tools teams.

Update (5/8/09): Perforce Changelist Search 0.1 has been released.