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