Being a Python newbie, and having just converted my home SCC repositories from Bazaar to Git on OS X Lion, I thought I’d write up a basic how-to guide. I used Tailor, written in Python, to do the conversion. I decided to gain some fluency with Git after attending WordCamp Las Vegas recently, since many, many folks are using GitHub to publish their projects.
I’ve been using Bazaar for my VPS’s config files, as well as some other documents I keep updated fairly frequently, like my resume. Tailor allowed me to quickly convert the Bazaar repository history to Git, after I figured out how to get it functioning on my main workstation running OS X Lion.
Lion has four versions of Python installed as part of the base system. Python 2.7 is the default. Git is also installed by default, but Bazaar isn’t. I use Homebrew to install Bazaar and other packages, rather than MacPorts or Fink. One of the selling points of Homebrew: no root privileges are required to install packages. Homebrew also uses Git for their build configs, so that’s another motivator for my change.
Homebrew installs a separate copy of Python for Bazaar since the base OS’s Python files are located in root-restricted directories, and Bazaar requires extra Python libraries. To get Tailor working I had to get Python to look in these extra directories, after receiving the error, “Common base for tailor exceptions: ‘bzr’ is not a known VCS kind: No module named bzrlib”:
export PYTHONPATH="/usr/local/Cellar/bazaar/2.4.2/libexec:/usr/lib/python2.7"
Tailor doesn’t need to be built or installed. Simply run it out of it’s source directory after making the script executable and creating a configuration file to tell it where your repository directory is located and a few other things. My very minimal config file looks like this but with real paths:
[DEFAULT]
verbose = True #sends verbose output to stdout
patch-name-format = "" #controls the repo change log format
#setting it empty leaves it as-is
[project]
source = bzr:source #format of the repository you are converting FROM
#tailor handles most familiar SCC flavors
target = git:target #repo ormat you are converting TO
start-revision = INITIAL #where in the source repo do you want
#the conversion started?
root-directory = /path/to/new/repo #top-level directory for tailor working
#directory and final conversion dir
state-file = tailor.state #where tailor stores last activity
[bzr:source]
repository = /full/path/to/repo/project
#full path to source repo project directory
subdir = burst-bzr2 #subdir relative to root-directory for extraction
#of the source working copy
[git:target]
subdir = burst-git #subdir relative to root-directory for build of
#the new target repositories
More information on all these options, as well as a plethora of others, can be found in the README.rst in the Tailor source code directory.
After you have your config file, it’s simply a matter of running:
tailor -D -c
I chose to use the debug flag, “-D” so I would have a good idea of what was going on during the process.
Tailor works by doing what you could do manually to convert a repository to a new format. First, it copies the existing repository you’re converting via the source’s repository tools to a temporary work location. Next, it checks out each revision, and syncs the files to your new repo’s target directory via rsync, then commits the files using your new target version control system.
For a simple case like mine with a handful of directories, Tailor works well. For a deep revision history or a complicated source tree, it would obviously take a lot longer, assuming Tailor can handle the complexity.