--- /usr/portage/eclass/mercurial.eclass 2009-01-16 09:11:37.000000000 +0100 +++ eclass/mercurial.eclass 2009-01-16 14:24:45.000000000 +0100 @@ -18,8 +18,10 @@ # These can be set by the ebuild but are usually fine as-is : ${EHG_PROJECT:=$PN} # dir under EHG_STORE_DIR -: ${EHG_CLONE_CMD:=hg clone} # clone cmd -: ${EHG_PULL_CMD:=hg pull -u} # pull cmd +: ${EHG_CLONE_CMD:=hg clone --pull} # clone cmd +: ${EHG_PULL_CMD:=hg pull -u -C} # pull cmd; update and clean out local changes +: ${EHG_CLONE_CMD_NOUPDATE:=hg clone --pull -U} # clone cmd; no working copy +: ${EHG_PULL_CMD_NOUPDATE:=hg pull} # pull cmd; no updating # should be set but blank to prevent using $HOME/.hgrc export HGRCPATH= @@ -44,19 +46,20 @@ addwrite "$(pwd -P)" if [[ ! -d ${EHG_PROJECT}/${module} ]]; then - # first check out - ebegin "${EHG_CLONE_CMD} ${repo}" + # first check out - if it fails, remove the dir again. + ebegin "${EHG_CLONE_CMD_NOUPDATE} ${repo}" mkdir -p "${EHG_PROJECT}" && chmod -f g+rw "${EHG_PROJECT}" && cd "${EHG_PROJECT}" && - ${EHG_CLONE_CMD} "${repo}" "${module}" && - cd "${module}" + ${EHG_CLONE_CMD_NOUPDATE} "${repo}" "${module}" && + cd "${module}" || + rm -r "${module}" eend $? || die else # update working copy - ebegin "${EHG_PULL_CMD} ${repo}" + ebegin "${EHG_PULL_CMD_NOUPDATE} ${repo}" cd "${EHG_PROJECT}/${module}" && - ${EHG_PULL_CMD} + ${EHG_PULL_CMD_NOUPDATE} case $? in # hg pull returns status 1 when there were no changes to pull 1) eend 0 ;; @@ -64,11 +67,27 @@ esac fi - # use rsync instead of cp for --exclude - ebegin "rsync to ${WORKDIR}/${module}" - mkdir -p "${WORKDIR}/${module}" && - rsync -a --delete --exclude=.hg/ . "${WORKDIR}/${module}" - eend $? || die + # use Mercurial instead of cp or rsync, + # as that saves space in distfiles and some setup.py scripts might depend on + # being run in an hg repository (For example the one from Mercurial does). + if [[ ! -d ${WORKDIR}/${module} ]]; then + # clone to workdir, remove the created dir if the clone fails. + ebegin "${EHG_CLONE_CMD} ${EHG_STORE_DIR}/${EHG_PROJECT}/${module} ${WORKDIR}/${module}" + mkdir -p "${WORKDIR}" && + ${EHG_CLONE_CMD} ${EHG_STORE_DIR}/${EHG_PROJECT}/${module} ${WORKDIR}/${module} || + rm -r "${WORKDIR}/${module}" + eend $? || die + else + # pull from workdir + ebegin "${EHG_PULL_CMD} ${EHG_PROJECT}/${module}" + cd "${WORKDIR}/${module}" && + ${EHG_PULL_CMD} + case $? in + # hg pull returns status 1 when there were no changes to pull + 1) eend 0 ;; + *) eend $? || die ;; + esac + fi popd >/dev/null }