# Template file for 'mercurial'
pkgname=mercurial
version=7.2.2
revision=1
build_style=python3-module
hostmakedepends="python3-devel python3-setuptools python3-setuptools_scm gettext"
makedepends="python3-devel"
depends="python3 ca-certificates"
checkdepends="diffutils gnupg iana-etc python3-docutils python3-pip subversion-python tar unzip which xz"
short_desc="Fast, lightweight source control management system"
maintainer="Komeil Parseh <komeilparseh@disroot.org>"
license="GPL-2.0-or-later"
homepage="https://www.mercurial-scm.org/"
changelog="https://foss.heptapod.net/mercurial/hg-website/-/raw/branch/default/source/relnotes/7.0.md"
distfiles="https://www.mercurial-scm.org/release/mercurial-${version}.tar.gz"
checksum=f2ec8e7eeef0500591706d374555f0ceb118822068e75fa3b32be07dd2184f6c

pre_check() {
	if [ "$XBPS_TARGET_LIBC" = musl ]; then
		# fix hardcoded strerror() value from glibc
		vsed -e 's/Address already in use/Address in use/' -i tests/common-pattern.py
	fi
}

do_check() {
	if [ "$XBPS_CHECK_PKGS" = full ]; then
		_additional_test=--allow-slow-tests
	else
		_additional_test='test-s*'
	fi

	cd tests
	PATH=/tmp/bin:$PATH python3 run-tests.py --blacklist "${FILESDIR}/tests_blacklist" ${makejobs} ${_additional_test}
}

post_install() {
	for i in doc/*.1 doc/*.8 doc/*.5 ; do
		vman $i
	done
	for shell in bash zsh; do
		vcompletion "contrib/${shell}_completion" $shell hg
	done
}
