From 18909613f0a4740fb0671bbc71bc403f115768a5 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Sun, 20 Apr 2025 02:22:18 +0000 Subject: Ensure Mercurial uses Python >= 3.5 (#33784). Redmine no longer supports Python 2.7. Mercurial does not support Python 3.0 to 3.4. Patch by Go MAEDA (user:maeda). git-svn-id: https://svn.redmine.org/redmine/trunk@23687 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/scm/adapters/mercurial_adapter.rb | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/redmine/scm/adapters/mercurial_adapter.rb b/lib/redmine/scm/adapters/mercurial_adapter.rb index 28a1922ca..562dd59d5 100644 --- a/lib/redmine/scm/adapters/mercurial_adapter.rb +++ b/lib/redmine/scm/adapters/mercurial_adapter.rb @@ -50,7 +50,10 @@ module Redmine end def client_available - client_version_above?([5, 1]) + client_version_above?([5, 1]) && + # Redmine >= 6.1 has dropped support for Python 2.7, and + # Mercurial has never supported Python 3.0 to 3.4 + (python_version <=> [3, 5]) >= 0 end def hgversion @@ -67,6 +70,23 @@ module Redmine shellout("#{sq_bin} --version") {|io| io.read}.to_s end + def python_version + @@python_version ||= begin + debuginstall = hgdebuginstall_from_command_line + if (m = debuginstall.match(/checking Python version \(([\d.]+)\)/)) + m[1].scan(%r{\d+}) + .collect(&:to_i) + .presence + else + nil + end + end + end + + def hgdebuginstall_from_command_line + shellout("#{sq_bin} debuginstall") {|io| io.read}.to_s + end + def template_path @@template_path ||= template_path_for(client_version) end -- cgit v1.2.3