Files
rcs/git2hg

60 lines
935 B
Bash

#!/bin/sh
# Convert git repositories to Mercurial
# Extensions required: hg-fastimport
clean() {
rm -rf ${1}.fi ${1}.fo ${1}.lift ${1}.map ${1}.opts
}
git_export() {
(cd ${1}-mirror ; repotool export) >${2}.git
}
git_mirror() {
repotool mirror ${1} ${2}-mirror
}
prepare() {
touch ${1}.opts
touch ${1}.map
touch ${1}.lift
}
hg_import() {
reposurgeon "script ${2}.opts" \
"read <${2}.git" \
"authors read <${2}.map" \
"sourcetype git" \
"prefer git" \
"script ${2}.lift" \
"legacy write >${2}.fo" \
"write >${2}.fi"
reposurgeon "read <${2}.fi" \
"prefer hg" \
"rebuild ${repo_name}-hg"
}
print_usage() {
printf "usage: %s [export dir file] [mirror url repo_name] [migrate repo_name]\n" "$0"
exit 1
}
case $1 in
export)
git_export $2 $3
;;
mirror)
git_mirror $2 $3
;;
migrate)
prepare $2
hg_import $2
clean $2
;;
*)
print_usage
;;
esac