summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2025-04-20 02:22:18 +0000
committerGo MAEDA <maeda@farend.jp>2025-04-20 02:22:18 +0000
commit18909613f0a4740fb0671bbc71bc403f115768a5 (patch)
tree1b2f7804221beb1750bb96d5a5255329003cfe39 /lib
parentce94a1d71a512f4cba9dd3e2359e8a4c2c1d285d (diff)
downloadredmine-18909613f0a4740fb0671bbc71bc403f115768a5.tar.gz
redmine-18909613f0a4740fb0671bbc71bc403f115768a5.zip
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
Diffstat (limited to 'lib')
-rw-r--r--lib/redmine/scm/adapters/mercurial_adapter.rb22
1 files changed, 21 insertions, 1 deletions
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