Patchwork extensions: include current version in "invalid version" message

login
register
mail settings
Submitter Boris Feld
Date Nov. 2, 2018, 9:03 a.m.
Message ID <6bfa530c2f37d1d66058.1541149391@localhost.localdomain>
Download mbox | patch
Permalink /patch/36323/
State Accepted
Headers show

Comments

Boris Feld - Nov. 2, 2018, 9:03 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1524240534 -7200
#      Fri Apr 20 18:08:54 2018 +0200
# Node ID 6bfa530c2f37d1d66058486aaa661d00dff45f83
# Parent  e0dea186ab6edfab124b1dfd84237a4b8142f13b
# EXP-Topic better-version-check
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 6bfa530c2f37
extensions: include current version in "invalid version" message

It is "not so rare" for the mercurial version to be badly detected at build
time. In such case, version check for extensions gets confused.

To help pinpoint the error, we now include the Mercurial's version number in
the error message.
Augie Fackler - Nov. 2, 2018, 7:01 p.m.
On Fri, Nov 02, 2018 at 10:03:11AM +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1524240534 -7200
> #      Fri Apr 20 18:08:54 2018 +0200
> # Node ID 6bfa530c2f37d1d66058486aaa661d00dff45f83
> # Parent  e0dea186ab6edfab124b1dfd84237a4b8142f13b
> # EXP-Topic better-version-check
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 6bfa530c2f37
> extensions: include current version in "invalid version" message

queued, thanks

Patch

diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -189,8 +189,9 @@  def load(ui, name, path, log=lambda *a: 
     # of Mercurial.
     minver = getattr(mod, 'minimumhgversion', None)
     if minver and util.versiontuple(minver, 2) > util.versiontuple(n=2):
-        ui.warn(_('(third party extension %s requires version %s or newer '
-                  'of Mercurial; disabling)\n') % (shortname, minver))
+        msg = _('(third party extension %s requires version %s or newer '
+                'of Mercurial (current: %s); disabling)\n')
+        ui.warn(msg % (shortname, minver, util.version()))
         return
     log('    - validating extension tables: %r\n', shortname)
     _validatetables(ui, mod)
diff --git a/tests/test-extension.t b/tests/test-extension.t
--- a/tests/test-extension.t
+++ b/tests/test-extension.t
@@ -1509,7 +1509,7 @@  Refuse to load extensions with minimum v
   > minimumhgversion = b'3.6'
   > EOF
   $ hg --config extensions.minversion=minversion1.py version
-  (third party extension minversion requires version 3.6 or newer of Mercurial; disabling)
+  (third party extension minversion requires version 3.6 or newer of Mercurial (current: 3.5.2); disabling)
   Mercurial Distributed SCM (version 3.5.2)
   (see https://mercurial-scm.org for more information)
   
@@ -1523,7 +1523,7 @@  Refuse to load extensions with minimum v
   > minimumhgversion = b'3.7'
   > EOF
   $ hg --config extensions.minversion=minversion2.py version 2>&1 | egrep '\(third'
-  (third party extension minversion requires version 3.7 or newer of Mercurial; disabling)
+  (third party extension minversion requires version 3.7 or newer of Mercurial (current: 3.6); disabling)
 
 Can load version that is only off by point release
 
diff --git a/tests/test-extensions-afterloaded.t b/tests/test-extensions-afterloaded.t
--- a/tests/test-extensions-afterloaded.t
+++ b/tests/test-extensions-afterloaded.t
@@ -87,7 +87,7 @@  configured but fails the minimum version
   $ echo "foo = $basepath/foo.py" >> .hg/hgrc
   $ echo "bar = $basepath/minvers.py" >> .hg/hgrc
   $ hg log -r. -T'{rev}\n'
-  (third party extension bar requires version 9999.9999 or newer of Mercurial; disabling)
+  (third party extension bar requires version 9999.9999 or newer of Mercurial (current: *); disabling) (glob)
   foo.uisetup
   foo: bar loaded: False
   0
@@ -107,7 +107,7 @@  for the two extensions.
   $ echo "bar = $basepath/minvers.py" >> .hg/hgrc
   $ echo "foo = $basepath/foo.py" >> .hg/hgrc
   $ hg log -r. -T'{rev}\n'
-  (third party extension bar requires version 9999.9999 or newer of Mercurial; disabling)
+  (third party extension bar requires version 9999.9999 or newer of Mercurial (current: *); disabling) (glob)
   foo.uisetup
   foo: bar loaded: False
   0