Patchwork [2,of,3,STABLE] hghave: verify we have a black that is new enough for our format

login
register
mail settings
Submitter Augie Fackler
Date Oct. 30, 2019, 8:39 p.m.
Message ID <4ec0fed0eeeb1e8c1a7c.1572467986@augie-macbookpro2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/42618/
State Accepted
Headers show

Comments

Augie Fackler - Oct. 30, 2019, 8:39 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1572467385 14400
#      Wed Oct 30 16:29:45 2019 -0400
# Branch stable
# Node ID 4ec0fed0eeeb1e8c1a7cd7041325d4733e26016a
# Parent  0dc1b2cc8e1784b059728c9d9decaf58a50937ae
hghave: verify we have a black that is new enough for our format

We require what is currently the absolute latest black, so let's be paranoid.

Patch

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -1,5 +1,6 @@ 
 from __future__ import absolute_import, print_function
 
+import distutils.version
 import os
 import re
 import socket
@@ -982,7 +983,8 @@  def has_emacs():
 
 @check('black', 'the black formatter for python')
 def has_black():
-    # use that to actual black as soon as possible
     blackcmd = 'black --version'
-    version_regex = b'black, version \d'
-    return matchoutput(blackcmd, version_regex)
+    version_regex = b'black, version ([0-9a-b.]+)'
+    version = matchoutput(blackcmd, version_regex)
+    sv = distutils.version.StrictVersion
+    return version and sv(version.group(1)) >= sv('19.10b0')