From 709ea4d8cc259f539f04830fabb7fd481d04cc7b Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Fri, 28 Jun 2013 16:05:21 -0400 Subject: [PATCH] git-hg-sub-import: Ajuste le repository git au commit dans .hgsubstate MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Façon détournée de faire les choses pour l'instant, car les hash de Mercurial et de git sont différents. --- scripts/git-hg-sub-import | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/git-hg-sub-import b/scripts/git-hg-sub-import index ecd7757..64b1035 100755 --- a/scripts/git-hg-sub-import +++ b/scripts/git-hg-sub-import @@ -50,8 +50,12 @@ 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 @@ -118,9 +122,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 -- 2.20.1