unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / Atom feed
* [bug#48232] [PATCH 0/2] Add mercurial-commitsigs and some changes to Mercurial.
       [not found] <cover.1620159508.git.public@yoctocell.xyz>
@ 2021-05-04 20:58 ` Xinglu Chen
  2021-05-11 10:26   ` Ludovic Courtès
  2021-05-15  9:17   ` [bug#48232] [PATCH v2 0/2] Add hg-commitsigs " Xinglu Chen
  2021-05-04 21:00 ` [bug#48232] [PATCH 1/2] gnu: Add mercurial-commitsigs Xinglu Chen
  2021-05-04 21:00 ` [bug#48232] [PATCH 2/2] gnu: mercurial: Add PYTHONPATH to Xinglu Chen
  2 siblings, 2 replies; 15+ messages in thread
From: Xinglu Chen @ 2021-05-04 20:58 UTC (permalink / raw)
  To: 48232

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




^ permalink raw reply	[flat|nested] 15+ messages in thread

* [bug#48232] [PATCH 1/2] gnu: Add mercurial-commitsigs.
       [not found] <cover.1620159508.git.public@yoctocell.xyz>
  2021-05-04 20:58 ` [bug#48232] [PATCH 0/2] Add mercurial-commitsigs and some changes to Mercurial Xinglu Chen
@ 2021-05-04 21:00 ` Xinglu Chen
  2021-05-04 21:00 ` [bug#48232] [PATCH 2/2] gnu: mercurial: Add PYTHONPATH to Xinglu Chen
  2 siblings, 0 replies; 15+ messages in thread
From: Xinglu Chen @ 2021-05-04 21:00 UTC (permalink / raw)
  To: 48232

* 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






^ permalink raw reply	[flat|nested] 15+ messages in thread

* [bug#48232] [PATCH 2/2] gnu: mercurial: Add PYTHONPATH to
       [not found] <cover.1620159508.git.public@yoctocell.xyz>
  2021-05-04 20:58 ` [bug#48232] [PATCH 0/2] Add mercurial-commitsigs and some changes to Mercurial Xinglu Chen
  2021-05-04 21:00 ` [bug#48232] [PATCH 1/2] gnu: Add mercurial-commitsigs Xinglu Chen
@ 2021-05-04 21:00 ` Xinglu Chen
  2 siblings, 0 replies; 15+ messages in thread
From: Xinglu Chen @ 2021-05-04 21:00 UTC (permalink / raw)
  To: 48232

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






^ permalink raw reply	[flat|nested] 15+ messages in thread

* [bug#48232] [PATCH 0/2] Add mercurial-commitsigs and some changes to Mercurial.
  2021-05-04 20:58 ` [bug#48232] [PATCH 0/2] Add mercurial-commitsigs and some changes to Mercurial Xinglu Chen
@ 2021-05-11 10:26   ` Ludovic Courtès
  2021-05-11 11:27     ` Xinglu Chen
  2021-05-15  9:17   ` [bug#48232] [PATCH v2 0/2] Add hg-commitsigs " Xinglu Chen
  1 sibling, 1 reply; 15+ messages in thread
From: Ludovic Courtès @ 2021-05-11 10:26 UTC (permalink / raw)
  To: Xinglu Chen; +Cc: 48232

Hi,

Xinglu Chen <public@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’.




^ permalink raw reply	[flat|nested] 15+ messages in thread

* [bug#48232] [PATCH 0/2] Add mercurial-commitsigs and some changes to Mercurial.
  2021-05-11 10:26   ` Ludovic Courtès
@ 2021-05-11 11:27     ` Xinglu Chen
  2021-05-11 12:29       ` Ludovic Courtès
  0 siblings, 1 reply; 15+ messages in thread
From: Xinglu Chen @ 2021-05-11 11:27 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 48232

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

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




^ permalink raw reply	[flat|nested] 15+ messages in thread

* [bug#48232] [PATCH 0/2] Add mercurial-commitsigs and some changes to Mercurial.
  2021-05-11 11:27     ` Xinglu Chen
@ 2021-05-11 12:29       ` Ludovic Courtès
  2021-05-11 13:17         ` Xinglu Chen
  0 siblings, 1 reply; 15+ messages in thread
From: Ludovic Courtès @ 2021-05-11 12:29 UTC (permalink / raw)
  To: Xinglu Chen; +Cc: 48232

Xinglu Chen <public@yoctocell.xyz> skribis:

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

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




^ permalink raw reply	[flat|nested] 15+ messages in thread

* [bug#48232] [PATCH 0/2] Add mercurial-commitsigs and some changes to Mercurial.
  2021-05-11 12:29       ` Ludovic Courtès
@ 2021-05-11 13:17         ` Xinglu Chen
  2021-05-12  9:21           ` Xinglu Chen
  0 siblings, 1 reply; 15+ messages in thread
From: Xinglu Chen @ 2021-05-11 13:17 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 48232

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.





^ permalink raw reply	[flat|nested] 15+ messages in thread

* [bug#48232] [PATCH 0/2] Add mercurial-commitsigs and some changes to Mercurial.
  2021-05-11 13:17         ` Xinglu Chen
@ 2021-05-12  9:21           ` Xinglu Chen
  2021-05-12 20:56             ` Ludovic Courtès
  0 siblings, 1 reply; 15+ messages in thread
From: Xinglu Chen @ 2021-05-12  9:21 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 48232

[-- Attachment #1: Type: text/plain, Size: 637 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: hg-extension-path-patch --]
[-- Type: text/x-patch, Size: 874 bytes --]

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"))
     mod = __import__(pycompat.sysstr(name))
     components = name.split(b'.')
     for comp in components[1:]:

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [bug#48232] [PATCH 0/2] Add mercurial-commitsigs and some changes to Mercurial.
  2021-05-12  9:21           ` Xinglu Chen
@ 2021-05-12 20:56             ` Ludovic Courtès
  2021-05-14 11:52               ` Xinglu Chen
  0 siblings, 1 reply; 15+ messages in thread
From: Ludovic Courtès @ 2021-05-12 20:56 UTC (permalink / raw)
  To: Xinglu Chen; +Cc: 48232

Hi,

Xinglu Chen <public@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’.




^ permalink raw reply	[flat|nested] 15+ messages in thread

* [bug#48232] [PATCH 0/2] Add mercurial-commitsigs and some changes to Mercurial.
  2021-05-12 20:56             ` Ludovic Courtès
@ 2021-05-14 11:52               ` Xinglu Chen
  0 siblings, 0 replies; 15+ messages in thread
From: Xinglu Chen @ 2021-05-14 11:52 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 48232

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.





^ permalink raw reply	[flat|nested] 15+ messages in thread

* [bug#48232] [PATCH v2 0/2] Add hg-commitsigs and some changes to Mercurial.
  2021-05-04 20:58 ` [bug#48232] [PATCH 0/2] Add mercurial-commitsigs and some changes to Mercurial Xinglu Chen
  2021-05-11 10:26   ` Ludovic Courtès
@ 2021-05-15  9:17   ` Xinglu Chen
  2021-05-15  9:17     ` [bug#48232] [PATCH v2 1/2] gnu: Add hg-commitsigs Xinglu Chen
  2021-05-15  9:17     ` [bug#48232] [PATCH v2 2/2] gnu: mercurial: Patch to make it read HGEXTENSIONPATH Xinglu Chen
  1 sibling, 2 replies; 15+ messages in thread
From: Xinglu Chen @ 2021-05-15  9:17 UTC (permalink / raw)
  To: 48232; +Cc: Ludovic Courtès

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




^ permalink raw reply	[flat|nested] 15+ messages in thread

* [bug#48232] [PATCH v2 1/2] gnu: Add hg-commitsigs.
  2021-05-15  9:17   ` [bug#48232] [PATCH v2 0/2] Add hg-commitsigs " Xinglu Chen
@ 2021-05-15  9:17     ` Xinglu Chen
  2021-05-16 21:14       ` Ludovic Courtès
  2021-05-15  9:17     ` [bug#48232] [PATCH v2 2/2] gnu: mercurial: Patch to make it read HGEXTENSIONPATH Xinglu Chen
  1 sibling, 1 reply; 15+ messages in thread
From: Xinglu Chen @ 2021-05-15  9:17 UTC (permalink / raw)
  To: 48232; +Cc: Ludovic Courtès

* 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




^ permalink raw reply	[flat|nested] 15+ messages in thread

* [bug#48232] [PATCH v2 2/2] gnu: mercurial: Patch to make it read HGEXTENSIONPATH.
  2021-05-15  9:17   ` [bug#48232] [PATCH v2 0/2] Add hg-commitsigs " Xinglu Chen
  2021-05-15  9:17     ` [bug#48232] [PATCH v2 1/2] gnu: Add hg-commitsigs Xinglu Chen
@ 2021-05-15  9:17     ` Xinglu Chen
  2021-05-16 21:16       ` Ludovic Courtès
  1 sibling, 1 reply; 15+ messages in thread
From: Xinglu Chen @ 2021-05-15  9:17 UTC (permalink / raw)
  To: 48232; +Cc: Ludovic Courtès

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




^ permalink raw reply	[flat|nested] 15+ messages in thread

* [bug#48232] [PATCH v2 1/2] gnu: Add hg-commitsigs.
  2021-05-15  9:17     ` [bug#48232] [PATCH v2 1/2] gnu: Add hg-commitsigs Xinglu Chen
@ 2021-05-16 21:14       ` Ludovic Courtès
  0 siblings, 0 replies; 15+ messages in thread
From: Ludovic Courtès @ 2021-05-16 21:14 UTC (permalink / raw)
  To: Xinglu Chen; +Cc: 48232

Hi,

Xinglu Chen <public@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’.




^ permalink raw reply	[flat|nested] 15+ messages in thread

* [bug#48232] [PATCH v2 2/2] gnu: mercurial: Patch to make it read HGEXTENSIONPATH.
  2021-05-15  9:17     ` [bug#48232] [PATCH v2 2/2] gnu: mercurial: Patch to make it read HGEXTENSIONPATH Xinglu Chen
@ 2021-05-16 21:16       ` Ludovic Courtès
  0 siblings, 0 replies; 15+ messages in thread
From: Ludovic Courtès @ 2021-05-16 21:16 UTC (permalink / raw)
  To: Xinglu Chen; +Cc: 48232

Xinglu Chen <public@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’.




^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-05-16 21:17 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <cover.1620159508.git.public@yoctocell.xyz>
2021-05-04 20:58 ` [bug#48232] [PATCH 0/2] Add mercurial-commitsigs and some changes to Mercurial Xinglu Chen
2021-05-11 10:26   ` Ludovic Courtès
2021-05-11 11:27     ` Xinglu Chen
2021-05-11 12:29       ` Ludovic Courtès
2021-05-11 13:17         ` Xinglu Chen
2021-05-12  9:21           ` Xinglu Chen
2021-05-12 20:56             ` Ludovic Courtès
2021-05-14 11:52               ` Xinglu Chen
2021-05-15  9:17   ` [bug#48232] [PATCH v2 0/2] Add hg-commitsigs " Xinglu Chen
2021-05-15  9:17     ` [bug#48232] [PATCH v2 1/2] gnu: Add hg-commitsigs Xinglu Chen
2021-05-16 21:14       ` Ludovic Courtès
2021-05-15  9:17     ` [bug#48232] [PATCH v2 2/2] gnu: mercurial: Patch to make it read HGEXTENSIONPATH Xinglu Chen
2021-05-16 21:16       ` Ludovic Courtès
2021-05-04 21:00 ` [bug#48232] [PATCH 1/2] gnu: Add mercurial-commitsigs Xinglu Chen
2021-05-04 21:00 ` [bug#48232] [PATCH 2/2] gnu: mercurial: Add PYTHONPATH to Xinglu Chen

unofficial mirror of guix-patches@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/guix-patches/1 guix-patches/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guix-patches guix-patches/ https://yhetil.org/guix-patches \
		guix-patches@gnu.org
	public-inbox-index guix-patches

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://news.yhetil.org/yhetil.gnu.guix.patches


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git