X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=scripts%2Fgit-hg-sub-update;h=c381546a483f4e918deb7d0e8252be2d17ec5b45;hb=788d9df6ef70a92e2569e0c659a52a639700af62;hp=897fb0afe1551baf646440c49187c1eefc8f4cee;hpb=8b8f7b3fa5ba9b4d9bf8bfa5261d537279f8d091;p=hvutilities.git diff --git a/scripts/git-hg-sub-update b/scripts/git-hg-sub-update index 897fb0a..c381546 100755 --- a/scripts/git-hg-sub-update +++ b/scripts/git-hg-sub-update @@ -1,6 +1,10 @@ #!/bin/bash set -o errexit +SCRIPT="`readlink -e $0`" +SCRIPTPATH=$(dirname ${SCRIPT}) +source ${SCRIPTPATH}/hv-hg-functions.sh + # for use with git-remote-hg: # http://felipec.wordpress.com/2012/11/13/git-remote-hg-bzr-2/ @@ -13,56 +17,6 @@ print_usage() echo "Usage: $(basename $0) [OPTIONS...]" } -# git-remote-hg doesn't work with Mercurial subpaths extension, -# so use it manually -hg_subpaths_config() { - subpaths=$(hg showconfig | grep "subpaths") - - if [ -n ${subpaths} ]; then - sp_src=${subpaths//subpaths./} - sp_src=${sp_src//=*/} - sp_src=${sp_src//\\/} # Remove windows separator (LSI) - sp_dst=${subpaths//*=/} - - if [ -n "${debug}" ]; then - echo "sp_src = $sp_src" - echo "sp_dst = $sp_dst" - fi - fi -} - -# Map a revision to a branch name in HG subrepository -# Use hg log (in original repo) to get branch name corresponding to that -# revision. -# -# Arg 1: subrepository URL -# Arg 2: id -# Arg 3: revision -subrepo_find_branch() { - local src="${1}" - local id="${2}" - local rev="${3}" - - pushd "${src}" 1> /dev/null - - branch=$(hg log -r ${rev} | grep "branch:" | sed "s/branch:\ *//") - - if [ -z "${branch}" ]; then - # If "branch:" is null, this indicate we are on the default 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 1> /dev/null -} - if [ "x${1}" = "x--help" ]; then print_usage exit 1