Mercurial configuration on Windows

454 views
Skip to first unread message

Toby

unread,
Oct 14, 2020, 8:34:41 AM10/14/20
to scmmanager

Hi,

I'm trying to link SCM-Manager to a default TortoiseHg Mercurial installation on Windows.
Default install location of TortoiseHg is under C:\Program Files\TortoiseHg, which includes a space. Is it requried to quote the path on web config interface or xml file ?
Currently, I have set HG Binary Path to C:\Program Files\TortoiseHg\hg.exe and Python Module search path to C:\Program Files\TortoiseHg\lib without quoting (python binary is C:\Python27\python.exe -  ).
Now, when accessing SCM web interface, everything looks fine. Changesets, branches, ...  are reported correctly, but when trying to pull/push to the repository, I'm getting a "Mercurial/Python process ends with return code 1".
And when looking at the log, there's 
File "C:\SCM\data\lib\python\hgweb.py", line 27, in <module>
    from mercurial import demandimport, ui as uimod, hg
ImportError: No module named mercurial

Any idea what's wrong? Do I need to quote the paths?
Regards,
Toby

Toby

unread,
Oct 14, 2020, 9:10:28 AM10/14/20
to scmmanager
Further, how about the python version? Python2 + Mercurial for Python 2, or Python3 and a matching Mercurial version ?
I couldn't find any information on this in documentation.

Regards,
Toby

Sebastian Sdorra

unread,
Oct 16, 2020, 7:20:20 AM10/16/20
to scmma...@googlegroups.com
I think the problem is that the python modules of mercurial are zipped in a file called library.zip. I assume that we have to unpack it in order to access it from the hgweb.py.

The problem seems to occur only on windows, osx and linux does not use zipped modules. Could you try to unzip the library in a directory and configure the python library path in scm-manager to that directory?

Sebastian

--
You received this message because you are subscribed to the Google Groups "scmmanager" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scmmanager+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scmmanager/b78eeeac-6bc1-49d2-9e4e-9c9ccf1a8d3an%40googlegroups.com.

Toby

unread,
Oct 16, 2020, 8:22:41 AM10/16/20
to scmmanager
Hi Sebastian,

meanwhile I've switched to Python 3.8 and the latest 5.5.2 Mercurial standalone installer for Windows (without Tortoise GUI), which doesn't use an archive library.zip. And I can confirm this setup is working.
Previously, I had been using Mercurial 5.4 shipped with TortoiseHg, which has been Python 2.7 based and utilizes archived library.zip.
So I need to bring back the old setup as an alternative option to test if unarchived library.zip is making in work. I'll let you know ....
(Would Python3 be able to deal with library.zip?)
 
In general: What's the baseline requirement of SCM-Manager/mercurial ?  Python2, Python3, or both?
Mercurial 5.5 (Windows) is still provided with support for Python2 or Python3, and if there's a restriction from SCM-Manager, the documentation should be more specific.

Thanks,
Toby

Matt Harbison

unread,
Nov 10, 2020, 12:35:14 AM11/10/20
to scmmanager

On Friday, October 16, 2020 at 8:22:41 AM UTC-4, Toby wrote:
Hi Sebastian,

meanwhile I've switched to Python 3.8 and the latest 5.5.2 Mercurial standalone installer for Windows (without Tortoise GUI), which doesn't use an archive library.zip. And I can confirm this setup is working.

I'm surprised by this, since they both use py2exe, which is what creates/handles library.zip.  I thought 5.6 was the first python3 release for Windows, but it looks like there was also a python3 build for 5.5.2.  You can confirm by running `hg debuginstall` and seeing what version of python is printed.  The python3 builds don't use py2exe, which would explain the lack of a zip file.

The medium term goal is to bundle all of these python files inside of hg.exe and read them directly from memory when the executable loads instead of reading them from the filesystem.  That sounds like it's going to be a problem here.  Why exactly does SCM Manager need to load Mercurial python files?  I vaguely remember there's an SCM Manager module similar to Mercurial's hgwebdir module, but it's been awhile since I dove into the code since it runs pretty smoothly for us.  In any case, I'd like to make sure that the Mercurial project accounts for this use case in its release packaging.  TortoiseHg is a bit behind in it's python3 porting on Windows, but is going to use the same unified binary.
 
In general: What's the baseline requirement of SCM-Manager/mercurial ?  Python2, Python3, or both?
Mercurial 5.5 (Windows) is still provided with support for Python2 or Python3, and if there's a restriction from SCM-Manager, the documentation should be more specific.

I'm curious if SCM Manager supports python3 Mercurial myself (but it sounds like it does).  The Mercurial project wants to drop python2 support very soon, possibly as soon as 5.7.  I put SCM Manager on the list of potential blockers, because it's a useful hosting solution for us.  So if there are things I can help with on the Mercurial side, please let me know.

Toby

unread,
Nov 10, 2020, 6:21:14 AM11/10/20
to scmmanager
Here's the info you've asked for:

