diff --git a/0001-setup-hg3.patch b/0001-setup-hg3.patch index 3edd7d2..d15c098 100644 --- a/0001-setup-hg3.patch +++ b/0001-setup-hg3.patch @@ -1,37 +1,38 @@ -From 313f85a013b487149bff441411d4b643d0cea6c2 Mon Sep 17 00:00:00 2001 -From: Petr Stodulka -Date: Thu, 15 Aug 2019 01:20:11 +0200 -Subject: [PATCH] create hg3 bin/script to keep Py2 & Py3 mercurial - installable.. +From 65b6aac48e167645a1aa75d6a724811fb7e5c775 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= +Date: Tue, 26 Nov 2019 11:10:12 +0100 +Subject: [PATCH] Create hg2/hg3 bin/scripts to keep Py2 & Py3 mercurial + co-installable -This can be removed completely once the mercurial for Python2 is -removed +This can be removed completely once the mercurial for Python 2 is removed. + +Co-Authored-By: Petr Stodulka --- - setup.py | 4 ++++ - 1 file changed, 4 insertions(+) + setup.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py -index 99556ce..5e30421 100644 +index 932608b..8663e01 100644 --- a/setup.py +++ b/setup.py -@@ -207,6 +207,8 @@ def write_if_changed(path, content): +@@ -196,7 +196,7 @@ def write_if_changed(path, content): + fh.write(content) - scripts = ['hg'] -+if 'HGPYTHON3' in os.environ: -+ scripts = ['hg3'] +-scripts = ['hg'] ++scripts = ['hg' + str(sys.version_info[0])] if os.name == 'nt': # We remove hg.bat if we are able to build hg.exe. scripts.append('contrib/win32/hg.bat') -@@ -311,6 +313,8 @@ def findhg(): +@@ -317,7 +317,7 @@ def findhg(): + # and disable localization for the same reasons. hgenv['HGPLAIN'] = '1' hgenv['LANGUAGE'] = 'C' - hgcmd = ['hg'] -+ if 'HGPYTHON3' in os.environ: -+ hgcmd = ['hg3'] +- hgcmd = ['hg'] ++ hgcmd = ['hg' + str(sys.version_info[0])] # Run a simple "hg log" command just to see if using hg from the user's # path works and can successfully interact with this repository. Windows # gives precedence to hg.exe in the current directory, so fall back to the -- -2.21.0 +2.23.0 diff --git a/contrib-hg-ssh.patch b/contrib-hg-ssh.patch deleted file mode 100644 index aabca62..0000000 --- a/contrib-hg-ssh.patch +++ /dev/null @@ -1,10 +0,0 @@ -diff -r 9d3628141c21 contrib/hg-ssh ---- a/contrib/hg-ssh Tue Mar 05 07:26:45 2019 -0500 -+++ b/contrib/hg-ssh Tue Mar 05 07:26:54 2019 -0500 -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/env python3 - # - # Copyright 2005-2007 by Intevation GmbH - # - diff --git a/mercurial.spec b/mercurial.spec index 5f58d7c..a2eff9d 100644 --- a/mercurial.spec +++ b/mercurial.spec @@ -1,7 +1,7 @@ Summary: Mercurial -- a distributed SCM Name: mercurial Version: 5.2 -Release: 1%{?dist} +Release: 2%{?dist} # Release: 1.rc1%%{?dist} @@ -13,16 +13,14 @@ URL: http://www.selenic.com/mercurial/ #Source0: http://www.selenic.com/mercurial/release/%%{name}-%%{version}.tar.gz Source0: http://www.selenic.com/mercurial/release/%{name}-%{upstreamversion}.tar.gz Source1: mercurial-site-start.el -Patch0: contrib-hg-ssh.patch Patch2: 0001-setup-hg3.patch -BuildRequires: python2 python2-devel bash-completion -BuildRequires: emacs-nox emacs-el pkgconfig gettext python2-docutils +BuildRequires: python2-devel python3-devel bash-completion +BuildRequires: emacs-nox emacs-el pkgconfig gettext python3-docutils BuildRequires: gcc -Requires: python2 emacs-filesystem -Requires: %{name}-lang = %{version}-%{release} -Provides: hg = %{version}-%{release} -Obsoletes: emacs-mercurial <= 3.4.1, emacs-mercurial-el <= 3.4.1 -Provides: emacs-mercurial <= 3.4.1, emacs-mercurial-el <= 3.4.1 + +# Priorities for the alternatives system +%global py3_priority 30 +%global py2_priority 20 %description Mercurial is a fast, lightweight source control management system designed @@ -36,23 +34,65 @@ Extensions: http://www.selenic.com/mercurial/wiki/index.cgi/CategoryExtension # If the emacs-el package has installed a pkgconfig file, use that to determine -%package py3 -Summary: Mercurial -- a distributed SCM for Python3 -Provides: hg3 = %{version}-%{release} -Requires: python3 emacs-filesystem -BuildRequires: python3 python3-devel bash-completion -BuildRequires: emacs-nox emacs-el pkgconfig gettext python3-docutils + +%package py2 +Summary: Mercurial -- a distributed SCM (Python 2 version) +Provides: hg2 = %{version}-%{release} +Provides: hg = %{version}-%{release} +Provides: %{name} = %{version}-%{release} +Provides: %{name}%{?_isa} = %{version}-%{release} +Requires: python2 emacs-filesystem Requires: %{name}-lang = %{version}-%{release} +Obsoletes: emacs-mercurial <= 3.4.1, emacs-mercurial-el <= 3.4.1 +Obsoletes: %{name} < 5.2-2 +Conflicts: %{name}-py3 < %{version}-%{release} +Requires(post): %{_sbindir}/update-alternatives +Requires(preun): %{_sbindir}/update-alternatives + +%description py2 +Mercurial is a fast, lightweight source control management system designed +for efficient handling of very large distributed projects. + +Quick start: http://www.selenic.com/mercurial/wiki/index.cgi/QuickStart +Tutorial: http://www.selenic.com/mercurial/wiki/index.cgi/Tutorial +Extensions: http://www.selenic.com/mercurial/wiki/index.cgi/CategoryExtension + +This Mercurial runs on Python 2. It's expected to be obsoleted when +dependent packages are prepared to use Python 3 by default. + + +%package py3 +Summary: Mercurial -- a distributed SCM (Python 3 version) +Provides: hg3 = %{version}-%{release} +Provides: hg = %{version}-%{release} +Provides: %{name} = %{version}-%{release} +Provides: %{name}%{?_isa} = %{version}-%{release} +Requires: python3 emacs-filesystem +Requires: %{name}-lang = %{version}-%{release} +Obsoletes: emacs-mercurial <= 3.4.1, emacs-mercurial-el <= 3.4.1 +Conflicts: %{name}-py2 < %{version}-%{release} +Requires(post): %{_sbindir}/update-alternatives +Requires(preun): %{_sbindir}/update-alternatives %description py3 -Subpackage with mercurial for Python3. It's expected to be obsoleted when -dependent packages are prepared to use Python3 by default. +Mercurial is a fast, lightweight source control management system designed +for efficient handling of very large distributed projects. + +Quick start: http://www.selenic.com/mercurial/wiki/index.cgi/QuickStart +Tutorial: http://www.selenic.com/mercurial/wiki/index.cgi/Tutorial +Extensions: http://www.selenic.com/mercurial/wiki/index.cgi/CategoryExtension + +This Mercurial runs on Python 3. It's expected to obsolete the Python 2 version +when dependent packages are prepared to use Python 3 by default. %package hgk Summary: Hgk interface for mercurial Requires: hg = %{version}-%{release}, tk +# Currently, only installs to python2_sitearch, TODO fix +Requires: hg2 = %{version}-%{release}, tk + %description hgk A Mercurial extension for displaying the change history graphically using Tcl/Tk. Displays branches and merges in an easily @@ -68,6 +108,9 @@ documentation. Summary: A fast client for Mercurial command server running on Unix. It saves time of slow Python startup. Requires: hg = %{version}-%{release} +# Let's default to Python 2, but allow some experiments +Suggests: hg2 + %description chg chg is a C wrapper for the hg command. Typically, when you type hg, a new Python process is created, Mercurial is loaded, and your requested command runs @@ -88,16 +131,14 @@ Locales for mercurial. %setup -q -n %{name}-%{upstreamversion} # NOTE: Use PYTHON envar instead of pathing Makefiles # sed -ri 's|python\b|python2|' %{_builddir}/%{name}-%{version}/Makefile %{_builddir}/%{name}-%{version}/doc/Makefile -%patch0 -p1 -b .contrib-hg-ssh %patch2 -p1 -b .create_hg3 %build -# copy hg to hg3 to be able to create /usr/bin/hg3 script +# copy hg to hg2/hg3 to be able to create /usr/bin/hg(2|3) script +cp -a hg hg2 cp -a hg hg3 -# HGPYTHON3 is not needed since mercurial 5.2 for building & installation, but -# let's keep it for now as we can use is simply to create HG3 executable. Can -# be dropped with -py3 subpackage -PYTHON=%{__python3} HGPYTHON3=1 make all +rm hg +PYTHON=%{__python3} make all PYTHON=%{__python2} make all #TODO: Now just for Py2, version for Py3 will need probably more fixes @@ -110,14 +151,22 @@ popd # NOTE: this is nasty, but if we want to have parallel Py2/Py3 mercurial.. # ignoring now stuff related to *_completion, extensions rm -rf $RPM_BUILD_ROOT -HGPYTHON3=1 %{__python3} setup.py install -O1 --root $RPM_BUILD_ROOT --prefix %{_prefix} --record=%{name}3.files -%{__python2} setup.py install -O1 --root $RPM_BUILD_ROOT --prefix %{_prefix} --record=%{name}.files +%{__python3} setup.py install -O1 --root $RPM_BUILD_ROOT --prefix %{_prefix} --record=%{name}3.files +%{__python2} setup.py install -O1 --root $RPM_BUILD_ROOT --prefix %{_prefix} --record=%{name}2.files make install-doc DESTDIR=$RPM_BUILD_ROOT MANDIR=%{_mandir} -grep -v -e 'hgk.py*' -e %{python3_sitearch}/mercurial/ -e %{python3_sitearch}/hgext/ < %{name}3.files > %{name}3-base.files -grep -v -e 'hgk.py*' -e %{python2_sitearch}/mercurial/ -e %{python2_sitearch}/hgext/ < %{name}.files > %{name}-base.files +grep -v -e 'hgk.py*' \ + -e "%{python3_sitearch}/mercurial/" \ + -e "%{python3_sitearch}/hgext/" \ + -e "%{_bindir}" \ + < %{name}3.files > %{name}3-base.files +grep -v -e 'hgk.py*' \ + -e "%{python2_sitearch}/mercurial/" \ + -e "%{python2_sitearch}/hgext/" \ + -e "%{_bindir}" \ + < %{name}2.files > %{name}2-base.files grep 'hgk.py*' < %{name}3.files > %{name}3-hgk.files -grep 'hgk.py*' < %{name}.files > %{name}-hgk.files +grep 'hgk.py*' < %{name}2.files > %{name}2-hgk.files install -D -m 755 contrib/hgk $RPM_BUILD_ROOT%{_libexecdir}/mercurial/hgk install -m 755 contrib/hg-ssh $RPM_BUILD_ROOT%{_bindir} @@ -172,13 +221,47 @@ mv $RPM_BUILD_ROOT%{python2_sitearch}/mercurial/locale $RPM_BUILD_ROOT%{_datadir rm -rf $RPM_BUILD_ROOT%{python3_sitearch}/mercurial/locale rm -rf $RPM_BUILD_ROOT%{python2_sitearch}/mercurial/locale - %find_lang hg -grep -v locale %{name}-base.files > %{name}-base-filtered.files +grep -v locale %{name}2-base.files > %{name}2-base-filtered.files grep -v locale %{name}3-base.files > %{name}3-base-filtered.files -%files -f %{name}-base-filtered.files + +# Move hg-ssh aside +cp -p $RPM_BUILD_ROOT%{_bindir}/hg-ssh $RPM_BUILD_ROOT%{_bindir}/hg-ssh2 +cp -p $RPM_BUILD_ROOT%{_bindir}/hg-ssh $RPM_BUILD_ROOT%{_bindir}/hg-ssh3 +rm $RPM_BUILD_ROOT%{_bindir}/hg-ssh +pathfix.py -pni "%{__python2}" $RPM_BUILD_ROOT%{_bindir}/hg-ssh2 +pathfix.py -pni "%{__python3}" $RPM_BUILD_ROOT%{_bindir}/hg-ssh3 + + +# Touch the base executables for alternatives +touch $RPM_BUILD_ROOT%{_bindir}/hg +touch $RPM_BUILD_ROOT%{_bindir}/hg-ssh + +%post py2 +%{_sbindir}/update-alternatives --install %{_bindir}/hg \ + hg %{_bindir}/hg2 %{py2_priority} \ + --slave %{_bindir}/hg-ssh hg-ssh %{_bindir}/hg-ssh2 || : + +%preun py2 +if [ $1 -eq 0 ]; then + %{_sbindir}/update-alternatives --remove \ + hg %{_bindir}/hg2 || : +fi + +%post py3 +%{_sbindir}/update-alternatives --install %{_bindir}/hg \ + hg %{_bindir}/hg3 %{py3_priority} \ + --slave %{_bindir}/hg-ssh hg-ssh %{_bindir}/hg-ssh3 || : + +%preun py3 +if [ $1 -eq 0 ]; then + %{_sbindir}/update-alternatives --remove \ + hg %{_bindir}/hg3 || : +fi + +%files py2 -f %{name}2-base-filtered.files %doc CONTRIBUTORS COPYING doc/README doc/hg*.txt doc/hg*.html *.cgi contrib/*.fcgi contrib/*.wsgi %doc %attr(644,root,root) %{_mandir}/man?/hg*.gz %doc %attr(644,root,root) contrib/*.svg @@ -186,21 +269,44 @@ grep -v locale %{name}3-base.files > %{name}3-base-filtered.files %dir %{_datadir}/zsh/site-functions/ %dir %{_sysconfdir}/mercurial %dir %{_sysconfdir}/mercurial/hgrc.d -%{_bindir}/hg-ssh %{_datadir}/bash-completion/ %{_datadir}/zsh/site-functions/_mercurial %{python2_sitearch}/mercurial %{python2_sitearch}/hgext %{_emacs_sitelispdir}/mercurial %{_emacs_sitestartdir}/*.el +%ghost %{_bindir}/hg +%ghost %{_bindir}/hg-ssh +%{_bindir}/hg2 +%{_bindir}/hg-ssh2 %config(noreplace) %{_sysconfdir}/mercurial/hgrc.d/certs.rc -%files py3 -f %{name}3-base-filtered.files -%{python3_sitearch}/mercurial -%{python3_sitearch}/hgext +%files py3 -f %{name}2-base-filtered.files +%doc CONTRIBUTORS COPYING doc/README doc/hg*.txt doc/hg*.html *.cgi contrib/*.fcgi contrib/*.wsgi +%doc %attr(644,root,root) %{_mandir}/man?/hg*.gz +%doc %attr(644,root,root) contrib/*.svg +%dir %{_datadir}/zsh/ +%dir %{_datadir}/zsh/site-functions/ +%dir %{_sysconfdir}/mercurial +%dir %{_sysconfdir}/mercurial/hgrc.d +%{_datadir}/bash-completion/ +%{_datadir}/zsh/site-functions/_mercurial +%{python3_sitearch}/mercurial-*.egg-info +%{python3_sitearch}/mercurial/ +%{python3_sitearch}/hgdemandimport/ +%{python3_sitearch}/hgext/ +%{python3_sitearch}/hgext3rd/ +%{_emacs_sitelispdir}/mercurial +%{_emacs_sitestartdir}/*.el +%ghost %{_bindir}/hg +%ghost %{_bindir}/hg-ssh +%{_bindir}/hg3 +%{_bindir}/hg-ssh3 -%files hgk -f %{name}-hgk.files +%config(noreplace) %{_sysconfdir}/mercurial/hgrc.d/certs.rc + +%files hgk -f %{name}2-hgk.files %{_libexecdir}/mercurial/ %{_sysconfdir}/mercurial/hgrc.d/hgk.rc @@ -220,6 +326,9 @@ grep -v locale %{name}3-base.files > %{name}3-base-filtered.files %changelog +* Tue Nov 26 2019 Miro HronĨok - 5.2-2 +- Use alternatives for /usr/bin/hg + * Mon Nov 25 2019 Petr Stodulka - 5.2-1 - Update to 5.2 - Mercurial port is now much more stable on Python3 than before;