public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Ulrich Mueller <ulm@gentoo.org>
To: <gentoo-dev@lists.gentoo.org>
Subject: [gentoo-dev] bzr.eclass changes, please review
Date: Fri, 14 Sep 2012 11:01:01 +0200	[thread overview]
Message-ID: <20562.62029.425431.864386@a1i15.kph.uni-mainz.de> (raw)

In bug 434746 it has been suggested that ${WORKDIR} should look like a
bzr branch or checkout. Proposed changes for bzr.eclass are included
below, comprising the following:

- bzr_fetch can optionally call bzr checkout --lightweight instead of
  bzr export. The default behaviour won't change, the new behaviour
  can be enabled with:
- New variable EBZR_WORKDIR_CHECKOUT, (Or can anyone come up with a
  better/shorter name?)
- New variable EBZR_CHECKOUT_CMD.
- The sandbox environment is now always restored; before it was only
  restored if ${EBZR_STORE_DIR} didn't exist. This is to prevent the
  package's build system from writing to ${EBZR_STORE_DIR} when it's
  calling bzr (which wasn't an issue for an export, but could be for
  a checkout).
- Unrelated to the above, some old cleanup code (around line 220) is
  removed.

The updated bzr.eclass is available in the emacs overlay, along with
an app-editors/emacs-vcs ebuild that I've used for testing.

Ulrich


--- bzr.eclass	18 Jul 2012 15:12:54 -0000	1.18
+++ bzr.eclass	14 Sep 2012 08:02:08 -0000
@@ -61,6 +61,11 @@
 # The Bazaar command to export a branch.
 : ${EBZR_EXPORT_CMD:="bzr export"}
 
+# @ECLASS-VARIABLE: EBZR_CHECKOUT_CMD
+# @DESCRIPTION:
+# The Bazaar command to checkout a branch.
+: ${EBZR_CHECKOUT_CMD:="bzr checkout --lightweight -q"}
+
 # @ECLASS-VARIABLE: EBZR_REVNO_CMD
 # @DESCRIPTION:
 # The Bazaar command to list a revision number of the branch.
@@ -145,6 +150,12 @@
 # by users.
 : ${EBZR_OFFLINE=${EVCS_OFFLINE}}
 
+# @ECLASS-VARIABLE: EBZR_WORKDIR_CHECKOUT
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# If this variable is set to a non-empty value, EBZR_CHECKOUT_CMD will
+# be used instead of EBZR_EXPORT_CMD to copy the sources to WORKDIR.
+
 # @FUNCTION: bzr_initial_fetch
 # @USAGE: <repository URI> <branch directory>
 # @DESCRIPTION:
@@ -196,11 +207,11 @@
 # working copy.
 bzr_fetch() {
 	local repo_dir branch_dir
+	local save_sandbox_write=${SANDBOX_WRITE}
 
 	[[ -n ${EBZR_REPO_URI} ]] || die "${EBZR}: EBZR_REPO_URI is empty"
 
 	if [[ ! -d ${EBZR_STORE_DIR} ]] ; then
-		local save_sandbox_write=${SANDBOX_WRITE}
 		addwrite /
 		mkdir -p "${EBZR_STORE_DIR}" \
 			|| die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}"
@@ -215,19 +226,6 @@
 
 	addwrite "${EBZR_STORE_DIR}"
 
-	# Clean up if the existing local copy is a checkout (as was the case
-	# with an older version of bzr.eclass).
-	# This test can be removed after 1 Mar 2012.
-	if [[ ${EBZR_FETCH_CMD} != *checkout* && -d ${repo_dir}/.bzr/checkout ]]
-	then
-		local tmpname=$(mktemp -u "${repo_dir}._old_.XXXXXX")
-		ewarn "checkout from old version of ${EBZR} found, moving it to:"
-		ewarn "${tmpname}"
-		ewarn "you may manually remove it"
-		mv "${repo_dir}" "${tmpname}" \
-			|| die "${EBZR}: can't move old checkout out of the way"
-	fi
-
 	if [[ ! -d ${branch_dir}/.bzr ]]; then
 		if [[ ${repo_dir} != "${branch_dir}" && ! -d ${repo_dir}/.bzr ]]; then
 			einfo "creating shared bzr repository: ${repo_dir}"
@@ -252,14 +250,23 @@
 		bzr_update "${EBZR_REPO_URI}" "${branch_dir}"
 	fi
 
+	# Restore sandbox environment
+	SANDBOX_WRITE=${save_sandbox_write}
+
 	cd "${branch_dir}" || die "${EBZR}: can't chdir to ${branch_dir}"
 
 	# Save revision number in environment. #311101
 	export EBZR_REVNO=$(${EBZR_REVNO_CMD})
 
-	einfo "exporting ..."
-	${EBZR_EXPORT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \
-		"${WORKDIR}/${P}" . || die "${EBZR}: export failed"
+	if [[ -n ${EBZR_WORKDIR_CHECKOUT} ]]; then
+		einfo "checking out ..."
+		${EBZR_CHECKOUT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \
+			. "${WORKDIR}/${P}" || die "${EBZR}: checkout failed"
+	else
+		einfo "exporting ..."
+		${EBZR_EXPORT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \
+			"${WORKDIR}/${P}" . || die "${EBZR}: export failed"
+	fi
 	einfo "revision ${EBZR_REVISION:-${EBZR_REVNO}} is now in ${WORKDIR}/${P}"
 
 	popd > /dev/null


             reply	other threads:[~2012-09-14  9:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-14  9:01 Ulrich Mueller [this message]
2012-09-14 13:15 ` [gentoo-dev] bzr.eclass changes, please review Rick "Zero_Chaos" Farina
2012-09-14 15:51   ` Ulrich Mueller
2012-09-14 16:12     ` Rick "Zero_Chaos" Farina
2012-09-14 22:26       ` Mike Gilbert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20562.62029.425431.864386@a1i15.kph.uni-mainz.de \
    --to=ulm@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox