17 December 2007 8:54 PM (version control | bazaar)
A couple of weeks ago I was hacking on a GStreamer element from gst-plugins-bad and realized that I needed a way to record my changes in pieces, but not commit to the repository. GStreamer uses CVS, which does not support this workflow.
Bazaar to the rescue, then. I created a new local repository, in the plugin directory. It's as simple as typing bzr init, adding the files you want to track, and then committing as you make changes. I ended up committing a dozen patches or so.
Of course, when I was finished I wanted to push the changes upstream. Thus the point of this writing product, a script to turn a bzr repository into a series of patch files on disk:
#!/bin/bash set -e patchbase=$(basename `pwd`) outputdir=$1 if test -z "$outputdir"; then outputdir=.; fi revno=`bzr version-info | grep revno | cut -d: -f2` echo "exporting $(($revno)) patches..." for ((i=0; $i<$revno; i=$i+1)); do file="$patchbase.diff.$(($i+1))" echo "exporting $i..$(($i+1)) to $file" # dunno why bzr always returns $? != 0 bzr log -r$(($i+1))..$(($i+1)) > $file || true bzr diff -r$i..$(($i+1)) >> $file || true done
I then reverted my tree, applying and committing the patches one-by-one with e.g. patch -u -p0 < foo.diff.4. I'm sure there's some kind of more integrated plugin to do this, but a 10-minute shell script was easiest to hack out.
As an aside, bzr uncommit is quite useful for producing a readable history -- I often go back and modify the committed patches so that they are more understandable on their own.