homebrew-core/Formula/mercurial.rb

82 lines
3.0 KiB
Ruby

# No head build supported; if you need head builds of Mercurial, do so outside
# of Homebrew.
class Mercurial < Formula
desc "Scalable distributed version control system"
homepage "https://mercurial-scm.org/"
url "https://www.mercurial-scm.org/release/mercurial-6.3.2.tar.gz"
sha256 "cfe6eeb5dd893ab32c0b79c1531aac420773e0fc837a35db3d4d92703df45a98"
license "GPL-2.0-or-later"
livecheck do
url "https://www.mercurial-scm.org/release/"
regex(/href=.*?mercurial[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
sha256 arm64_ventura: "1feb37666417c1f7bdb42dd31b61801f4626c8991b7e71217b68635f8899a9ec"
sha256 arm64_monterey: "77d3ffd9b8e5ef481f84c5dc691daccca6c6e58bd1b86b6b469f1b824ea232e2"
sha256 arm64_big_sur: "39da304fd3e855e3869cfa5a61cc103b352be30fa73e74e679c023c31297d25f"
sha256 ventura: "1369837e42055cf1a358b04d7e84ec79f06ef4ce4e2e64dcbbf7a1d42367ecce"
sha256 monterey: "9dd1b3803c342f23ea4a2bd45c092a78d33f913868298a4f850901802ead4694"
sha256 big_sur: "7c7a34ffa6233cbcca09d6c76a679afc6f7f8a880180aa69e7b1606736a8fded"
sha256 x86_64_linux: "b2e832899d64f1324296ed58ec70b9643321943da22d1adca8437e3f464b4f39"
end
depends_on "python@3.11"
def install
ENV["HGPYTHON3"] = "1"
ENV["PYTHON"] = python3 = which("python3.11")
# FIXME: python@3.11 formula's "prefix scheme" patch tries to install into
# HOMEBREW_PREFIX/{lib,bin}, which fails due to sandbox. As workaround,
# manually set the installation paths to behave like prior python versions.
setup_install_args = %W[
--install-lib="#{prefix/Language::Python.site_packages(python3)}"
--install-scripts="#{bin}"
--install-data="#{prefix}"
]
inreplace "Makefile", / setup\.py .* --prefix="\$\(PREFIX\)"/, "\\0 #{setup_install_args.join(" ")}"
system "make", "install-bin", "PREFIX=#{prefix}"
# Install chg (see https://www.mercurial-scm.org/wiki/CHg)
system "make", "-C", "contrib/chg", "install", "PREFIX=#{prefix}", "HGPATH=#{bin}/hg", "HG=#{bin}/hg"
# Configure a nicer default pager
(buildpath/"hgrc").write <<~EOS
[pager]
pager = less -FRX
EOS
(etc/"mercurial").install "hgrc"
# Install man pages, which come pre-built in source releases
man1.install "doc/hg.1"
man5.install "doc/hgignore.5", "doc/hgrc.5"
# Move the bash completion script
bash_completion.install share/"bash-completion/completions/hg"
end
def caveats
return unless (opt_bin/"hg").exist?
cacerts_configured = `#{opt_bin}/hg config web.cacerts`.strip
return if cacerts_configured.empty?
<<~EOS
Homebrew has detected that Mercurial is configured to use a certificate
bundle file as its trust store for TLS connections instead of using the
default OpenSSL store. If you have trouble connecting to remote
repositories, consider unsetting the `web.cacerts` property. You can
determine where the property is being set by running:
hg config --debug web.cacerts
EOS
end
test do
system "#{bin}/hg", "init"
end
end