x11-themes/gentoo10-backgrounds: Cleanup per bug #85210
[gentoo.git] / eclass / subversion.eclass
1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 # @ECLASS: subversion.eclass
6 # @MAINTAINER:
7 # Akinori Hattori <hattya@gentoo.org>
8 # @AUTHOR:
9 # Original Author: Akinori Hattori <hattya@gentoo.org>
10 # @BLURB: The subversion eclass is written to fetch software sources from subversion repositories
11 # @DESCRIPTION:
12 # The subversion eclass provides functions to fetch, patch and bootstrap
13 # software sources from subversion repositories.
14
15 inherit eutils
16
17 ESVN="${ECLASS}"
18
19 case "${EAPI:-0}" in
20         0|1)
21                 EXPORT_FUNCTIONS src_unpack pkg_preinst
22                 DEPEND="dev-vcs/subversion"
23                 ;;
24         2|3|4|5)
25                 EXPORT_FUNCTIONS src_unpack src_prepare pkg_preinst
26                 DEPEND="|| ( dev-vcs/subversion[http] dev-vcs/subversion[webdav-neon] dev-vcs/subversion[webdav-serf] )"
27                 ;;
28         6)
29                 EXPORT_FUNCTIONS src_unpack pkg_preinst
30                 DEPEND="|| ( dev-vcs/subversion[http] dev-vcs/subversion[webdav-neon] dev-vcs/subversion[webdav-serf] )"
31                 ;;
32         *)
33                 die "EAPI ${EAPI} is not supported in subversion.eclass"
34                 ;;
35 esac
36
37 DEPEND+=" net-misc/rsync"
38
39 # @ECLASS-VARIABLE: ESVN_STORE_DIR
40 # @DESCRIPTION:
41 # subversion sources store directory. Users may override this in /etc/portage/make.conf
42 [[ -z ${ESVN_STORE_DIR} ]] && ESVN_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/svn-src"
43
44 # @ECLASS-VARIABLE: ESVN_FETCH_CMD
45 # @DESCRIPTION:
46 # subversion checkout command
47 ESVN_FETCH_CMD="svn checkout"
48
49 # @ECLASS-VARIABLE: ESVN_UPDATE_CMD
50 # @DESCRIPTION:
51 # subversion update command
52 ESVN_UPDATE_CMD="svn update"
53
54 # @ECLASS-VARIABLE: ESVN_SWITCH_CMD
55 # @DESCRIPTION:
56 # subversion switch command
57 ESVN_SWITCH_CMD="svn switch"
58
59 # @ECLASS-VARIABLE: ESVN_OPTIONS
60 # @DESCRIPTION:
61 # the options passed to checkout or update. If you want a specific revision see
62 # ESVN_REPO_URI instead of using -rREV.
63 ESVN_OPTIONS="${ESVN_OPTIONS:-}"
64
65 # @ECLASS-VARIABLE: ESVN_REPO_URI
66 # @DESCRIPTION:
67 # repository uri
68 #
69 # e.g. http://foo/trunk, svn://bar/trunk, svn://bar/branch/foo@1234
70 #
71 # supported URI schemes:
72 #   http://
73 #   https://
74 #   svn://
75 #   svn+ssh://
76 #   file://
77 #
78 # to peg to a specific revision, append @REV to the repo's uri
79 ESVN_REPO_URI="${ESVN_REPO_URI:-}"
80
81 # @ECLASS-VARIABLE: ESVN_REVISION
82 # @DESCRIPTION:
83 # User configurable revision checkout or update to from the repository
84 #
85 # Useful for live svn or trunk svn ebuilds allowing the user to peg
86 # to a specific revision
87 #
88 # Note: This should never be set in an ebuild!
89 ESVN_REVISION="${ESVN_REVISION:-}"
90
91 # @ECLASS-VARIABLE: ESVN_USER
92 # @DESCRIPTION:
93 # User name
94 ESVN_USER="${ESVN_USER:-}"
95
96 # @ECLASS-VARIABLE: ESVN_PASSWORD
97 # @DESCRIPTION:
98 # Password
99 ESVN_PASSWORD="${ESVN_PASSWORD:-}"
100
101 # @ECLASS-VARIABLE: ESVN_PROJECT
102 # @DESCRIPTION:
103 # project name of your ebuild (= name space)
104 #
105 # subversion eclass will check out the subversion repository like:
106 #
107 #   ${ESVN_STORE_DIR}/${ESVN_PROJECT}/${ESVN_REPO_URI##*/}
108 #
109 # so if you define ESVN_REPO_URI as http://svn.collab.net/repo/svn/trunk or
110 # http://svn.collab.net/repo/svn/trunk/. and PN is subversion-svn.
111 # it will check out like:
112 #
113 #   ${ESVN_STORE_DIR}/subversion/trunk
114 #
115 # this is not used in order to declare the name of the upstream project.
116 # so that you can declare this like:
117 #
118 #   # jakarta commons-loggin
119 #   ESVN_PROJECT=commons/logging
120 #
121 # default: ${PN/-svn}.
122 ESVN_PROJECT="${ESVN_PROJECT:-${PN/-svn}}"
123
124 # @ECLASS-VARIABLE: ESVN_BOOTSTRAP
125 # @DESCRIPTION:
126 # Bootstrap script or command like autogen.sh or etc..
127 # Removed in EAPI 6 and later.
128 ESVN_BOOTSTRAP="${ESVN_BOOTSTRAP:-}"
129
130 # @ECLASS-VARIABLE: ESVN_PATCHES
131 # @DESCRIPTION:
132 # subversion eclass can apply patches in subversion_bootstrap().
133 # you can use regexp in this variable like *.diff or *.patch or etc.
134 # NOTE: patches will be applied before ESVN_BOOTSTRAP is processed.
135 #
136 # Patches are searched both in ${PWD} and ${FILESDIR}, if not found in either
137 # location, the installation dies.
138 #
139 # Removed in EAPI 6 and later, use PATCHES instead.
140 ESVN_PATCHES="${ESVN_PATCHES:-}"
141
142 # @ECLASS-VARIABLE: ESVN_RESTRICT
143 # @DESCRIPTION:
144 # this should be a space delimited list of subversion eclass features to
145 # restrict.
146 #   export)
147 #     don't export the working copy to S.
148 ESVN_RESTRICT="${ESVN_RESTRICT:-}"
149
150 # @ECLASS-VARIABLE: ESVN_OFFLINE
151 # @DESCRIPTION:
152 # Set this variable to a non-empty value to disable the automatic updating of
153 # an svn source tree. This is intended to be set outside the subversion source
154 # tree by users.
155 ESVN_OFFLINE="${ESVN_OFFLINE:-${EVCS_OFFLINE}}"
156
157 # @ECLASS-VARIABLE: ESVN_UMASK
158 # @DESCRIPTION:
159 # Set this variable to a custom umask. This is intended to be set by users.
160 # By setting this to something like 002, it can make life easier for people
161 # who do development as non-root (but are in the portage group), and then
162 # switch over to building with FEATURES=userpriv.  Or vice-versa.  Shouldn't
163 # be a security issue here as anyone who has portage group write access
164 # already can screw the system over in more creative ways.
165 ESVN_UMASK="${ESVN_UMASK:-${EVCS_UMASK}}"
166
167 # @ECLASS-VARIABLE: ESVN_UP_FREQ
168 # @DESCRIPTION:
169 # Set the minimum number of hours between svn up'ing in any given svn module. This is particularly
170 # useful for split KDE ebuilds where we want to ensure that all submodules are compiled for the same
171 # revision. It should also be kept user overrideable.
172 ESVN_UP_FREQ="${ESVN_UP_FREQ:=}"
173
174 # @ECLASS-VARIABLE: ESCM_LOGDIR
175 # @DESCRIPTION:
176 # User configuration variable. If set to a path such as e.g. /var/log/scm any
177 # package inheriting from subversion.eclass will record svn revision to
178 # ${CATEGORY}/${PN}.log in that path in pkg_preinst. This is not supposed to be
179 # set by ebuilds/eclasses. It defaults to empty so users need to opt in.
180 ESCM_LOGDIR="${ESCM_LOGDIR:=}"
181
182 # @FUNCTION: subversion_fetch
183 # @USAGE: [repo_uri] [destination]
184 # @DESCRIPTION:
185 # Wrapper function to fetch sources from subversion via svn checkout or svn update,
186 # depending on whether there is an existing working copy in ${ESVN_STORE_DIR}.
187 #
188 # Can take two optional parameters:
189 #   repo_uri    - a repository URI. default is ESVN_REPO_URI.
190 #   destination - a check out path in S.
191 subversion_fetch() {
192         local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")"
193         local revision="$(subversion__get_peg_revision "${1:-${ESVN_REPO_URI}}")"
194         local S_dest="${2}"
195
196         if [[ -z ${repo_uri} ]]; then
197                 die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty."
198         fi
199
200         [[ -n "${ESVN_REVISION}" ]] && revision="${ESVN_REVISION}"
201
202         # check for the scheme
203         local scheme="${repo_uri%%:*}"
204         case "${scheme}" in
205                 http|https)
206                         ;;
207                 svn|svn+ssh)
208                         ;;
209                 file)
210                         ;;
211                 *)
212                         die "${ESVN}: fetch from '${scheme}' is not yet implemented."
213                         ;;
214         esac
215
216         addread "/etc/subversion"
217         addwrite "${ESVN_STORE_DIR}"
218
219         if [[ -n "${ESVN_UMASK}" ]]; then
220                 eumask_push "${ESVN_UMASK}"
221         fi
222
223         if [[ ! -d ${ESVN_STORE_DIR} ]]; then
224                 debug-print "${FUNCNAME}: initial checkout. creating subversion directory"
225                 mkdir -m 775 -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}."
226         fi
227
228         pushd "${ESVN_STORE_DIR}" >/dev/null || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}"
229
230         local wc_path="$(subversion__get_wc_path "${repo_uri}")"
231         local options="${ESVN_OPTIONS} --config-dir ${ESVN_STORE_DIR}/.subversion"
232
233         [[ -n "${revision}" ]] && options="${options} -r ${revision}"
234
235         if [[ "${ESVN_OPTIONS}" = *-r* ]]; then
236                 ewarn "\${ESVN_OPTIONS} contains -r, this usage is unsupported. Please"
237                 ewarn "see \${ESVN_REPO_URI}"
238         fi
239
240         if has_version ">=dev-vcs/subversion-1.6.0"; then
241                 options="${options} --config-option=config:auth:password-stores="
242         fi
243
244         debug-print "${FUNCNAME}: wc_path = \"${wc_path}\""
245         debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\""
246         debug-print "${FUNCNAME}: options = \"${options}\""
247
248         if [[ ! -d ${wc_path}/.svn ]]; then
249                 if [[ -n ${ESVN_OFFLINE} ]]; then
250                         ewarn "ESVN_OFFLINE cannot be used when there is no existing checkout."
251                 fi
252                 # first check out
253                 einfo "subversion check out start -->"
254                 einfo "     repository: ${repo_uri}${revision:+@}${revision}"
255
256                 debug-print "${FUNCNAME}: ${ESVN_FETCH_CMD} ${options} ${repo_uri}"
257
258                 mkdir -m 775 -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
259                 cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}"
260                 if [[ -n "${ESVN_USER}" ]]; then
261                         ${ESVN_FETCH_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" "${repo_uri}" || die "${ESVN}: can't fetch to ${wc_path} from ${repo_uri}."
262                 else
263                         ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch to ${wc_path} from ${repo_uri}."
264                 fi
265
266         elif [[ -n ${ESVN_OFFLINE} ]]; then
267                 svn upgrade "${wc_path}" &>/dev/null
268                 svn cleanup "${wc_path}" &>/dev/null
269                 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy."
270
271                 if [[ -n ${ESVN_REVISION} && ${ESVN_REVISION} != ${ESVN_WC_REVISION} ]]; then
272                         die "${ESVN}: You requested off-line updating and revision ${ESVN_REVISION} but only revision ${ESVN_WC_REVISION} is available locally."
273                 fi
274                 einfo "Fetching disabled: Using existing repository copy at revision ${ESVN_WC_REVISION}."
275         else
276                 svn upgrade "${wc_path}" &>/dev/null
277                 svn cleanup "${wc_path}" &>/dev/null
278                 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy."
279
280                 local esvn_up_freq=
281                 if [[ -n ${ESVN_UP_FREQ} ]]; then
282                         if [[ -n ${ESVN_UP_FREQ//[[:digit:]]} ]]; then
283                                 die "${ESVN}: ESVN_UP_FREQ must be an integer value corresponding to the minimum number of hours between svn up."
284                         elif [[ -z $(find "${wc_path}/.svn/entries" -mmin "+$((ESVN_UP_FREQ*60))") ]]; then
285                                 einfo "Fetching disabled since ${ESVN_UP_FREQ} hours has not passed since last update."
286                                 einfo "Using existing repository copy at revision ${ESVN_WC_REVISION}."
287                                 esvn_up_freq=no_update
288                         fi
289                 fi
290
291                 if [[ -z ${esvn_up_freq} ]]; then
292                         if [[ ${ESVN_WC_UUID} != $(subversion__svn_info "${repo_uri}" "Repository UUID") ]]; then
293                                 # UUID mismatch. Delete working copy and check out it again.
294                                 einfo "subversion recheck out start -->"
295                                 einfo "     old UUID: ${ESVN_WC_UUID}"
296                                 einfo "     new UUID: $(subversion__svn_info "${repo_uri}" "Repository UUID")"
297                                 einfo "     repository: ${repo_uri}${revision:+@}${revision}"
298
299                                 rm -fr "${ESVN_PROJECT}" || die
300
301                                 debug-print "${FUNCNAME}: ${ESVN_FETCH_CMD} ${options} ${repo_uri}"
302
303                                 mkdir -m 775 -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
304                                 cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}"
305                                 if [[ -n "${ESVN_USER}" ]]; then
306                                         ${ESVN_FETCH_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" "${repo_uri}" || die "${ESVN}: can't fetch to ${wc_path} from ${repo_uri}."
307                                 else
308                                         ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch to ${wc_path} from ${repo_uri}."
309                                 fi
310                         elif [[ ${ESVN_WC_URL} != $(subversion__get_repository_uri "${repo_uri}") ]]; then
311                                 einfo "subversion switch start -->"
312                                 einfo "     old repository: ${ESVN_WC_URL}@${ESVN_WC_REVISION}"
313                                 einfo "     new repository: ${repo_uri}${revision:+@}${revision}"
314
315                                 debug-print "${FUNCNAME}: ${ESVN_SWITCH_CMD} ${options} ${repo_uri}"
316
317                                 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
318                                 if [[ -n "${ESVN_USER}" ]]; then
319                                         ${ESVN_SWITCH_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" ${repo_uri} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
320                                 else
321                                         ${ESVN_SWITCH_CMD} ${options} ${repo_uri} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
322                                 fi
323                         else
324                                 # update working copy
325                                 einfo "subversion update start -->"
326                                 einfo "     repository: ${repo_uri}${revision:+@}${revision}"
327
328                                 debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}"
329
330                                 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
331                                 if [[ -n "${ESVN_USER}" ]]; then
332                                         ${ESVN_UPDATE_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
333                                 else
334                                         ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
335                                 fi
336                         fi
337
338                         # export updated information for the working copy
339                         subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy."
340                 fi
341         fi
342
343         if [[ -n "${ESVN_UMASK}" ]]; then
344                 eumask_pop
345         fi
346
347         einfo "   working copy: ${wc_path}"
348
349         if ! has "export" ${ESVN_RESTRICT}; then
350                 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
351
352                 local S="${S}/${S_dest}"
353                 mkdir -p "${S}"
354
355                 # export to the ${WORKDIR}
356                 #*  "svn export" has a bug.  see https://bugs.gentoo.org/119236
357                 #* svn export . "${S}" || die "${ESVN}: can't export to ${S}."
358                 rsync -rlpgo --exclude=".svn/" . "${S}" || die "${ESVN}: can't export to ${S}."
359         fi
360
361         popd >/dev/null
362         echo
363 }
364
365 # @FUNCTION: subversion_bootstrap
366 # @DESCRIPTION:
367 # Apply patches in ${ESVN_PATCHES} and run ${ESVN_BOOTSTRAP} if specified.
368 # Removed in EAPI 6 and later.
369 subversion_bootstrap() {
370         [[ ${EAPI} == [012345] ]] || die "${FUNCNAME[1]} is removed from subversion.eclass in EAPI 6 and later"
371
372         if has "export" ${ESVN_RESTRICT}; then
373                 return
374         fi
375
376         cd "${S}"
377
378         if [[ -n ${ESVN_PATCHES} ]]; then
379                 local patch fpatch
380                 einfo "apply patches -->"
381                 for patch in ${ESVN_PATCHES}; do
382                         if [[ -f ${patch} ]]; then
383                                 epatch "${patch}"
384                         else
385                                 for fpatch in ${FILESDIR}/${patch}; do
386                                         if [[ -f ${fpatch} ]]; then
387                                                 epatch "${fpatch}"
388                                         else
389                                                 die "${ESVN}: ${patch} not found"
390                                         fi
391                                 done
392                         fi
393                 done
394                 echo
395         fi
396
397         if [[ -n ${ESVN_BOOTSTRAP} ]]; then
398                 einfo "begin bootstrap -->"
399                 if [[ -f ${ESVN_BOOTSTRAP} && -x ${ESVN_BOOTSTRAP} ]]; then
400                         einfo "   bootstrap with a file: ${ESVN_BOOTSTRAP}"
401                         eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP."
402                 else
403                         einfo "   bootstrap with command: ${ESVN_BOOTSTRAP}"
404                         eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP."
405                 fi
406         fi
407 }
408
409 # @FUNCTION: subversion_wc_info
410 # @USAGE: [repo_uri]
411 # @RETURN: ESVN_WC_URL, ESVN_WC_ROOT, ESVN_WC_UUID, ESVN_WC_REVISION and ESVN_WC_PATH
412 # @DESCRIPTION:
413 # Get svn info for the specified repo_uri. The default repo_uri is ESVN_REPO_URI.
414 #
415 # The working copy information on the specified repository URI are set to
416 # ESVN_WC_* variables.
417 subversion_wc_info() {
418         local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")"
419         local wc_path="$(subversion__get_wc_path "${repo_uri}")"
420
421         debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
422         debug-print "${FUNCNAME}: wc_path = ${wc_path}"
423
424         if [[ ! -d ${wc_path} ]]; then
425                 return 1
426         fi
427
428         export ESVN_WC_URL="$(subversion__svn_info "${wc_path}" "URL")"
429         export ESVN_WC_ROOT="$(subversion__svn_info "${wc_path}" "Repository Root")"
430         export ESVN_WC_UUID="$(subversion__svn_info "${wc_path}" "Repository UUID")"
431         export ESVN_WC_REVISION="$(subversion__svn_info "${wc_path}" "Revision")"
432         export ESVN_WC_PATH="${wc_path}"
433 }
434
435 # @FUNCTION: subversion_src_unpack
436 # @DESCRIPTION:
437 # Default src_unpack. Fetch and, in older EAPIs, bootstrap.
438 subversion_src_unpack() {
439         subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch."
440         if has "${EAPI:-0}" 0 1; then
441                 subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap."
442         fi
443 }
444
445 # @FUNCTION: subversion_src_prepare
446 # @DESCRIPTION:
447 # Default src_prepare. Bootstrap.
448 # Removed in EAPI 6 and later.
449 subversion_src_prepare() {
450         [[ ${EAPI} == [012345] ]] || die "${FUNCNAME[1]} is removed from subversion.eclass in EAPI 6 and later"
451         subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap."
452 }
453
454 # @FUNCTION: subversion_pkg_preinst
455 # @USAGE: [repo_uri]
456 # @DESCRIPTION:
457 # Log the svn revision of source code. Doing this in pkg_preinst because we
458 # want the logs to stick around if packages are uninstalled without messing with
459 # config protection.
460 subversion_pkg_preinst() {
461         has "${EAPI:-0}" 0 1 2 && ! use prefix && EROOT="${ROOT}"
462         local pkgdate=$(date "+%Y%m%d %H:%M:%S")
463         if [[ -n ${ESCM_LOGDIR} ]]; then
464                 local dir="${EROOT}/${ESCM_LOGDIR}/${CATEGORY}"
465                 if [[ ! -d ${dir} ]]; then
466                         mkdir -p "${dir}" || eerror "Failed to create '${dir}' for logging svn revision"
467                 fi
468                 local logmessage="svn: ${pkgdate} - ${PF}:${SLOT} was merged at revision ${ESVN_WC_REVISION}"
469                 if [[ -d ${dir} ]]; then
470                         echo "${logmessage}" >>"${dir}/${PN}.log"
471                 else
472                         eerror "Could not log the message '${logmessage}' to '${dir}/${PN}.log'"
473                 fi
474         fi
475 }
476
477 ## -- Private Functions
478
479 ## -- subversion__svn_info() ------------------------------------------------- #
480 #
481 # param $1 - a target.
482 # param $2 - a key name.
483 #
484 subversion__svn_info() {
485         local target="${1}"
486         local key="${2}"
487
488         env LC_ALL=C svn info ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" "${target}" \
489                 | grep -i "^${key}" \
490                 | cut -d" " -f2-
491 }
492
493 ## -- subversion__get_repository_uri() --------------------------------------- #
494 #
495 # param $1 - a repository URI.
496 subversion__get_repository_uri() {
497         local repo_uri="${1}"
498
499         debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
500         if [[ -z ${repo_uri} ]]; then
501                 die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty."
502         fi
503         # delete trailing slash
504         if [[ -z ${repo_uri##*/} ]]; then
505                 repo_uri="${repo_uri%/}"
506         fi
507         repo_uri="${repo_uri%@*}"
508
509         echo "${repo_uri}"
510 }
511
512 ## -- subversion__get_wc_path() ---------------------------------------------- #
513 #
514 # param $1 - a repository URI.
515 subversion__get_wc_path() {
516         local repo_uri="$(subversion__get_repository_uri "${1}")"
517
518         debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
519
520         echo "${ESVN_STORE_DIR}/${ESVN_PROJECT}/${repo_uri##*/}"
521 }
522
523 ## -- subversion__get_peg_revision() ----------------------------------------- #
524 #
525 # param $1 - a repository URI.
526 subversion__get_peg_revision() {
527         local repo_uri="${1}"
528         local peg_rev=
529
530         debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
531         # repo_uri has peg revision?
532         if [[ ${repo_uri} = *@* ]]; then
533                 peg_rev="${repo_uri##*@}"
534                 debug-print "${FUNCNAME}: peg_rev = ${peg_rev}"
535         else
536                 debug-print "${FUNCNAME}: repo_uri does not have a peg revision."
537         fi
538
539         echo "${peg_rev}"
540 }