continuous import of mercurial to bazaar

Scroll Down

I've been hassling Brian to move libmemcached to bazaar for a while now, tonight we finally got a continuous import from mercurial going into bazaar, and published on launchpad. Using bzr fast-import along with hg-fast-export, this was really easy. I'm thrilled to see all the fast-export/fast-import tools that have sprouted up between git, mercurial, and bazaar. Here is the script I stuck in cron to do the continous import (every 6 hours or so), feel free to make fun of my crappy shell scripting.


# move into the hg repo and check if hg repo has new revisions
pushd ../libmemcached

# hg incoming will exit 1 if no new revisions, 0 if new revisions
hg incoming
if [ "$?" -eq "0" ]; then
    # pull hg repo
    echo "New mercurial revisions found upstream, pulling"
    hg pull
    echo "No new mercurial revisions found, exiting"

# move back to our bazaar shared repo

# run fastimport to get the latest revisions into bzr
echo "Importing new revisions into bazaar repo"
export HG_FAST_EXPORT=~/.bazaar/plugins/fastimport/exporters/
$HG_FAST_EXPORT --repo=../libmemcached/ | bzr fast-import -

export LAUNCHPAD_ID=`bzr launchpad-login`

# loop through all branches, pushing them to launchpad
for directory in *
  if [ -d "$directory" ]; then
    echo "Pushing $directory to launchpad"
    pushd $directory > NUL
    echo "bzr push bzr+ssh://$$directory"
    bzr push bzr+ssh://$$directory

View Comments