Hi,

bzr.eclass currently uses "bzr export" for copying from
${DISTDIR}/bzr-src to ${WORKDIR} in src_unpack. Unfortunately,
"bzr export" accesses the remote repository for lightweight checkouts
(which are the eclass's default), so it cannot be used off-line.

Besides, it is very slow: In my test (GNU Emacs BZR repo, 2 Mbit/s
connection) bzr export took 54 minutes, whereas the initial checkout
took only 11 minutes.

The patch included below fixes this problem by using "rsync" instead
of "bzr export" in most cases. Additionally, a problem with updating
of non-lightweight checkouts is fixed, and restoring of the
SANDBOX_WRITE variable is made more robust.

Please review.

Ulrich


--- bzr.eclass  9 Dec 2009 10:04:16 -0000       1.6
+++ bzr.eclass  14 Dec 2009 20:54:27 -0000
@@ -189,10 +189,11 @@
 
        if [[ ! -d ${EBZR_STORE_DIR} ]] ; then
                debug-print "${FUNCNAME}: initial branch. Creating bzr 
directory"
+               local save_sandbox_write=${SANDBOX_WRITE}
                addwrite /
                mkdir -p "${EBZR_STORE_DIR}" \
                        || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}."
-               export SANDBOX_WRITE="${SANDBOX_WRITE%%:/}"
+               SANDBOX_WRITE=${save_sandbox_write}
        fi
 
        pushd "${EBZR_STORE_DIR}" > /dev/null || die "${EBZR}: can't chdir to 
${EBZR_STORE_DIR}"
@@ -209,7 +210,8 @@
        # an older version of bzr.eclass)
        if [[ ! -d ${EBZR_BRANCH_DIR} ]] ; then
                bzr_initial_fetch "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}"
-       elif [[ -d "${EBZR_BRANCH_DIR}"/.bzr/repository/ ]]; then
+       elif [[ ${EBZR_FETCH_CMD} == *lightweight* \
+               && -d ${EBZR_BRANCH_DIR}/.bzr/repository ]]; then
                einfo "Re-fetching the branch to save space..."
                rm -rf "${EBZR_BRANCH_DIR}"
                bzr_initial_fetch "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}"
@@ -220,18 +222,18 @@
        cd "${EBZR_BRANCH_DIR}"
 
        einfo "exporting ..."
-       ${EBZR_EXPORT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} 
"${WORKDIR}/${P}" \
-                       || die "${EBZR}: export failed"
 
-       local revision
-       if [[ -n "${EBZR_REVISION}" ]]; then
-               revision="${EBZR_REVISION}"
-       else
-               revision=$(${EBZR_REVNO_CMD} "${EBZR_BRANCH_DIR}")
+       if [[ -z ${EBZR_REVISION} ]]; then
+               rsync -rlpgo --exclude=".bzr/" . "${WORKDIR}/${P}" \
+                       || die "${EBZR}: export failed"
+       else
+               # revisions of a lightweight checkout are only available when 
online
+               [[ -z ${EBZR_OFFLINE} || -d ${EBZR_BRANCH_DIR}/.bzr/repository 
]] \
+                       || die "${EBZR}: No support for revisions when off-line"
+               ${EBZR_EXPORT_CMD} -r "${EBZR_REVISION}" "${WORKDIR}/${P}" \
+                       || die "${EBZR}: export failed"
        fi
 
-       einfo "Revision ${revision} is now in ${WORKDIR}/${P}"
-
        popd > /dev/null
 }
 

Reply via email to