[Updated] D11476: extensions: prevent a crash on py3 with a `minimumhgversion` str value

mharbison72 (Matt Harbison) phabricator at mercurial-scm.org
Wed Sep 22 07:57:40 UTC 2021


Closed by commit rHG5caec48d9a01: extensions: prevent a crash on py3 with a `minimumhgversion` str value (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D11476?vs=30350&id=30368

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D11476/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D11476

AFFECTED FILES
  mercurial/extensions.py
  tests/test-extension.t

CHANGE DETAILS

diff --git a/tests/test-extension.t b/tests/test-extension.t
--- a/tests/test-extension.t
+++ b/tests/test-extension.t
@@ -1692,12 +1692,13 @@
   $ hg --config extensions.minversion=minversion3.py version 2>&1 | egrep '\(third'
   [1]
 
-Don't explode on py3 with a bad version number
+Don't explode on py3 with a bad version number (both str vs bytes, and not enough
+parts)
 
   $ cat > minversion4.py << EOF
   > from mercurial import util
   > util.version = lambda: b'3.5'
-  > minimumhgversion = b'3'
+  > minimumhgversion = '3'
   > EOF
   $ hg --config extensions.minversion=minversion4.py version -v
   Mercurial Distributed SCM (version 3.5)
diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -224,7 +224,7 @@
     minver = getattr(mod, 'minimumhgversion', None)
     if minver:
         curver = util.versiontuple(n=2)
-        extmin = util.versiontuple(minver, 2)
+        extmin = util.versiontuple(stringutil.forcebytestr(minver), 2)
 
         if None in extmin:
             extmin = (extmin[0] or 0, extmin[1] or 0)



To: mharbison72, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210922/188c3ef0/attachment-0002.html>


More information about the Mercurial-patches mailing list