1+ # Distributed under the terms of the GNU General Public License v2
2+
3+ EAPI=7
4+
5+ PYTHON_COMPAT=( python3+ )
6+ PYTHON_REQ_USE=" threads(+)"
7+
8+ inherit bash-completion-r1 elisp-common eutils distutils-r1 flag-o-matic
9+
10+ DESCRIPTION=" "
11+ HOMEPAGE=" https://www.mercurial-scm.org/"
12+ SRC_URI=" https://files.pythonhosted.org/packages/2d/d4/5be888405717a3f998250012efd6af6e928b2baf3df4f347bcd1d6c226f8/mercurial-7.0.2.tar.gz -> mercurial-7.0.2.tar.gz"
13+
14+ LICENSE=" GPL-2+"
15+ SLOT=" 0"
16+ KEYWORDS=" *"
17+ IUSE=" +chg emacs gpg test tk zsh-completion"
18+
19+ RDEPEND="
20+ app-misc/ca-certificates
21+ dev-python/zstandard[${PYTHON_USEDEP} ]
22+ gpg? ( app-crypt/gnupg )
23+ tk? ( dev-lang/tk )
24+ zsh-completion? ( app-shells/zsh )"
25+
26+ DEPEND=" emacs? ( >=app-editors/emacs-23.1:* )
27+ test? ( app-arch/unzip
28+ dev-python/pygments[${PYTHON_USEDEP} ] )"
29+
30+ SITEFILE=" 70${PN} -gentoo.el"
31+
32+ # Too many tests fail #608720
33+ RESTRICT=" test"
34+
35+ python_prepare_all () {
36+ # Use absolute import for zstd
37+ sed -i -e ' s/from \.* import zstd/import zstd/' \
38+ mercurial/utils/compression.py \
39+ mercurial/wireprotoframing.py
40+ distutils-r1_python_prepare_all
41+ }
42+
43+ python_compile () {
44+ filter-flags -ftracer -ftree-vectorize
45+ append-cflags -D_GNU_SOURCE
46+ python_is_python3 || local -x CFLAGS=" ${CFLAGS} -fno-strict-aliasing"
47+ distutils-r1_python_compile build_ext --no-zstd
48+ }
49+
50+ python_compile_all () {
51+ rm -r contrib/win32 || die
52+ if use chg; then
53+ emake -C contrib/chg
54+ fi
55+ if use emacs; then
56+ cd contrib || die
57+ elisp-compile mercurial.el || die " elisp-compile failed!"
58+ fi
59+ }
60+
61+ python_install () {
62+ distutils-r1_python_install build_ext --no-zstd
63+ }
64+
65+ python_install_all () {
66+ distutils-r1_python_install_all
67+
68+ newbashcomp contrib/bash_completion hg
69+
70+ if use zsh-completion ; then
71+ insinto /usr/share/zsh/site-functions
72+ newins contrib/zsh_completion _hg
73+ fi
74+
75+ dobin hgeditor
76+ if use tk; then
77+ dobin contrib/hgk
78+ fi
79+ python_foreach_impl python_doscript contrib/hg-ssh
80+
81+ if use emacs; then
82+ elisp-install ${PN} contrib/mercurial.el* || die " elisp-install failed!"
83+ elisp-site-file-install " ${FILESDIR} " /${SITEFILE}
84+ fi
85+
86+ local RM_CONTRIB=( hgk hg-ssh bash_completion zsh_completion plan9 * .el )
87+
88+ if use chg; then
89+ dobin contrib/chg/chg
90+ doman contrib/chg/chg.1
91+ RM_CONTRIB+=( chg )
92+ fi
93+
94+ for f in ${RM_CONTRIB[@]} ; do
95+ rm -rf contrib/${f} || die
96+ done
97+
98+ dodoc -r contrib
99+ docompress -x /usr/share/doc/${PF} /contrib
100+ doman doc/* .?
101+ dodoc CONTRIBUTORS hgweb.cgi
102+
103+ insinto /etc/mercurial/hgrc.d
104+ doins " ${FILESDIR} /cacerts.rc"
105+ }
106+
107+ src_test () {
108+ pushd tests & > /dev/null || die
109+ rm -rf * svn* # Subversion tests fail with 1.5
110+ rm -f test-archive* # Fails due to verbose tar output changes
111+ rm -f test-convert-baz* # GNU Arch baz
112+ rm -f test-convert-cvs* # CVS
113+ rm -f test-convert-darcs* # Darcs
114+ rm -f test-convert-git* # git
115+ rm -f test-convert-mtn* # monotone
116+ rm -f test-convert-tla* # GNU Arch tla
117+ rm -f test-largefiles* # tends to time out
118+ if [[ ${EUID} -eq 0 ]]; then
119+ einfo " Removing tests which require user privileges to succeed"
120+ rm -f test-convert*
121+ rm -f test-lock-badness*
122+ rm -f test-permissions*
123+ rm -f test-pull-permission*
124+ rm -f test-journal-exists*
125+ rm -f test-repair-strip*
126+ fi
127+
128+ popd & > /dev/null || die
129+ distutils-r1_src_test
130+ }
131+
132+ python_test () {
133+ local TEST_DIR
134+
135+ rm -rf " ${TMPDIR} " /test
136+ distutils_install_for_testing
137+ cd tests || die
138+ " ${PYTHON} " run-tests.py --verbose \
139+ --tmpdir=" ${TMPDIR} " /test \
140+ --with-hg=" ${TEST_DIR} " /scripts/hg \
141+ || die " Tests fail with ${EPYTHON} "
142+ }
143+
144+ pkg_postinst () {
145+ use emacs && elisp-site-regen
146+
147+ elog " If you want to convert repositories from other tools using convert"
148+ elog " extension please install correct tool:"
149+ elog " dev-vcs/cvs"
150+ elog " dev-vcs/darcs"
151+ elog " dev-vcs/git"
152+ elog " dev-vcs/monotone"
153+ elog " dev-vcs/subversion"
154+ }
155+
156+ pkg_postrm () {
157+ use emacs && elisp-site-regen
158+ }
0 commit comments