Skip to content

Instantly share code, notes, and snippets.

@zlargon
Last active August 29, 2015 14:10
Show Gist options
  • Save zlargon/7eb211e487086b265805 to your computer and use it in GitHub Desktop.
Save zlargon/7eb211e487086b265805 to your computer and use it in GitHub Desktop.
clone mercurial repository, and using "fast-export" to convert it into git repository
#!/bin/sh
hg_remote=$1
project_path=$2
function usage() {
echo " Usage: ./hggit-clone.sh <mercurial repository remote url> <project path>"
echo "Example: ./hggit-clone.sh https://bitbucket.org/oojah/mosquitto mosquitto"
}
# check hg_remote
if test "x$hg_remote" = "x"; then
usage
exit
fi
# check project_path
if test "x$project_path" = "x"; then
usage
exit
fi
# download fast-export and hg-project
git clone git://repo.or.cz/fast-export.git
hg clone $hg_remote hg_project
# create git project
mkdir -p $project_path
cd $project_path
git init
# fast-export hg -> git
../fast-export/hg-fast-export.sh -r ../hg_project
# remove useless files
git checkout HEAD
cd ..
rm -rf fast-export
rm -rf hg_project
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment