Last active
August 29, 2015 14:10
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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