GNU bug report logs - #48232
[PATCH 0/2] Add mercurial-commitsigs and some changes to Mercurial.

Previous Next

Package: guix-patches;

Reported by: Xinglu Chen <public <at> yoctocell.xyz>

Date: Tue, 4 May 2021 20:59:01 UTC

Severity: normal

Tags: patch

Done: Xinglu Chen <public <at> yoctocell.xyz>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 48232 in the body.
You can then email your comments to 48232 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#48232; Package guix-patches. (Tue, 04 May 2021 20:59:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Xinglu Chen <public <at> yoctocell.xyz>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Tue, 04 May 2021 20:59:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: guix-patches <at> gnu.org
Subject: [PATCH 0/2] Add mercurial-commitsigs and some changes to Mercurial.
Date: Tue, 04 May 2021 22:58:01 +0200
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

[1]: https://yhetil.org/guix-devel/878s6u2pco.fsf <at> trop.in/
[2]: https://lists.sr.ht/~abcdw/rde-devel/patches/22421

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




Information forwarded to guix-patches <at> gnu.org:
bug#48232; Package guix-patches. (Tue, 04 May 2021 21:01:02 GMT) Full text and rfc822 format available.

Message #8 received at 48232 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 48232 <at> debbugs.gnu.org
Subject: [PATCH 1/2] gnu: Add mercurial-commitsigs.
Date: Tue, 04 May 2021 23:00:03 +0200
* 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(+)

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






Information forwarded to guix-patches <at> gnu.org:
bug#48232; Package guix-patches. (Tue, 04 May 2021 21:01:02 GMT) Full text and rfc822 format available.

Message #11 received at 48232 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 48232 <at> debbugs.gnu.org
Subject: [PATCH 2/2] gnu: mercurial: Add PYTHONPATH to
Date: Tue, 04 May 2021 23:00:10 +0200
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(+)

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






Information forwarded to guix-patches <at> gnu.org:
bug#48232; Package guix-patches. (Tue, 11 May 2021 10:27:02 GMT) Full text and rfc822 format available.

Message #14 received at 48232 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Xinglu Chen <public <at> yoctocell.xyz>
Cc: 48232 <at> debbugs.gnu.org
Subject: Re: bug#48232: [PATCH 0/2] Add mercurial-commitsigs and some
 changes to Mercurial.
Date: Tue, 11 May 2021 12:26:31 +0200
Hi,

Xinglu Chen <public <at> yoctocell.xyz> skribis:

> 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?

> 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’.




Information forwarded to guix-patches <at> gnu.org:
bug#48232; Package guix-patches. (Tue, 11 May 2021 11:28:01 GMT) Full text and rfc822 format available.

Message #17 received at 48232 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 48232 <at> debbugs.gnu.org
Subject: Re: [bug#48232] [PATCH 0/2] Add mercurial-commitsigs and some
 changes to Mercurial.
Date: Tue, 11 May 2021 13:27:15 +0200
On Tue, May 11 2021, Ludovic Courtès wrote:

> Hi,
>
> Xinglu Chen <public <at> 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].

>> 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.

[1]: https://foss.heptapod.net/mercurial/hg-credentials




Information forwarded to guix-patches <at> gnu.org:
bug#48232; Package guix-patches. (Tue, 11 May 2021 12:30:01 GMT) Full text and rfc822 format available.

