Currently, svnmerge uses repository URL's in its branch metadata. That
scheme won't work when you have multiple repository access methods, or
find yourself moving your repository.
This patch has svnmerge use repository-local paths instead of URL's.
Graceful upgrades from the old scheme are supported, assuming that the
URL is still valid.
-John
Index: svnmerge
===================================================================
--- svnmerge (revision 12634)
+++ svnmerge (working copy)
@@ -316,6 +316,36 @@
RETURN_VALUE="${TEMP}"
}
+# Subroutine to convert working copy path or repo URL $1 to a repo URL
+target_to_url()
+{
+ if [ -d "$1" -a -d "$1/.svn" ]; then
+ RETURN_VALUE=`"${SVN_MERGE_SVN}" info "$1" \
+ | grep ^URL: | sed -e 's/^URL: \(.*\)$/\1/g'`
+ else
+ RETURN_VALUE="$1"
+ fi
+}
+
+# Subroutine to compute the root repo URL given wc path or repo URL $1.
+# Constrained to svn command line tools, we are stuck with this ugly trial-
+# and-error implementation. It could be made faster with a binary search.
+get_repo_root()
+{
+ target_to_url "$1"
+ while TEMP=`dirname ${RETURN_VALUE}` &&
+ "${SVN_MERGE_SVN}" proplist "${TEMP}" >/dev/null 2>&1; do
+ RETURN_VALUE="${TEMP}"
+ done
+}
+
+# Subroutine to convert repo URL $1 to a repo-local path
+url_to_rlpath()
+{
+ get_repo_root $1
+ RETURN_VALUE="${1#${RETURN_VALUE}}"
+}
+
# The "init" action
init()
{
@@ -337,7 +367,7 @@
# Set properties
svn_command propset -q "${SVN_MERGE_HEAD_PROP}" \
- "${HEAD_URL}" "${BRANCH_DIR}"
+ "${HEAD_RLPATH}" "${BRANCH_DIR}"
svn_command propset -q "${SVN_MERGE_REVS_PROP}" \
"${REVS}" "${BRANCH_DIR}"
@@ -433,7 +463,7 @@
if [ "${SVN_MERGE_COMMIT_FILE}" != "" ]; then
echo "Merged revisions ${BREVS} via ${NAME} from" \
> "${SVN_MERGE_COMMIT_FILE}"
- echo "${HEAD_URL}" >> "${SVN_MERGE_COMMIT_FILE}"
+ echo "${HEAD_RLPATH}" >> "${SVN_MERGE_COMMIT_FILE}"
report wrote commit message to "${SVN_MERGE_COMMIT_FILE}"
fi
@@ -583,12 +613,10 @@
# In the --init case, convert ${HEAD} into ${HEAD_URL}
if [ "${ACTION}" = "init" ]; then
- if [ -d "${HEAD}" -a -d "${HEAD}/.svn" ]; then
- HEAD_URL=`"${SVN_MERGE_SVN}" info "${HEAD}" \
- | grep ^URL: | sed -e 's/^URL: \(.*\)$/\1/g'`
- else
- HEAD_URL="${HEAD}"
- fi
+ target_to_url "${HEAD}"
+ HEAD_URL="${RETURN_VALUE}"
+ url_to_rlpath "${HEAD_URL}"
+ HEAD_RLPATH="${RETURN_VALUE}"
fi
# Determine which label to use
@@ -626,7 +654,20 @@
# If already initialized, retrieve ${HEAD_URL} from the corresponding property
if [ "${ACTION}" != "init" ]; then
get_prop "${SVN_MERGE_HEAD_PROP}" "${BRANCH_DIR}"
- HEAD_URL="${RETURN_VALUE}"
+ HEAD_RLPATH="${RETURN_VALUE}"
+ # handle old metadata scheme which used repository URL's
+ if echo "${HEAD_RLPATH}" | grep -qE '^[[:alpha:]][-+.[:alnum:]]*://'; then
+ echo "${NAME}: old head property value detected; an upgrade is required."
+ echo
+ url_to_rlpath "${HEAD_RLPATH}"
+ echo "Please execute and commit this change to upgrade:"
+ echo
+ echo " svn propset ${SVN_MERGE_HEAD_PROP} ${RETURN_VALUE} ${BRANCH_DIR}"
+ echo
+ exit 1
+ fi
+ get_repo_root "${BRANCH_DIR}"
+ HEAD_URL="${RETURN_VALUE}${HEAD_RLPATH}"
fi
# Sanity check ${HEAD_URL}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Jan 9 06:30:40 2005