X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=scripts%2Fgit-hg-sub-import;h=41617d1058c81431031f3ff655d9edf5c522bbad;hb=20cb6a4a1b260f18c0cc1414431080ecab3f3da4;hp=ecd7757ac0381573e98c79b354e3895190e5de94;hpb=a3d197ba5982637e448f1f89201bca4d99e01602;p=hvutilities.git diff --git a/scripts/git-hg-sub-import b/scripts/git-hg-sub-import index ecd7757..41617d1 100755 --- a/scripts/git-hg-sub-import +++ b/scripts/git-hg-sub-import @@ -24,8 +24,10 @@ hg_subpaths_config() { sp_src=${sp_src//\\/} # Remove windows separator (LSI) sp_dst=${subpaths//*=/} - echo "sp_src = $sp_src" - echo "sp_dst = $sp_dst" + if [ -n "${debug}" ]; then + echo "sp_src = $sp_src" + echo "sp_dst = $sp_dst" + fi fi } @@ -41,7 +43,7 @@ subrepo_find_branch() { local id="${2}" local rev="${3}" - pushd "${src}" + pushd "${src}" 1> /dev/null branch=$(hg log -r ${rev} | grep "branch:" | sed "s/branch:\ *//") @@ -50,11 +52,15 @@ subrepo_find_branch() { branch=default fi + num=$(hg log --branch "${branch}" --template '{node}\n' | \ + grep -n ${rev} | awk -F ':' '{print $1}') + if [ -n "${debug}" ]; then echo " branch: ${branch}" + echo " num: ${num}" fi - popd + popd 1> /dev/null } if [ "x${1}" = "x--help" ]; then @@ -118,9 +124,13 @@ while read sub; do cd "${dest}" git checkout "branches/${branch}" - # This does not work: the SHA from hg and git - # are not the same... - #git reset --hard ${rev} + # Adjusting git tree to specific commit specified in + # .hgsubstate: + # The SHA from hg and git are not the same, therefore, we must + # find the commit sequence in hg and map this + # 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 @@ -129,10 +139,6 @@ while read sub; do # Ignore subrepo in top-level git repository echo "${dest}" >> .gitignore fi - else - pushd "${dest}" - git pull - popd fi fi done < .hgsub