1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python2_7 python3_{6..8} )
7 PYTHON_REQ_USE="threads(+)"
9 inherit bash-completion-r1 elisp-common eutils distutils-r1 mercurial flag-o-matic
11 DESCRIPTION="Scalable distributed SCM"
12 HOMEPAGE="https://www.mercurial-scm.org/"
13 EHG_REPO_URI="https://www.mercurial-scm.org/repo/hg"
18 IUSE="+chg emacs gpg test tk zsh-completion"
21 !~dev-python/python-3.5.0
22 !~dev-python/python-3.5.1
23 !~dev-python/python-3.5.2
24 !~dev-python/python-3.6.0
25 !~dev-python/python-3.6.1"
27 BDEPEND="${BROKEN_PYTHON}
28 dev-python/docutils[${PYTHON_USEDEP}]"
30 RDEPEND="${BROKEN_PYTHON}
31 app-misc/ca-certificates
32 dev-python/zstandard[${PYTHON_USEDEP}]
33 gpg? ( app-crypt/gnupg )
35 zsh-completion? ( app-shells/zsh )"
37 DEPEND="emacs? ( >=app-editors/emacs-23.1:* )
38 test? ( app-arch/unzip
39 dev-python/pygments[${PYTHON_USEDEP}] )"
41 SITEFILE="70${PN}-gentoo.el"
43 # Too many tests fail #608720
46 python_prepare_all() {
47 # fix up logic that won't work in Gentoo Prefix (also won't outside in
48 # certain cases), bug #362891
49 sed -i -e 's:xcodebuild:nocodebuild:' setup.py || die
50 sed -i -e '/ hgenv =/a\' -e ' hgenv.pop("PYTHONPATH", None)' setup.py || die
51 # Use absolute import for zstd
52 sed -i -e 's/from \.* import zstd/import zstd/' \
53 mercurial/utils/compression.py \
54 mercurial/wireprotoframing.py || die
56 distutils-r1_python_prepare_all
60 filter-flags -ftracer -ftree-vectorize
61 python_is_python3 || local -x CFLAGS="${CFLAGS} -fno-strict-aliasing"
62 distutils-r1_python_compile build_ext --no-zstd
65 python_compile_all() {
66 rm -r contrib/win32 || die
73 elisp-compile mercurial.el || die "elisp-compile failed!"
78 distutils-r1_python_install build_ext --no-zstd
81 python_install_all() {
82 distutils-r1_python_install_all
84 newbashcomp contrib/bash_completion hg
86 if use zsh-completion ; then
87 insinto /usr/share/zsh/site-functions
88 newins contrib/zsh_completion _hg
95 python_foreach_impl python_doscript contrib/hg-ssh
98 elisp-install ${PN} contrib/mercurial.el* || die "elisp-install failed!"
99 elisp-site-file-install "${FILESDIR}"/${SITEFILE}
102 local RM_CONTRIB=( hgk hg-ssh bash_completion zsh_completion plan9 *.el )
105 dobin contrib/chg/chg
106 doman contrib/chg/chg.1
110 for f in ${RM_CONTRIB[@]}; do
111 rm -rf contrib/${f} || die
115 docompress -x /usr/share/doc/${PF}/contrib
117 dodoc CONTRIBUTORS hgweb.cgi
119 insinto /etc/mercurial/hgrc.d
120 doins "${FILESDIR}/cacerts.rc"
124 pushd tests &>/dev/null || die
125 rm -rf *svn* # Subversion tests fail with 1.5
126 rm -f test-archive* # Fails due to verbose tar output changes
127 rm -f test-convert-baz* # GNU Arch baz
128 rm -f test-convert-cvs* # CVS
129 rm -f test-convert-darcs* # Darcs
130 rm -f test-convert-git* # git
131 rm -f test-convert-mtn* # monotone
132 rm -f test-convert-tla* # GNU Arch tla
133 rm -f test-largefiles* # tends to time out
134 if [[ ${EUID} -eq 0 ]]; then
135 einfo "Removing tests which require user privileges to succeed"
137 rm -f test-lock-badness*
138 rm -f test-permissions*
139 rm -f test-pull-permission*
140 rm -f test-journal-exists*
141 rm -f test-repair-strip*
144 popd &>/dev/null || die
145 distutils-r1_src_test
151 rm -rf "${TMPDIR}"/test
152 distutils_install_for_testing
154 "${PYTHON}" run-tests.py --verbose \
155 --tmpdir="${TMPDIR}"/test \
156 --with-hg="${TEST_DIR}"/scripts/hg \
157 || die "Tests fail with ${EPYTHON}"
161 use emacs && elisp-site-regen
163 elog "If you want to convert repositories from other tools using convert"
164 elog "extension please install correct tool:"
166 elog " dev-vcs/darcs"
168 elog " dev-vcs/monotone"
169 elog " dev-vcs/subversion"
173 use emacs && elisp-site-regen