$ cd /path/to/hg/repo
$ cat << EOF >> ./.hg/hgrc
[extensions]
hggit=
EOF
$ hg branches > ../branches
#!/usr/bin/env bash
hgBranchList="./branches"
sed -i 's/:.*//g' ${hgBranchList}
symbolsToDelete=$(awk '{print $NF}' FS=" " ${hgBranchList} > sym_to_del.tmp)
i=0
while read hgBranch; do
hgBranches[$i]=${hgBranch}
i=$((i+1))
done <${hgBranchList}
i=0
while read str; do
strToDel[$i]=${str}
i=$((i+1))
done < ./sym_to_del.tmp
for i in ${!strToDel[@]}
do
echo ${hgBranches[$i]} | sed "s/${strToDel[$i]}//" >> result.tmp
done
sed -i 's/[ \t]*$//' result.tmp
sed 's/^/"/g' result.tmp > branches_hg
sed -i 's/$/"/g' branches_hg
sed 's/ /-/g' result.tmp > branches_git
sed -i 's/-\/-/\//g' branches_git
sed -i 's/-\//\//g' branches_git
sed -i 's/\/-/\//g' branches_git
sed -i 's/---/-/g' branches_git
sed -i 's/--/-/g' branches_git
rm sym_to_del.tmp
rm result.tmp
#!/usr/bin/env bash
gitBranchList="./branches_git"
hgBranchList="./branches_hg"
hgRepo="/repos/reponame"
i=0
while read hgBranch; do
hgBranches[$i]=${hgBranch}
i=$((i+1))
done <${hgBranchList}
i=0
while read gitBranch; do
gitBranches[$i]=${gitBranch}
i=$((i+1))
done <${gitBranchList}
cd ${hgRepo}
for i in ${!gitBranches[@]}
do
hg bookmark -r "${hgBranches[$i]}" "${gitBranches[$i]}-cnv"
done
hg push git+ssh://git@bitbucket.org:username/reponame-temp.git
echo "Done."
#!/bin/bash
repo="/repos/repo"
gitBranchList="./branches_git"
defaultBranch="default-cnv"
while read gitBranch; do gitBranches[$i]=${gitBranch}; i=$((i+1)); done < $gitBranchList
cd $repo
for i in ${!gitBranches[@]}; do git checkout ${gitBranches[$i]}-cnv; done
git checkout $defaultBranch
for i in ${!gitBranches[@]}; do
git branch -m ${gitBranches[$i]}-cnv ${gitBranches[$i]}
git push origin :${gitBranches[$i]}-cnv ${gitBranches[$i]}
git push origin -u ${gitBranches[$i]}
done
#!/bin/bash
repo="/repos/repo"
gitBranchList="./branches_git"
defaultBranch="default"
while read gitBranch; do gitBranches[$i]=${gitBranch}; i=$((i+1)); done < $gitBranchList
cd $repo
for i in ${!gitBranches[@]}; do
git checkout ${gitBranches[$i]}
sed -i '1d' .hgignore
mv .hgignore .gitignore
git add .
git commit -m "Migrated ignore file"
done