-# git-remote-hg doesn't work with Mercurial subpaths extension,
-# so use it manually
-hg_subpaths_config() {
- subpaths=$(hg showconfig | grep "subpaths" | grep "HG_REPO")
-
- echo "subpaths = ${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
-}
-
-# git-remote-hg doesn't work with Mercurial projrc extension,
-# so use it manually.
-# We parse the projrc file in the assembly (on the server), to check
-# for any projrc substitutions.
-#
-# Arg 1: subproject (path and name)
-#
-# Return the new substitution name if found, and original subrepo name if not
-# (with the path stripped)
-hg_check_projrc_config() {
- if [ ${#} -lt 1 ]; then
- echo "Missing subrepos name"
- fi
-
- # Repo name can have spaces in it, hence the use of ${*}
- local subrepo_orig="${*}"
- local subrepo="${*}"
-
- # Quote spaces
- subrepo=${subrepo// /\\\\ }
-
- asm=$(cat .git/config | grep "hg::" | sed "s/.*url = hg::\(.*\)/\1/")
-
- local baserepo=$(basename "${subrepo}")
-
- if cat "${asm}/.hg/projrc" | grep -q "${baserepo}" ; then
- projrc=$(cat "${asm}/.hg/projrc" | grep "${baserepo}" | sed "s/.*= \(.*\)/\1/")
- else
- # No substitution, return same name as original
- projrc=$(basename "${subrepo_orig}")
- fi
-
- echo "${projrc}"
-}
-
-# 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
-}
-