-# 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"
+# Return the substitution key/values in arrays:
+# SUBPATHS_KEY
+# SUBPATHS_VAL
+# SUBPATHS_COUNT will be greater than zero if any substitutions were found.
+hg_parse_subpaths() {
+ subpaths=$(hg showconfig subpaths)
+
+ if [ -n "${subpaths}" ]; then
+ for p in ${subpaths}; do
+ local key=$(echo ${p} | sed 's/^subpaths\.\(.*\)=.*/\1/')
+ local val=$(echo ${p} | sed 's/.*=\(.*\)/\1/')
+
+ # Replace '\\' with '/'
+ key=${key//\\\\/\/}
+ # ^^ replace multiple times
+
+ val=${val//\\\\/\/}
+
+ SUBPATHS_KEY[${SUBPATHS_COUNT}]="${key}"
+ SUBPATHS_VAL[${SUBPATHS_COUNT}]="${val}"
+
+ if [ -n "${debug}" ]; then
+ echo "Parsing SUBPATHS entry: ${p}"
+ echo " key: ${key}"
+ echo " val: ${val}"
+ fi
+
+ SUBPATHS_COUNT=$((SUBPATHS_COUNT + 1))
+ done