From: Hugo Villeneuve Date: Thu, 20 Mar 2014 13:22:03 +0000 (-0400) Subject: Fix bug with multiple subpaths entries X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=383e625e4defb96cd77756cc7426932a5a825643;p=hvutilities.git Fix bug with multiple subpaths entries --- diff --git a/scripts/git-hg-sub-import b/scripts/git-hg-sub-import index 41617d1..cf2b44f 100755 --- a/scripts/git-hg-sub-import +++ b/scripts/git-hg-sub-import @@ -5,7 +5,7 @@ set -o errexit # http://felipec.wordpress.com/2012/11/13/git-remote-hg-bzr-2/ # Uncomment to have verbose debug output -#debug=1 +debug=1 print_usage() { @@ -16,7 +16,9 @@ print_usage() # git-remote-hg doesn't work with Mercurial subpaths extension, # so use it manually hg_subpaths_config() { - subpaths=$(hg showconfig | grep "subpaths") + subpaths=$(hg showconfig | grep "subpaths" | grep "HG_REPO") + + echo "subpaths = ${subpaths}" if [ -n ${subpaths} ]; then sp_src=${subpaths//subpaths./} @@ -118,11 +120,22 @@ while read sub; do # "BRANCH___-___NAME" branch="${branch// /___}" + if [ -n "${debug}" ]; then + echo "branch: ${branch}" + fi + git clone "hg::${src}" "${dest}" + cd "${dest}" + + if [ -x ${HOME}/scripts/git-set-local-author.sh ]; then + # Make sure commits have correct author for LSI + ${HOME}/scripts/git-set-local-author.sh + fi + if [ "x${branch}" != "xdefault" ]; then - cd "${dest}" - git checkout "branches/${branch}" + # Make tracking branch + git checkout -f "branches/${branch}" # Adjusting git tree to specific commit specified in # .hgsubstate: @@ -131,10 +144,10 @@ while read sub; do # to a hash in git using the ${num} variable: git_rev=$(git log --oneline | sed -n "${num}p" | awk '{print $1}') git reset --hard ${git_rev} - - cd .. fi + cd .. + if ! grep -q "${dest}" .gitignore ; then # Ignore subrepo in top-level git repository echo "${dest}" >> .gitignore