April 1, 2009

Code Swarm - Visualize your depot history!


Code Swarm is a visualization tool that:

shows the history of commits in a software project. A commit happens when a developer makes changes to the code or documents and transfers them into the central project repository. Both developers and files are represented as moving elements. When a developer commits a file, it lights up and flies towards that developer. Files are colored according to their purpose, such as whether they are source code or a document. If files or developers have not been active for a while, they will fade away. A histogram at the bottom keeps a reminder of what has come before.

Here are two screen shots from a video that my coworker Matt Attaway created from our internal P4 repository (the oldest one in the world!). The first is a year or so into its life, and the second is from around 2007. The user names have been crossed out to protect the guilty^Winnocent.


Now if you want to try this out on your own depots, here's a simple quick-start:

  1. Get the code. It's written in Java and Python.
  2. Unpack the source and change directories into it.
  3. Build it:


  4. Run it with some default data, rendering it in realtime to your display:


Now, to actually get data from your repository instead of using the example history, you can do this:

  1. Run the log converter script on a depot of your choice:

    python convert_logs/convert_logs.py --perforce-path //some_depot/...

    Note that it'll use whatever connection details you have set in your environment, and that it'll run a "p4 changes //some_depot/..." and then a "p4 describe" on each changelist it found. Its output file is called "depot.xml" no matter what your depot is actually named.

  2. Move the log file it created into the data directory:

    mv depot.xml data

  3. Edit the config file, pointing it to the log file you created:

    emacs data/sample.config

    E.g.: InputFile=data/depot.xml

  4. Run the program again!


    You'll have to hit enter once to accept the defaults unless you want something different.