C:\SCM\Mercurial>hg debuginstall
checking encoding (cp1252)...
checking Python executable (C:\SCM\Mercurial\hg.exe)
checking Python implementation (CPython)
checking Python version (3.8.6)
checking Python lib (C:\SCM\Mercurial\hg.exe)...
checking Python security support (sni,tls1.0,tls1.1,tls1.2)
checking Rust extensions (missing)
checking Mercurial version (5.5.2)
checking Mercurial custom build (6-2a84459e685c)
checking module policy (c)
checking installed modules (C:\SCM\Mercurial\lib\mercurial)...
checking registered compression engines (bz2, bz2truncated, none, zlib, zstd)
checking available compression engines (bz2, bz2truncated, none, zlib, zstd)
checking available compression engines for wire protocol (zstd, zlib, bz2, none)
checking "re2" regexp engine (missing)
checking templates (C:\SCM\Mercurial\templates)...
checking default template (C:\SCM\Mercurial\templates\map-cmdline.default)
checking commit editor... (vi)
 No commit editor set and can't find vi in PATH
 (specify a commit editor in your configuration file)
checking username...
 no username supplied
 (specify a username in your configuration file)
1 problems detected, please check your install!

Installer has been downloaded from this page, https://www.mercurial-scm.org/downloads in veryion 5.5.2/Inno Setup on 14th of October.
But meanwhile they have switched to 5.6.

Matt Harbison

unread,
Nov 10, 2020, 10:14:03 AM11/10/20
to scmmanager

On Tuesday, November 10, 2020 at 6:21:14 AM UTC-5, Toby wrote:
Here's the info you've asked for:

C:\SCM\Mercurial>hg debuginstall
checking encoding (cp1252)...
checking Python executable (C:\SCM\Mercurial\hg.exe)

Thanks.  This is the telltale sign that it was built with PyOxidizer, instead of py2exe[1].

IDK if SCM Manager ships its own python, or relies on it being installed on the system.  If the latter and you don't have py2 installed, then it seems like SCM Manager already supports py3.  Otherwise, it might still be running py2.
 
checking Python implementation (CPython)
checking Python version (3.8.6)

Toby

unread,
Nov 10, 2020, 10:56:02 AM11/10/20
to scmmanager
For clarification: I've removed all Python2 from my SCM-Manager server machine, installed Python 3.8.6 to match the Python version Mercurial 5.5.2 had been built with, and in the configuration of SCM-Manager Mercurial plugin I point the "Python binary" to the one of the Python 3.8.6 install. A very consistent setup - I'd say. The save choice.
I'm assuming SCM manager / Mercurial plugin is utilizing the Python binary configured in the settings of Mercurial plugin, as there's nothing shipped with SCM Manager that looks like python stuff except for the 3 source files hgweb.py, scmhook.py, and version.py.

Sebastian Sdorra

unread,
Nov 10, 2020, 11:26:40 AM11/10/20
to scmma...@googlegroups.com
Currently the SCM-Team discuss the possibility to implement the handling of the mercurial protocol within a mercurial extension. Currently the handling of the protocol is implemented as separate python script (hgweb.py), this script is the reason why we need a separate python and the unzipped library. If we are able to implement the hgweb as mercurial extension, we only need the python executable, no separate python installation is required. This change would drastically reduce the complexity of windows installations and this would work the same way on all platforms.

I think we are able to create a test version in the next weeks.

Sebastian

--
You received this message because you are subscribed to the Google Groups "scmmanager" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scmmanager+...@googlegroups.com.

Nikolay Sidorenko

unread,
Nov 23, 2020, 6:24:29 AM11/23/20
to scmmanager
Hi Toby, 
You've mentioned that you've succeeded to configure  SCM-Manager within Python 3.8 and the latest 5.5.2 Mercurial standalone  
Could you please help me to do the same? 
Here are steps I've tried w/o any success (on Windows 10)
1. Install OpenJDK 11 by AdoptOpenJDK
2. Unzip, install and start scm-server service
3. Install Python 3.8.3 (64-bit) to default location  (C:\Users\Administrator\AppData\Local\Programs\Python\Python38)
4. Install Mercurial 5.5.2
5. Provide "C:\Program Files\Mercurial\hg.exe" as Mercurial binary path and "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\python.exe" as Python binary path for Mercurial plugin via web interface of SCM-Manager 
6. Create repo
7. Clone repo

Clone operation returns "remote error: OutOfBand"

пятница, 16 октября 2020 г. в 15:22:41 UTC+3, Toby:

Sebastian Sdorra

unread,
Dec 22, 2020, 5:56:43 AM12/22/20
to scmma...@googlegroups.com
Hi at all,
We release version 2.12.0, which simplifies the configuration of mercurial drastically:

https://www.scm-manager.org/blog/posts/2020-12-17-scm-manager-2-12-0/#mercurial

All we need now is a path to the mercurial binary. This should avoid a lot of problems especially with mercurial on windows.

@Nikolay could you try using version 2.12.0?

Sebastian

Nikolay Sidorenko

unread,
Dec 24, 2020, 11:01:17 AM12/24/20
to scmmanager
Thanks for the suggestion.
I was able to solve the issue by executing additional command in Python command line 
"pip install mercurial"

вторник, 22 декабря 2020 г. в 12:56:43 UTC+2, Sebastian Sdorra:
Reply all
Reply to author
Forward
0 new messages