Message #20 received at 48232 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Xinglu Chen <public <at> yoctocell.xyz>
Cc: 48232 <at> debbugs.gnu.org
Subject: Re: [bug#48232] [PATCH 0/2] Add mercurial-commitsigs and some
 changes to Mercurial.
Date: Tue, 11 May 2021 14:29:20 +0200
Xinglu Chen <public <at> yoctocell.xyz> skribis:

> On Tue, May 11 2021, Ludovic Courtès wrote:
>
>> Hi,
>>
>> Xinglu Chen <public <at> 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.

>>> 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’.




Information forwarded to guix-patches <at> gnu.org:
bug#48232; Package guix-patches. (Tue, 11 May 2021 13:18:01 GMT) Full text and rfc822 format available.

Message #23 received at 48232 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 48232 <at> debbugs.gnu.org
Subject: Re: [bug#48232] [PATCH 0/2] Add mercurial-commitsigs and some
 changes to Mercurial.
Date: Tue, 11 May 2021 15:17:19 +0200
On Tue, May 11 2021, Ludovic Courtès wrote:

>>>> 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.

> 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.





Information forwarded to guix-patches <at> gnu.org:
bug#48232; Package guix-patches. (Wed, 12 May 2021 09:22:01 GMT) Full text and rfc822 format available.

Message #26 received at 48232 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 48232 <at> debbugs.gnu.org
Subject: Re: [bug#48232] [PATCH 0/2] Add mercurial-commitsigs and some
 changes to Mercurial.
Date: Wed, 12 May 2021 11:21:43 +0200
[Message part 1 (text/plain, inline)]
On Tue, May 11 2021, Xinglu Chen wrote:

>> 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”.

[mercurial-hg-extension-path.patch (text/x-patch, attachment)]

Information forwarded to guix-patches <at> gnu.org:
bug#48232; Package guix-patches. (Wed, 12 May 2021 20:57:02 GMT) Full text and rfc822 format available.

Message #29 received at 48232 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Xinglu Chen <public <at> yoctocell.xyz>
Cc: 48232 <at> debbugs.gnu.org
Subject: Re: [bug#48232] [PATCH 0/2] Add mercurial-commitsigs and some
 changes to Mercurial.
Date: Wed, 12 May 2021 22:56:11 +0200
Hi,

Xinglu Chen <public <at> yoctocell.xyz> skribis:

[...]

> 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’.




Information forwarded to guix-patches <at> gnu.org:
bug#48232; Package guix-patches. (Fri, 14 May 2021 11:53:01 GMT) Full text and rfc822 format available.

Message #32 received at 48232 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 48232 <at> debbugs.gnu.org
Subject: Re: [bug#48232] [PATCH 0/2] Add mercurial-commitsigs and some
 changes to Mercurial.
Date: Fri, 14 May 2021 13:52:03 +0200
On Wed, May 12 2021, Ludovic Courtès wrote:

> 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.

> 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.





Information forwarded to guix-patches <at> gnu.org:
bug#48232; Package guix-patches. (Sat, 15 May 2021 09:18:01 GMT) Full text and rfc822 format available.

Message #35 received at 48232 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 48232 <at> debbugs.gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH v2 0/2] Add hg-commitsigs and some changes to Mercurial.
Date: Sat, 15 May 2021 11:17:09 +0200
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




Information forwarded to guix-patches <at> gnu.org:
bug#48232; Package guix-patches. (Sat, 15 May 2021 09:18:02 GMT) Full text and rfc822 format available.

Message #38 received at 48232 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 48232 <at> debbugs.gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH v2 1/2] gnu: Add hg-commitsigs.
Date: Sat, 15 May 2021 11:17:11 +0200
* gnu/packages/version-control.scm (hg-commitsigs): New variable.
---
 gnu/packages/version-control.scm | 63 ++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

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




Information forwarded to guix-patches <at> gnu.org:
bug#48232; Package guix-patches. (Sat, 15 May 2021 09:18:02 GMT) Full text and rfc822 format available.

Message #41 received at 48232 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 48232 <at> debbugs.gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH v2 2/2] gnu: mercurial: Patch to make it read HGEXTENSIONPATH.
Date: Sat, 15 May 2021 11:17:12 +0200
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

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




Information forwarded to guix-patches <at> gnu.org:
bug#48232; Package guix-patches. (Sun, 16 May 2021 21:15:01 GMT) Full text and rfc822 format available.

Message #44 received at 48232 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Xinglu Chen <public <at> yoctocell.xyz>
Cc: 48232 <at> debbugs.gnu.org
Subject: Re: [PATCH v2 1/2] gnu: Add hg-commitsigs.
Date: Sun, 16 May 2021 23:14:32 +0200
Hi,

Xinglu Chen <public <at> yoctocell.xyz> skribis:

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

[...]

> +      (license license:gpl3+))))

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

Thanks!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#48232; Package guix-patches. (Sun, 16 May 2021 21:17:02 GMT) Full text and rfc822 format available.

Message #47 received at 48232 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Xinglu Chen <public <at> yoctocell.xyz>
Cc: 48232 <at> debbugs.gnu.org
Subject: Re: [PATCH v2 2/2] gnu: mercurial: Patch to make it read
 HGEXTENSIONPATH.
Date: Sun, 16 May 2021 23:16:07 +0200
Xinglu Chen <public <at> yoctocell.xyz> skribis:

> 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’.




Information forwarded to guix-patches <at> gnu.org:
bug#48232; Package guix-patches. (Sun, 16 May 2021 21:34:02 GMT) Full text and rfc822 format available.

Message #50 received at 48232 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 48232 <at> debbugs.gnu.org
Subject: Re: [bug#48232] [PATCH v2 1/2] gnu: Add hg-commitsigs.
Date: Sun, 16 May 2021 23:33:33 +0200
[Message part 1 (text/plain, inline)]
On Sun, May 16 2021, Ludovic Courtès wrote:

> Hi,
>
> Xinglu Chen <public <at> 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!

[signature.asc (application/pgp-signature, inline)]

Reply sent to Xinglu Chen <public <at> yoctocell.xyz>:
You have taken responsibility. (Mon, 17 May 2021 20:09:02 GMT) Full text and rfc822 format available.

Notification sent to Xinglu Chen <public <at> yoctocell.xyz>:
bug acknowledged by developer. (Mon, 17 May 2021 20:09:02 GMT) Full text and rfc822 format available.

Message #55 received at 48232-done <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 48232-done <at> debbugs.gnu.org
Subject: Re: [bug#48232] [PATCH v2 0/2] Add hg-commitsigs and some changes
 to Mercurial.
Date: Mon, 17 May 2021 22:07:55 +0200
The patches have been applied, closing.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 15 Jun 2021 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 315 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.