[PATCH 0/2] Add mercurial-commitsigs and some changes to Mercurial.

  • Done
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Xinglu Chen
Owner
unassigned
Submitted by
Xinglu Chen
Severity
normal
X
X
Xinglu Chen wrote on 4 May 2021 22:58
(address . guix-patches@gnu.org)
87k0oecj3a.fsf@yoctocell.xyz
The first patch adds the commitsigs extension for Mercurial, it allows
users to sign Mercurial changesets (equivalent to Git commits) with
GnuPG or OpenSSL.

The second patch adds PYTHONPATH to the ‘native-search-paths’ field of
Mercurial, this allows Mercurial to automatically find third-party
extensions (like commitsigs) installed in
/gnu/store/...-profile/lib/python3.8/site-packages/hgext3rd. By
default, it only looks at
/gnu/store/...-mercurial/lib/python3.8/site-packages/hgext3rd.

However, I am not sure this is the best approach since it messes with
PYTHONPATH, AFAIK there is no such things as a HGEXTENSIONS variable I
could set. Another problem is that I have to hardcode “python3.8”, this
would obviously have to be updated if the default Python version gets
updated. I did try to do something like this:

#+begin_src scheme
(string-append
"lib/python"
(string-join
(drop-right (string-split (package-version python) #\.) 1)
".")
"/site-packages/hgext3rd")
#+end_src

but it just gave me a confusing error message when trying to build it;
it worked fine if I hit {C-x C-e} in Emacs, though.

What we could do instead is to delegate the work of installing Mercurial
extensions to Guix Home[1] (I am currently working on adding a service
for Mercurial[2]) and add a ‘mercurial-extension-file-path’ key to the
‘properties’ field of Mercurial extensions so Guix Home can tell
Mercurial where to find the extension by the relevant lines in hgrc. We
could have a package definition like this:

#+begin_src scheme
(package
(name "mercurial-commitsigs")
...
(properties
'((mercurial-extension-file-path . "commitsigs.py"))))
#+end_src

hgrc:

#+begin_src
[extensions]
commitsigs = /gnu/store/...-mercurial-commitsigs/commitsigs.py
#+end_src


Xinglu Chen (2):
gnu: Add mercurial-commitsigs.
gnu: mercurial: Add PYTHONPATH to ‘native-search-paths’.

gnu/packages/version-control.scm | 68 ++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)


base-commit: aa7eeabe9a782afc2535581298990050d16b1895
--
2.31.1
X
X
Xinglu Chen wrote on 4 May 2021 23:00
[PATCH 1/2] gnu: Add mercurial-commitsigs.
(address . 48232@debbugs.gnu.org)
f1c1299504315f8d13d33a3cce20ef63779a40c7.1620159508.git.public@yoctocell.xyz
* gnu/packages/version-control.scm (mercurial-commitsigs): New variable.
---
Note: I am using ‘git-version’ and ‘git-file-name’, maybe we should add
the equivalent procedures in (guix hg-download) ?

gnu/packages/version-control.scm | 63 ++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)

Toggle diff (90 lines)
diff --git a/gnu/packages/version-control.scm b/gnu/packages/version-control.scm
index 0cad83c4b0..3a1cb33fc3 100644
--- a/gnu/packages/version-control.scm
+++ b/gnu/packages/version-control.scm
@@ -62,6 +62,7 @@
#:use-module (guix download)
#:use-module (guix git-download)
#:use-module (guix hg-download)
+ #:use-module (guix build python-build-system)
#:use-module (guix build-system cmake)
#:use-module (guix build-system copy)
#:use-module (guix build-system gnu)
@@ -88,6 +89,7 @@
#:use-module (gnu packages gl)
#:use-module (gnu packages glib)
#:use-module (gnu packages gnome)
+ #:use-module (gnu packages gnupg)
#:use-module (gnu packages golang)
#:use-module (gnu packages groff)
#:use-module (gnu packages guile)
@@ -1741,6 +1743,67 @@ and offers an easy and intuitive interface.")
history. It implements the changeset evolution concept for Mercurial.")
(license license:gpl2)))
+(define-public mercurial-commitsigs
+ ;; Latest tag is 11 years old.
+ (let ((changeset "b53eb6862bff")
+ (revision "0"))
+ (package
+ (name "mercurial-commitsigs")
+ (version (git-version "0.1.0" revision changeset))
+ (source (origin
+ (method hg-fetch)
+ (uri (hg-reference
+ (url "https://foss.heptapod.net/mercurial/commitsigs")
+ (changeset changeset)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "059gm66q06m6ayl4brsc517zkw3ahmz249b6xm1m32ac5y24wb9x"))))
+ (build-system copy-build-system)
+ (arguments
+ `(#:imported-modules ((guix build python-build-system)
+ ,@%copy-build-system-modules)
+ #:modules ((srfi srfi-1)
+ (guix build python-build-system)
+ ;; Don't use `%copy-build-system-modules' because
+ ;; `standard-phases' from (guix build gnu-build-system)
+ ;; shadows the one from (guix build copy-build-system),
+ ;; which is the one we actually want.
+ (guix build copy-build-system)
+ ((guix build gnu-build-system) #:prefix gnu)
+ (guix build utils)
+ (guix build gremlin)
+ (ice-9 ftw)
+ (guix elf))
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'patch-paths
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let ((gpg (string-append (assoc-ref inputs "gnupg")
+ "/bin/gpg"))
+ (openssl (string-append (assoc-ref inputs "openssl")
+ "/bin/openssl")))
+ (substitute* "commitsigs.py"
+ (("b'gpg',") (string-append "b'" gpg "',"))
+ (("b'openssl',") (string-append "b'" openssl "',")))))))
+ #:install-plan
+ `(("commitsigs.py" ,(string-append "lib/python"
+ (python-version
+ (assoc-ref %build-inputs "python"))
+ "/site-packages/hgext3rd/commitsigs.py")))))
+ (native-inputs
+ `(("python" ,python)))
+ (inputs
+ `(("gnupg" ,gnupg)
+ ("openssl" ,openssl)))
+ (home-page "https://foss.heptapod.net/mercurial/commitsigs")
+ (synopsis "Automatic signing of changeset hashes")
+ (description "This package provides a Mercurial extension for signing
+the changeset hash of commits. The signure is embedded directly in the
+changeset itself; there won't be any extra commits. Either GnuPG or OpenSSL
+can be used for signing.")
+ (license license:gpl3+))))
+
(define-public neon
(package
(name "neon")
--
2.31.1
X
X
Xinglu Chen wrote on 4 May 2021 23:00
[PATCH 2/2] gnu: mercurial: Add PYTHONPATH to
(address . 48232@debbugs.gnu.org)
bb3bf9711cfb03214786407afe8fd67019c0c4fa.1620159508.git.public@yoctocell.xyz
This will make Mercurial be able to find third-party extensions.

* gnu/packages/version-control.scm (mercurial)[native-search-paths]: Add
PYTHONPATH.
---
gnu/packages/version-control.scm | 5 +++++
1 file changed, 5 insertions(+)

Toggle diff (18 lines)
diff --git a/gnu/packages/version-control.scm b/gnu/packages/version-control.scm
index 3a1cb33fc3..9711516609 100644
--- a/gnu/packages/version-control.scm
+++ b/gnu/packages/version-control.scm
@@ -1709,6 +1709,11 @@ execution of any hook written in any language before every commit.")
`(("python-nose" ,python-nose)
("unzip" ,unzip)
("which" ,which)))
+ ;; Find third-party extensions.
+ (native-search-paths
+ (list (search-path-specification
+ (variable "PYTHONPATH")
+ (files '("lib/python3.8/site-packages/hgext3rd")))))
(home-page "https://www.mercurial-scm.org/")
(synopsis "Decentralized version control system")
(description
--
2.31.1
L
L
Ludovic Courtès wrote on 11 May 2021 12:26
Re: bug#48232: [PATCH 0/2] Add mercurial-commitsigs and some changes to Mercurial.
(name . Xinglu Chen)(address . public@yoctocell.xyz)(address . 48232@debbugs.gnu.org)
87lf8l36so.fsf_-_@gnu.org
Hi,

Xinglu Chen <public@yoctocell.xyz> skribis:

Toggle quote (11 lines)
> The first patch adds the commitsigs extension for Mercurial, it allows
> users to sign Mercurial changesets (equivalent to Git commits) with
> GnuPG or OpenSSL.
>
> The second patch adds PYTHONPATH to the ‘native-search-paths’ field of
> Mercurial, this allows Mercurial to automatically find third-party
> extensions (like commitsigs) installed in
> /gnu/store/...-profile/lib/python3.8/site-packages/hgext3rd. By
> default, it only looks at
> /gnu/store/...-mercurial/lib/python3.8/site-packages/hgext3rd.

Is /hgext3rd a convention that upstream recommends?

Toggle quote (6 lines)
> However, I am not sure this is the best approach since it messes with
> PYTHONPATH, AFAIK there is no such things as a HGEXTENSIONS variable I
> could set. Another problem is that I have to hardcode “python3.8”, this
> would obviously have to be updated if the default Python version gets
> updated. I did try to do something like this:

Messing up with PYTHONPATH is indeed not great since it “belongs” to
Python.

Could we instead patch Mercurial so it honors a specific environment
variable, like HG_EXTENSION_PATH?

Thanks,
Ludo’.
X
X
Xinglu Chen wrote on 11 May 2021 13:27
Re: [bug#48232] [PATCH 0/2] Add mercurial-commitsigs and some changes to Mercurial.
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 48232@debbugs.gnu.org)
87bl9hh5nw.fsf@yoctocell.xyz
On Tue, May 11 2021, Ludovic Courtès wrote:

Toggle quote (13 lines)
> Hi,
>
> Xinglu Chen <public@yoctocell.xyz> skribis:
>
>> The second patch adds PYTHONPATH to the ‘native-search-paths’ field of
>> Mercurial, this allows Mercurial to automatically find third-party
>> extensions (like commitsigs) installed in
>> /gnu/store/...-profile/lib/python3.8/site-packages/hgext3rd. By
>> default, it only looks at
>> /gnu/store/...-mercurial/lib/python3.8/site-packages/hgext3rd.
>
> Is /hgext3rd a convention that upstream recommends?

I don’t think they mention it in their docs, but the hgext3rd/ directory
already contained one file (__init__.py), and I have seen one Mercurial
extension that put their Python files in a hgext3rd/ directory[1].

Toggle quote (12 lines)
>> However, I am not sure this is the best approach since it messes with
>> PYTHONPATH, AFAIK there is no such things as a HGEXTENSIONS variable I
>> could set. Another problem is that I have to hardcode “python3.8”, this
>> would obviously have to be updated if the default Python version gets
>> updated. I did try to do something like this:
>
> Messing up with PYTHONPATH is indeed not great since it “belongs” to
> Python.
>
> Could we instead patch Mercurial so it honors a specific environment
> variable, like HG_EXTENSION_PATH?

I am not familiar with the Mercurial codebase, but I guess we could try.
Or perhaps we could wrap the ‘hg’ binary to set PYTHONPATH so it finds
the extensions.

L
L
Ludovic Courtès wrote on 11 May 2021 14:29
(name . Xinglu Chen)(address . public@yoctocell.xyz)(address . 48232@debbugs.gnu.org)
87zgx1zc67.fsf@gnu.org
Xinglu Chen <public@yoctocell.xyz> skribis:

Toggle quote (19 lines)
> On Tue, May 11 2021, Ludovic Courtès wrote:
>
>> Hi,
>>
>> Xinglu Chen <public@yoctocell.xyz> skribis:
>>
>>> The second patch adds PYTHONPATH to the ‘native-search-paths’ field of
>>> Mercurial, this allows Mercurial to automatically find third-party
>>> extensions (like commitsigs) installed in
>>> /gnu/store/...-profile/lib/python3.8/site-packages/hgext3rd. By
>>> default, it only looks at
>>> /gnu/store/...-mercurial/lib/python3.8/site-packages/hgext3rd.
>>
>> Is /hgext3rd a convention that upstream recommends?
>
> I don’t think they mention it in their docs, but the hgext3rd/ directory
> already contained one file (__init__.py), and I have seen one Mercurial
> extension that put their Python files in a hgext3rd/ directory[1].

OK, sounds good.

Toggle quote (16 lines)
>>> However, I am not sure this is the best approach since it messes with
>>> PYTHONPATH, AFAIK there is no such things as a HGEXTENSIONS variable I
>>> could set. Another problem is that I have to hardcode “python3.8”, this
>>> would obviously have to be updated if the default Python version gets
>>> updated. I did try to do something like this:
>>
>> Messing up with PYTHONPATH is indeed not great since it “belongs” to
>> Python.
>>
>> Could we instead patch Mercurial so it honors a specific environment
>> variable, like HG_EXTENSION_PATH?
>
> I am not familiar with the Mercurial codebase, but I guess we could try.
> Or perhaps we could wrap the ‘hg’ binary to set PYTHONPATH so it finds
> the extensions.

I think wrapping is not an option because the wrapper doesn’t know where
the profile is. Let’s see if you can adjust hg to honor a new
environment variable, and if not, we’ll see…

Thanks!

Ludo’.
X
X
Xinglu Chen wrote on 11 May 2021 15:17
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 48232@debbugs.gnu.org)
877dk5h0kg.fsf@yoctocell.xyz
On Tue, May 11 2021, Ludovic Courtès wrote:

Toggle quote (19 lines)
>>>> However, I am not sure this is the best approach since it messes with
>>>> PYTHONPATH, AFAIK there is no such things as a HGEXTENSIONS variable I
>>>> could set. Another problem is that I have to hardcode “python3.8”, this
>>>> would obviously have to be updated if the default Python version gets
>>>> updated. I did try to do something like this:
>>>
>>> Messing up with PYTHONPATH is indeed not great since it “belongs” to
>>> Python.
>>>
>>> Could we instead patch Mercurial so it honors a specific environment
>>> variable, like HG_EXTENSION_PATH?
>>
>> I am not familiar with the Mercurial codebase, but I guess we could try.
>> Or perhaps we could wrap the ‘hg’ binary to set PYTHONPATH so it finds
>> the extensions.
>
> I think wrapping is not an option because the wrapper doesn’t know where
> the profile is.

Oh, right.

Toggle quote (3 lines)
> Let’s see if you can adjust hg to honor a new environment variable,
> and if not, we’ll see…

Hmm, I will try to see what I can do.
X
X
Xinglu Chen wrote on 12 May 2021 11:21
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 48232@debbugs.gnu.org)
874kf8cno8.fsf@yoctocell.xyz
On Tue, May 11 2021, Xinglu Chen wrote:

Toggle quote (5 lines)
>> Let’s see if you can adjust hg to honor a new environment variable,
>> and if not, we’ll see…
>
> Hmm, I will try to see what I can do.

I am no Python expert, but Mercurial is able to load the commitsigs.py
module when I applying the attached patch and putting the following in
~/.config/hg/hgrc.

[extensions]
commitsigs =

However, two of the tests are failing, they are related to multiple
people trying to push to the same repo at the same time. I don’t know
why they would fail, and I don’t know if my patch will break things in
the “real world”.
This is needed to make Mercurial read the HGEXTENSIONPATH to detect
third-party extensions. It is called HGEXTENSIONPATH and not
HG_EXTENSION_PATH to keep it consistent with other environment variables for
Mercurial, e.g. HGENCODINGAMBIGUOUS, HGEDITOR ... Hopefully I or someone else
will get this into Mercurial proper.

Toggle diff (20 lines)
diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -13,6 +13,7 @@
import imp
import inspect
import os
+import sys
from .i18n import (
_,
@@ -108,6 +109,8 @@
def _importh(name):
"""import and return the <name> module"""
+ # Read HGEXTENSIONPATH environment variable when import extensions.
+ sys.path.append(os.getenv("HGEXTENSIONPATH"))
mod = __import__(pycompat.sysstr(name))
components = name.split(b'.')
for comp in components[1:]:
L
L
Ludovic Courtès wrote on 12 May 2021 22:56
(name . Xinglu Chen)(address . public@yoctocell.xyz)(address . 48232@debbugs.gnu.org)
87k0o3u0wk.fsf@gnu.org
Hi,

Xinglu Chen <public@yoctocell.xyz> skribis:

[...]

Toggle quote (29 lines)
> However, two of the tests are failing, they are related to multiple
> people trying to push to the same repo at the same time. I don’t know
> why they would fail, and I don’t know if my patch will break things in
> the “real world”.
>
> This is needed to make Mercurial read the HGEXTENSIONPATH to detect
> third-party extensions. It is called HGEXTENSIONPATH and not
> HG_EXTENSION_PATH to keep it consistent with other environment variables for
> Mercurial, e.g. HGENCODINGAMBIGUOUS, HGEDITOR ... Hopefully I or someone else
> will get this into Mercurial proper.
>
> diff --git a/mercurial/extensions.py b/mercurial/extensions.py
> --- a/mercurial/extensions.py
> +++ b/mercurial/extensions.py
> @@ -13,6 +13,7 @@
> import imp
> import inspect
> import os
> +import sys
>
> from .i18n import (
> _,
> @@ -108,6 +109,8 @@
>
> def _importh(name):
> """import and return the <name> module"""
> + # Read HGEXTENSIONPATH environment variable when import extensions.
> + sys.path.append(os.getenv("HGEXTENSIONPATH"))

Perhaps you need to handle the case where HGEXTENSIONPATH is undefined?
(This could explain the test failures that you see, no?)

Also, I’m no Pythonista, but if ‘sys.path’ is a list, then you have to
split the value of HGEXTENSIONPATH on colons.

Thanks,
Ludo’.
X
X
Xinglu Chen wrote on 14 May 2021 13:52
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 48232@debbugs.gnu.org)
8735upzg64.fsf@yoctocell.xyz
On Wed, May 12 2021, Ludovic Courtès wrote:

Toggle quote (3 lines)
> Perhaps you need to handle the case where HGEXTENSIONPATH is undefined?
> (This could explain the test failures that you see, no?)

That could be the case.

Toggle quote (3 lines)
> Also, I’m no Pythonista, but if ‘sys.path’ is a list, then you have to
> split the value of HGEXTENSIONPATH on colons.

Good point, will do that.
X
X
Xinglu Chen wrote on 15 May 2021 11:17
[PATCH v2 0/2] Add hg-commitsigs and some changes to Mercurial.
(address . 48232@debbugs.gnu.org)(name . Ludovic Courtès)(address . ludo@gnu.org)
cover.1621069817.git.public@yoctocell.xyz
Changes since v1:

* Patch Mercurial to make it read the HGEXTENSIONPATH environment
variable to make it load third-party extensions.

* Rename ‘mercurial-commitsigs’ to ‘hg-commitsigs’ because to keep
things more consistent (we already have ‘python-hg-evolve’, not sure
if the ‘python-’ prefix is necessary, though).

Xinglu Chen (2):
gnu: Add hg-commitsigs.
gnu: mercurial: Patch to make it read HGEXTENSIONPATH.

gnu/local.mk | 1 +
.../patches/mercurial-hg-extension-path.patch | 29 ++++++++
gnu/packages/version-control.scm | 69 +++++++++++++++++++
3 files changed, 99 insertions(+)
create mode 100644 gnu/packages/patches/mercurial-hg-extension-path.patch


base-commit: fbb099a4481ce682bdaaaffea619c5273fd0d3b0
--
2.31.1
X
X
Xinglu Chen wrote on 15 May 2021 11:17
[PATCH v2 1/2] gnu: Add hg-commitsigs.
(address . 48232@debbugs.gnu.org)(name . Ludovic Courtès)(address . ludo@gnu.org)
b67a7e4eca3c8ad3631d958f6aee5de5bdcf9d8b.1621069817.git.public@yoctocell.xyz
* gnu/packages/version-control.scm (hg-commitsigs): New variable.
---
gnu/packages/version-control.scm | 63 ++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)

Toggle diff (90 lines)
diff --git a/gnu/packages/version-control.scm b/gnu/packages/version-control.scm
index 5438f6349c..1e55c73c0c 100644
--- a/gnu/packages/version-control.scm
+++ b/gnu/packages/version-control.scm
@@ -62,6 +62,7 @@
#:use-module (guix download)
#:use-module (guix git-download)
#:use-module (guix hg-download)
+ #:use-module (guix build python-build-system)
#:use-module (guix build-system cmake)
#:use-module (guix build-system copy)
#:use-module (guix build-system gnu)
@@ -88,6 +89,7 @@
#:use-module (gnu packages gl)
#:use-module (gnu packages glib)
#:use-module (gnu packages gnome)
+ #:use-module (gnu packages gnupg)
#:use-module (gnu packages golang)
#:use-module (gnu packages groff)
#:use-module (gnu packages guile)
@@ -1716,6 +1718,67 @@ interface.")
history. It implements the changeset evolution concept for Mercurial.")
(license license:gpl2)))
+(define-public hg-commitsigs
+ ;; Latest tag is 11 years old.
+ (let ((changeset "b53eb6862bff")
+ (revision "0"))
+ (package
+ (name "hg-commitsigs")
+ (version (git-version "0.1.0" revision changeset))
+ (source (origin
+ (method hg-fetch)
+ (uri (hg-reference
+ (url "https://foss.heptapod.net/mercurial/commitsigs")
+ (changeset changeset)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "059gm66q06m6ayl4brsc517zkw3ahmz249b6xm1m32ac5y24wb9x"))))
+ (build-system copy-build-system)
+ (arguments
+ `(#:imported-modules ((guix build python-build-system)
+ ,@%copy-build-system-modules)
+ #:modules ((srfi srfi-1)
+ (guix build python-build-system)
+ ;; Don't use `%copy-build-system-modules' because
+ ;; `standard-phases' from (guix build gnu-build-system)
+ ;; shadows the one from (guix build copy-build-system),
+ ;; which is the one we actually want.
+ (guix build copy-build-system)
+ ((guix build gnu-build-system) #:prefix gnu)
+ (guix build utils)
+ (guix build gremlin)
+ (ice-9 ftw)
+ (guix elf))
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'patch-paths
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let ((gpg (string-append (assoc-ref inputs "gnupg")
+ "/bin/gpg"))
+ (openssl (string-append (assoc-ref inputs "openssl")
+ "/bin/openssl")))
+ (substitute* "commitsigs.py"
+ (("b'gpg',") (string-append "b'" gpg "',"))
+ (("b'openssl',") (string-append "b'" openssl "',")))))))
+ #:install-plan
+ `(("commitsigs.py" ,(string-append "lib/python"
+ (python-version
+ (assoc-ref %build-inputs "python"))
+ "/site-packages/hgext3rd/commitsigs.py")))))
+ (native-inputs
+ `(("python" ,python)))
+ (inputs
+ `(("gnupg" ,gnupg)
+ ("openssl" ,openssl)))
+ (home-page "https://foss.heptapod.net/mercurial/commitsigs")
+ (synopsis "Automatic signing of changeset hashes")
+ (description "This package provides a Mercurial extension for signing
+the changeset hash of commits. The signure is embedded directly in the
+changeset itself; there won't be any extra commits. Either GnuPG or OpenSSL
+can be used for signing.")
+ (license license:gpl3+))))
+
(define-public neon
(package
(name "neon")
--
2.31.1
X
X
Xinglu Chen wrote on 15 May 2021 11:17
[PATCH v2 2/2] gnu: mercurial: Patch to make it read HGEXTENSIONPATH.
(address . 48232@debbugs.gnu.org)(name . Ludovic Courtès)(address . ludo@gnu.org)
c5dff7408ce009cfc89f1c02a2d4e2358840ec4d.1621069817.git.public@yoctocell.xyz
This will make Mercurial be able to find third-party extensions installed with
Guix, without having to set PYTHONPATH.

* gnu/packages/patches/mercurial-hg-extension-path.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register the patch.
* gnu/packages/version-control.scm (mercurial)[origin](patches): Apply the
patch.
[native-search-paths]: Add HGEXTENSIONPATH.
---
gnu/local.mk | 1 +
.../patches/mercurial-hg-extension-path.patch | 29 +++++++++++++++++++
gnu/packages/version-control.scm | 6 ++++
3 files changed, 36 insertions(+)
create mode 100644 gnu/packages/patches/mercurial-hg-extension-path.patch

Toggle diff (73 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index c3b0274945..afb745a5fc 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1412,6 +1412,7 @@ dist_patch_DATA = \
%D%/packages/patches/mcrypt-CVE-2012-4527.patch \
%D%/packages/patches/libmemcached-build-with-gcc7.patch \
%D%/packages/patches/libmhash-hmac-fix-uaf.patch \
+ %D%/packages/patches/mercurial-hg-extension-path.patch \
%D%/packages/patches/mesa-skip-tests.patch \
%D%/packages/patches/mescc-tools-boot.patch \
%D%/packages/patches/meson-for-build-rpath.patch \
diff --git a/gnu/packages/patches/mercurial-hg-extension-path.patch b/gnu/packages/patches/mercurial-hg-extension-path.patch
new file mode 100644
index 0000000000..d1073dd01c
--- /dev/null
+++ b/gnu/packages/patches/mercurial-hg-extension-path.patch
@@ -0,0 +1,29 @@
+This is needed to make Mercurial read the HGEXTENSIONPATH to detect
+third-party extensions. It is called HGEXTENSIONPATH and not
+HG_EXTENSION_PATH to keep it consistent with other environment variables for
+Mercurial, e.g. HGENCODINGAMBIGUOUS, HGEDITOR ... Hopefully I or someone else
+will get this into Mercurial proper.
+
+diff --git a/mercurial/extensions.py b/mercurial/extensions.py
+--- a/mercurial/extensions.py
++++ b/mercurial/extensions.py
+@@ -13,6 +13,7 @@
+ import imp
+ import inspect
+ import os
++import sys
+
+ from .i18n import (
+ _,
+@@ -108,6 +109,11 @@
+
+ def _importh(name):
+ """import and return the <name> module"""
++ # Read HGEXTENSIONSPATH environment variable when import extensions.
++ extension_path = os.getenv("HGEXTENSIONSPATH")
++ if extension_path is not None:
++ for path in extension_path:
++ sys.path.append(path)
+ mod = __import__(pycompat.sysstr(name))
+ components = name.split(b'.')
+ for comp in components[1:]:
diff --git a/gnu/packages/version-control.scm b/gnu/packages/version-control.scm
index 1e55c73c0c..c3be5f1c42 100644
--- a/gnu/packages/version-control.scm
+++ b/gnu/packages/version-control.scm
@@ -1614,6 +1614,7 @@ execution of any hook written in any language before every commit.")
(method url-fetch)
(uri (string-append "https://www.mercurial-scm.org/"
"release/mercurial-" version ".tar.gz"))
+ (patches (search-patches "mercurial-hg-extension-path.patch"))
(sha256
(base32
"17rhlmmkqz5ll3k68jfzpcifg3nndbcbc2nx7kw8xn3qcj7nlpgw"))))
@@ -1684,6 +1685,11 @@ execution of any hook written in any language before every commit.")
("which" ,which)))
(inputs
`(("python" ,python)))
+ ;; Find third-party extensions.
+ (native-search-paths
+ (list (search-path-specification
+ (variable "HGEXTENSIONPATH")
+ (files '("lib/python3.8/site-packages/hgext3rd")))))
(home-page "https://www.mercurial-scm.org/")
(synopsis "Decentralized version control system")
(description
--
2.31.1
L
L
Ludovic Courtès wrote on 16 May 2021 23:14
Re: [PATCH v2 1/2] gnu: Add hg-commitsigs.
(name . Xinglu Chen)(address . public@yoctocell.xyz)(address . 48232@debbugs.gnu.org)
87r1i6fkjr.fsf@gnu.org
Hi,

Xinglu Chen <public@yoctocell.xyz> skribis:

Toggle quote (2 lines)
> * gnu/packages/version-control.scm (hg-commitsigs): New variable.

[...]

Toggle quote (2 lines)
> + (license license:gpl3+))))

Changed to ‘gpl2’ (‘commitsigs.py’ says GPLv2 only) and applied.

Thanks!

Ludo’.
L
L
Ludovic Courtès wrote on 16 May 2021 23:16
Re: [PATCH v2 2/2] gnu: mercurial: Patch to make it read HGEXTENSIONPATH.
(name . Xinglu Chen)(address . public@yoctocell.xyz)(address . 48232@debbugs.gnu.org)
87mtsufkh4.fsf@gnu.org
Xinglu Chen <public@yoctocell.xyz> skribis:

Toggle quote (9 lines)
> This will make Mercurial be able to find third-party extensions installed with
> Guix, without having to set PYTHONPATH.
>
> * gnu/packages/patches/mercurial-hg-extension-path.patch: New file.
> * gnu/local.mk (dist_patch_DATA): Register the patch.
> * gnu/packages/version-control.scm (mercurial)[origin](patches): Apply the
> patch.
> [native-search-paths]: Add HGEXTENSIONPATH.

Perfect. Applied, thanks!

Ludo’.
X
X
Xinglu Chen wrote on 16 May 2021 23:33
Re: [bug#48232] [PATCH v2 1/2] gnu: Add hg-commitsigs.
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 48232@debbugs.gnu.org)
87sg2mfjo2.fsf@yoctocell.xyz
On Sun, May 16 2021, Ludovic Courtès wrote:

Toggle quote (8 lines)
> Hi,
>
> Xinglu Chen <public@yoctocell.xyz> skribis:
>
>> + (license license:gpl3+))))
>
> Changed to ‘gpl2’ (‘commitsigs.py’ says GPLv2 only) and applied.

Good catch, looks like COPYING was for the logo and not the code itself.

Thanks!
-----BEGIN PGP SIGNATURE-----

iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmChj60VHHB1YmxpY0B5
b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x5xZ4QAKKJpp/1MN+HQ9a+JuXxGzeL34UZ
vRM3Sdcjl6dNGMhvQPZUOyQPBop3Wlgk8lwQ4SWHwOLXNbJJYmMM3/azOJfqYKKH
XrVUWmzQgq0FIYjBCmZNsrrfR20T3J6gdZwpHXp1bJqez9JaZbQJwbwxHlYCRob/
5XDTuWWJzh3xGA7Lc7QWVG+fn+5BFFgbOaURR/1yiyEBBYTm88BsiQ09wOrYCq8Z
Pc/T5pzHqJhhqLpv/U+o+4keeo6GUurwD5RolsMVOW1F9VvRwMa01P81u4kYYxZm
zsF9hL5h6UJ+tnD/XoI/tM2o6O40lFds2y39C6S/bB9EHMmHQ+nIuoDPUbaIFJOE
qbs+UmBhDHVAkr5OkVk9j3ig8a+yDnGo4u2UYEln8AxxXqlboFqth2W1ySVdaerJ
vkhflzsrpuczfFR06qOCtuLkTfTQPXxQ4mevNwatCl6QFo2senRVs32Ec2fQ/ahc
qbjQ4S5dXzmr4tf/QyoOtQjfI1YMC/f30GB5kYpnhbVmrMSltH6WTNegMeAGZNOt
bUokTevw0QUTgfn0DVyNLij0Dl60FXI6Y+5jjl6joNvcsUAVuyvjNqRPyQdldKmr
BPo6VodOdUS8tdIdrQjtLjOW0dJDDCJnxxUZdlamzsBVH/Ar4ntQfPfYbpvRg/lr
rg6BYtlguXYWsfwQ
=/SK/
-----END PGP SIGNATURE-----

X
X
Xinglu Chen wrote on 17 May 2021 22:07
Re: [bug#48232] [PATCH v2 0/2] Add hg-commitsigs and some changes to Mercurial.
(address . 48232-done@debbugs.gnu.org)
877djxjf8k.fsf@yoctocell.xyz
The patches have been applied, closing.
Closed
?