Sunday, February 28, 2010

Remove the annoying .svn dirs

While moving a Subversion repo to Git, I again was reminded how much I like Git and it's simplicity with regards to what metadata it stores and needs to run.

The particular issue is one most SVN users are familiar with, the .svn hidden dirs. There is one for every directory in a SVN project. With Git there is just one up at the top of each project. The .git directory serves the same purpose and only intrudes in one place. A perfect example of the DRY principle at work

Anyway, I wrote this little command line script to get rid of the annoying .svn dirs when I copied the repo over to what will be it's new Git home.


find . -name ".svn" -exec rm -rf '{}' \;


It finds the .svn dirs and removes them forcefully. I know it's not a big revelation, but it is handy.

Sunday, February 07, 2010

Codeswarm 0.1 on OS X 10.6 with a Git repo

The other day while browsing, I came upon a link to the google code Codeswarm project. Codeswarm allows you to visualize the changes in your source code repository over time. Codeswarm is available here: http://code.google.com/p/codeswarm/

The Codeswarm application will run as an applet allowing you to supply the URL of the repo to visualize and then showing you the changes in your repo graphically. It allows you to save those visualizations as image files which you can then make a movie out of. You can also config some files to use your local cloned repo by giving a config file the directory path to your repo.

This post shows the steps to do use codeswarm 0.1 on OS X 10.6 along with your local clone of the remote Git source repo.

Thanks go to several hints and people who supplied them on the Codeswarm project wiki. I just put several of them together that fit for my need. Also, I couldn't find a page on the wiki that really fit this kind of step by step posting, so I decided to put a blog entry up about how I did it. I did also leave these steps as a comment on one of the wiki pages but it really wasn't the correct one for it, so that cemented my doing this post. So without further ado…


Steps to get it running with your Git

Make sure you have JDK 1.6 installed and setup, including having JAVAHOME set. These steps do not use the OpenGL option which while making it faster are still experimental.

Build and Run
  1. Change directories to your codeswarm directory. ( cd )
  2. Type the ant command to start build
  3. Change directories to your git repo directory. ( cd )
  4. Type in this command (all on one line):
  5. git-log --name -status --pretty=format:'%n------------------------------------------------------------------------%nr%h | %ae | %ai (%aD) | x lines%nChanged paths:' > activity.log
  6. Change directories to your `codeswarm` directory. ( cd )
  7. Change directories to the `convert_logs` directory. ( cd convert_logs )
  8. Convert the log files to XML format. The `-g` option means log format is git. (In git's case a modified git output log by step 2 above) (This command converts the git log to a XML version of itself). To do the conversion, type this command:
  9. python convert_logs.py -g /activity.log -o activity.xml
  10. Change directories to the root codeswarm directory. ( cd .. )
  11. Change directories to the `data` directory. ( cd data )
  12. Edit the `sample.config` file to change the `TakeSnapshots` variable to true like this: `TakeSnapshots=true`
  13. In the `sample.config` file also change the `InputFile` variable to be the path to your XML version of the activity logs. We just had step 5 output it into the same directory the command ran in, so in this case the setting is like this: `InputFile=./convert_logs/activity.xml`
  14. Change directories back up one directory to the codeswarm root directory. ( cd .. )
  15. Create a 'frames' directory at top level of codeswarm directory if there isn't one already. This is where all the snapshots of the progress go. (You'll see exceptions about files not being able to be written if you don't do this.) ( mkdir frames )
  16. Type `run.sh` on command line in this directory.

Make a movie
  1. Look in `./frames` directory and you'll see all your snapshots. Depending on which tools you have available, you can then take these snapshots and make a movie. I pasted them all into iMovie, selected them all and gave them all a frame duration of 00:02 seconds (2 seconds) (In TimeCode format the first set of zero's before colon is minutes and the second set after colon is second) Anyway this produced a nice little movie
Cleanup
  1. Change directories to your git repo directory. ( cd )
  2. Cleanup the activity.log file in your git repo directory. ( rm activity.log )
  3. Change directories to your `codeswarm` directory. (cd )
  4. Change directories to the `convert_logs` directory. ( cd convert_logs )
  5. Cleanup the activity.xml file in your convert_log directory in the codeswarm directory. ( rm activity.xml )
  6. Change directories to your `codeswarm` directory. ( cd )
  7. Change directories to your `codeswarm` directory. ( cd ./frames )
  8. Clean up all the snapshots. ( rm *.png )

NOTE: Where absolute paths are such as in step 5 above, change the path to be the correct one for where you put your file.


My Sample video (most rudimentary)


Other code swarmers