--- subversion.eclass.orig 2008-01-15 12:51:46.000000000 -0600 +++ subversion.eclass 2008-01-15 12:53:20.000000000 -0600 @@ -175,8 +175,34 @@ subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy." else subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy." + ESVN_WC_UUID="$(subversion__svn_info "${ESVN_WC_URL}" "Repository UUID")" + ESVN_REPO_UUID="$(subversion__svn_info "${repo_uri}" "Repository UUID")" + if [ "${ESVN_WC_REPOSITORY_UUID}" != "$(subversion__svn_info "${repo_uri}" "Repository UUID")" ] ; then + einfo "ESVN_REPO_URI (or specified URI) and working copy's URL refer to different repositories; deleting the existing working copy and starting over" + rm -rf "${wc_path}" || die "${ESVN}: unable to clear bad working copy" + subversion_fetch "$@"; return "$?" + fi + if [ "${ESVN_WC_REPOSITORY_ROOT}" != "$(subversion__svn_info "${repo_uri}" "Repository Root")" ] ; then + einfo "Repository root has moved; relocating..." + env LC_ALL=C svn switch --relocate \ + "${ESVN_WC_REPOSITORY_ROOT}" \ + "$(subversion__svn_info "${repo_uri}" "Repository Root")" \ + "${wc_path}" \ + || die "unable to relocate working copy ${wc_path} from repository ${ESVN_WC_REPOSITORY_ROOT} to $(subversion__svn_info "${repo_uri}" "Repository Root")" + subversion_wc_info "${repo_uri}" || die "error while refreshing our view of working copy state" + fi + if [ "${ESVN_WC_URL}" != "$(subversion__get_repository_uri "${repo_uri}" 1)" ] ; then + einfo "URI has moved within the repository; switching..." + env LC_ALL=C svn switch \ + "$(subversion__get_repository_uri "${repo_uri}" 1)" \ + "${wc_path}" \ + || die "unable to relocate working copy ${wc_path} from ${ESVN_WC_URL} to $(subversion__get_repository_uri "${repo_uri}" 1)" + subversion_wc_info "${repo_uri}" || die "error while refreshing our view of working copy state" + fi if [ "${ESVN_WC_URL}" != "$(subversion__get_repository_uri "${repo_uri}" 1)" ]; then - die "${ESVN}: ESVN_REPO_URI (or specified URI) and working copy's URL are not matched." + einfo "Attempts to update the current working copy have failed; deleting ${wc_path} and starting over..." + rm -rf "${wc_path}" || die "${ESVN}: unable to clear bad working copy" + subversion_fetch "$@"; return "$?" fi # update working copy @@ -272,8 +298,8 @@ fi local k - for k in url revision; do - export ESVN_WC_$(subversion__to_upper_case "${k}")="$(subversion__svn_info "${wc_path}" "${k}")" + for k in url revision "Repository Root" "Repository UUID"; do + export ESVN_WC_$(subversion__to_varname "${k}")="$(subversion__svn_info "${wc_path}" "${k}")" done } @@ -289,7 +315,7 @@ local target="${1}" local key="${2}" - env LC_ALL=C svn info "${target}" | grep -i "^${key}" | cut -d" " -f2- + env LC_ALL=C svn info "${target}" | grep -i "^${key}" | sed -r -e "s@[^:]+: +@@" } @@ -315,6 +341,10 @@ repo_uri="${repo_uri%/}" fi + # delete any duplicate slashes past the first instance + local repo_uri_tmp="${repo_uri//\/\///}" + repo_uri="${repo_uri_tmp/\////}" + if [[ -n "${remove_peg_revision}" ]]; then if subversion__has_peg_revision "${repo_uri}"; then repo_uri="${repo_uri%@*}" @@ -384,5 +414,14 @@ # @param $@ - the strings to upper case. # function subversion__to_upper_case() { - echo "${@}" | tr "[a-z]" "[A-Z]" + echo "${@}" | tr "[:lower:]" "[:upper:]" +} + + +## -- subversion__to_varname() -------------------------------------------- # +# +# @param $@ - the strings to convert to suitable form for variable names +# +function subversion__to_varname() { + echo "${@}" | tr "[[:lower:] ]" "[[:upper:]_]" }