# HG changeset patch
# User Manuel Jacob <m...@manueljacob.de>
# Date 1653176900 -7200
#      Sun May 22 01:48:20 2022 +0200
# Branch stable
# Node ID 29f2716c5c54c7e0f7aa6d91979893f5d2078862
# Parent  477b5145e1a02715f846ce017b460858a58e03b1
# EXP-Topic black_version_regex
hghave: make black version regex work with newer versions of black

Black commit 117891878e5be4d6b771ae5de299e51b679cea27 (included in black >=
21.11b0) dropped the string "version " from the output of "black --version". To
make the regex work with newer black versions, make matching of "version "
optional.

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -1123,7 +1123,7 @@
 @check('black', 'the black formatter for python (>= 20.8b1)')
 def has_black():
     blackcmd = 'black --version'
-    version_regex = b'black, version ([0-9a-b.]+)'
+    version_regex = b'black, (?:version )?([0-9a-b.]+)'
     version = matchoutput(blackcmd, version_regex)
     sv = distutils.version.StrictVersion
     return version and sv(_bytes2sys(version.group(1))) >= sv('20.8b1')

_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to