diff mbox

[bug#48232,0/2] Add mercurial-commitsigs and some changes to Mercurial.

Message ID 874kf8cno8.fsf@yoctocell.xyz
State Accepted
Headers show

Commit Message

Xinglu Chen May 12, 2021, 9:21 a.m. UTC
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”.

Comments

Ludovic Courtès May 12, 2021, 8:56 p.m. UTC | #1
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’.
Xinglu Chen May 14, 2021, 11:52 a.m. UTC | #2
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.
diff mbox

Patch

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