1 | # Copyright 1999-2006 Gentoo Foundation |
1 | # Copyright 1999-2012 Gentoo Foundation |
2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/mercurial.eclass,v 1.14 2010/10/26 19:04:44 nelchael Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/mercurial.eclass,v 1.18 2012/02/05 19:14:16 floppym Exp $ |
4 | |
4 | |
5 | # @ECLASS: mercurial.eclass |
5 | # @ECLASS: mercurial.eclass |
6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
7 | # Krzysztof Pawlik <nelchael@gentoo.org> |
7 | # Krzysztof Pawlik <nelchael@gentoo.org> |
8 | # Dirkjan Ochtman <djc@gentoo.org> |
8 | # Dirkjan Ochtman <djc@gentoo.org> |
… | |
… | |
25 | |
25 | |
26 | # @ECLASS-VARIABLE: EHG_REVISION |
26 | # @ECLASS-VARIABLE: EHG_REVISION |
27 | # @DESCRIPTION: |
27 | # @DESCRIPTION: |
28 | # Create working directory for specified revision, defaults to tip. |
28 | # Create working directory for specified revision, defaults to tip. |
29 | # |
29 | # |
30 | # EHG_REVISION is passed as a value for --rev parameter, so it can be more than |
30 | # EHG_REVISION is passed as a value for --updaterev parameter, so it can be more |
31 | # just a revision, please consult `hg help revisions' for more details. |
31 | # than just a revision, please consult `hg help revisions' for more details. |
32 | [[ -z "${EHG_REVISION}" ]] && EHG_REVISION="tip" |
32 | [[ -z "${EHG_REVISION}" ]] && EHG_REVISION="tip" |
33 | |
33 | |
34 | # @ECLASS-VARIABLE: EHG_STORE_DIR |
34 | # @ECLASS-VARIABLE: EHG_STORE_DIR |
35 | # @DESCRIPTION: |
35 | # @DESCRIPTION: |
36 | # Mercurial sources store directory. Users may override this in /etc/make.conf |
36 | # Mercurial sources store directory. Users may override this in /etc/make.conf |
… | |
… | |
66 | # a mercurial source tree. This is intended to be set outside the ebuild by |
66 | # a mercurial source tree. This is intended to be set outside the ebuild by |
67 | # users. |
67 | # users. |
68 | EHG_OFFLINE="${EHG_OFFLINE:-${ESCM_OFFLINE}}" |
68 | EHG_OFFLINE="${EHG_OFFLINE:-${ESCM_OFFLINE}}" |
69 | |
69 | |
70 | # @FUNCTION: mercurial_fetch |
70 | # @FUNCTION: mercurial_fetch |
71 | # @USAGE: [repository_uri] [module] |
71 | # @USAGE: [repository_uri] [module] [sourcedir] |
72 | # @DESCRIPTION: |
72 | # @DESCRIPTION: |
73 | # Clone or update repository. |
73 | # Clone or update repository. |
74 | # |
74 | # |
75 | # If not repository URI is passed it defaults to EHG_REPO_URI, if module is |
75 | # If repository URI is not passed it defaults to EHG_REPO_URI, if module is |
76 | # empty it defaults to basename of EHG_REPO_URI. |
76 | # empty it defaults to basename of EHG_REPO_URI, sourcedir defaults to S. |
77 | function mercurial_fetch { |
77 | function mercurial_fetch { |
78 | debug-print-function ${FUNCNAME} ${*} |
78 | debug-print-function ${FUNCNAME} ${*} |
79 | |
79 | |
80 | EHG_REPO_URI=${1-${EHG_REPO_URI}} |
80 | EHG_REPO_URI=${1-${EHG_REPO_URI}} |
81 | [[ -z "${EHG_REPO_URI}" ]] && die "EHG_REPO_URI is empty" |
81 | [[ -z "${EHG_REPO_URI}" ]] && die "EHG_REPO_URI is empty" |
82 | |
82 | |
83 | local module="${2-$(basename "${EHG_REPO_URI}")}" |
83 | local module="${2-$(basename "${EHG_REPO_URI}")}" |
|
|
84 | local sourcedir="${3-${S}}" |
84 | |
85 | |
85 | # Should be set but blank to prevent using $HOME/.hgrc |
86 | # Should be set but blank to prevent using $HOME/.hgrc |
86 | export HGRCPATH= |
87 | export HGRCPATH= |
87 | |
88 | |
88 | # Check ${EHG_STORE_DIR} directory: |
89 | # Check ${EHG_STORE_DIR} directory: |
… | |
… | |
110 | } |
111 | } |
111 | cd "${module}" |
112 | cd "${module}" |
112 | elif [[ -z "${EHG_OFFLINE}" ]]; then |
113 | elif [[ -z "${EHG_OFFLINE}" ]]; then |
113 | einfo "Updating ${EHG_STORE_DIR}/${EHG_PROJECT}/${module} from ${EHG_REPO_URI}" |
114 | einfo "Updating ${EHG_STORE_DIR}/${EHG_PROJECT}/${module} from ${EHG_REPO_URI}" |
114 | cd "${module}" || die "failed to cd to ${module}" |
115 | cd "${module}" || die "failed to cd to ${module}" |
115 | ${EHG_PULL_CMD} || die "update failed" |
116 | ${EHG_PULL_CMD} |
|
|
117 | # mercurial-2.1: hg pull returns 1 if there are no incoming changesets |
|
|
118 | [[ $? -eq 0 || $? -eq 1 ]] || die "update failed" |
116 | fi |
119 | fi |
117 | |
120 | |
118 | # Checkout working copy: |
121 | # Checkout working copy: |
119 | einfo "Creating working directory in ${WORKDIR}/${module} (target revision: ${EHG_REVISION})" |
122 | einfo "Creating working directory in ${sourcedir} (target revision: ${EHG_REVISION})" |
120 | hg clone \ |
123 | hg clone \ |
121 | ${EHG_QUIET_CMD_OPT} \ |
124 | ${EHG_QUIET_CMD_OPT} \ |
122 | --rev="${EHG_REVISION}" \ |
125 | --updaterev="${EHG_REVISION}" \ |
123 | "${EHG_STORE_DIR}/${EHG_PROJECT}/${module}" \ |
126 | "${EHG_STORE_DIR}/${EHG_PROJECT}/${module}" \ |
124 | "${WORKDIR}/${module}" || die "hg clone failed" |
127 | "${sourcedir}" || die "hg clone failed" |
125 | # An exact revision helps a lot for testing purposes, so have some output... |
128 | # An exact revision helps a lot for testing purposes, so have some output... |
126 | # id num branch |
129 | # id num branch |
127 | # fd6e32d61721 6276 default |
130 | # fd6e32d61721 6276 default |
128 | local HG_REVDATA=($(hg identify -b -i "${WORKDIR}/${module}")) |
131 | local HG_REVDATA=($(hg identify -b -i "${sourcedir}")) |
129 | export HG_REV_ID=${HG_REVDATA[0]} |
132 | export HG_REV_ID=${HG_REVDATA[0]} |
130 | local HG_REV_BRANCH=${HG_REVDATA[1]} |
133 | local HG_REV_BRANCH=${HG_REVDATA[1]} |
131 | einfo "Work directory: ${WORKDIR}/${module} global id: ${HG_REV_ID} branch: ${HG_REV_BRANCH}" |
134 | einfo "Work directory: ${sourcedir} global id: ${HG_REV_ID} branch: ${HG_REV_BRANCH}" |
132 | } |
135 | } |
133 | |
136 | |
134 | # @FUNCTION: mercurial_src_unpack |
137 | # @FUNCTION: mercurial_src_unpack |
135 | # @DESCRIPTION: |
138 | # @DESCRIPTION: |
136 | # The mercurial src_unpack function, which will be exported. |
139 | # The mercurial src_unpack function, which will be exported. |