Something Similar

About Jeff Hodges
Atom Feed

Moving From Bzr to Git (or "Tailor is So Awesome I Cream My Pants")

rFeedParser obviously has not gotten enough love from me. I intend to correct that.

The first order of business was to stop hosting its branches in bzr on this server. No one knew the repositories existed, they were sucking up tons of hard drive space, and, dammit, I’ve been digging git ever since Garry turned me onto it. Oh, and getting rFeedParser into a svn repository on rubyforge required bzr svn which required me patching svn on my Mac Book Pro. Too much damn work.

But I also don’t want to lose all of those commit logs. I’d feel guilty pretending that rFeedParser just magically appeared in its current state without showing off how many times it looked even worse. I decided that I needed just the main branch turned into the master branch of a new git repository and that I’d host it up on GitHub.

Enter tailor. tailor is an amazing bit of Python that can translate from most any version control system to most any other control system. Trying to describe all of the other crazy source control backflips it can do would take up too much space here, but, I assure, its worth checking out. Go do your googlings.

tailor made it drop dead simple to move rfeedparser over, but I had some significant help making that happen. Bryan Murdock‘s post on this exact same topic was a great boon, but not perfect. In the time since he posted, either the config file for tailor changed, or some kind of bizarro bit rot occurred.

In any case, I munged up the config file, looked up some more docs and, now, I present you with a simple way of moving your current bzr branch into a brand spanking new git repository. (How lucky you are!)

First things first, you’ll need bzr, git and tailor. The first two I had installed via MacPorts (verions 1.3.1 and, respectively) while the latter was a bit of a pain. You can install it via MacPorts, but by default it tries to run in the Python 2.4 environment when bzr is installed over in the 2.5 one. Bleh.

What I had to do, was grab the tailor code myself (version 0.9.30), unpack it (say, to ~/src) and run it with python2.5 explicitly. For those of you on Macs, substitute python2.5 ~/src/tailor-0.9.30/tailor for tailor when I write it in the commands below. The rest of you can be blissfully unaware that there is any problem at all because your package management system probably doesn’t suck as much as MacPorts.

First things first. Find your bzr branch while I, for the sake of this post, it’s at /path/to/bzrbranch. Next, decide where you want the git branch to exist which, again for the sake of this post, I’ll pretend is /path/to/gitrepo.

Now, anywhere at all, write a file (which we’ll call bzr2git.conf) containing:

verbose = True
patch-name-format = ""

source = bzr:source
target = git:target
start-revision = INITIAL
root-directory = /path/to/gitrepo
state-file = tailor.state

repository = /path/to/bzrbranch


Notice the git-command line at the end. That’s only for lame-o MacPort users because tailor doesn’t seem to understand $PATH or something, freaks out about not being able to find the git command and leaves us questioning our ability to manage our own systems. Leave it out, or change the path to right one if you’re one another system.

Finally, run

tailor -D -c bzr2git.conf

and you’ll have a happy new git repository at /path/to/bzrbranch with your history intact. Oh! And it’ll have the .bzr directory in it but you can feel free to clear it out. The old bzr branch will still have all that info in place.

And you’re done. I’ll be following up with information on what’s up with rFeedParser in the next post.

Update: Now see this: rFeedParser on GitHub.