Re: [PATCH stable] hghave: make black version regex work with newer versions of black

2022-05-21 Thread Yuya Nishihara
On Sun, 22 May 2022 02:43:05 +0200, Joerg Sonnenberger wrote:
> Am Sun, May 22, 2022 at 02:13:03AM +0200 schrieb Manuel Jacob:
> > # HG changeset patch
> > # User Manuel Jacob 
> > # 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

This works for me, but I hesitated to queue since test-check-format.t starts
detecting formatting errors with

  % black --version
  black, 22.3.0 (compiled: no)

> > 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.  
> 
> I had a patch like this locally, but newer black versions insist on
> incompatible output and that's where I stopped. There is also the issue
> that the regex itself seems wrong, e.g. the unescaped "." in the [].

[.] should be okay. "." has no special meaning in character set.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH stable] hghave: make black version regex work with newer versions of black

2022-05-21 Thread Manuel Jacob

On 22/05/2022 02.43, Joerg Sonnenberger wrote:

Am Sun, May 22, 2022 at 02:13:03AM +0200 schrieb Manuel Jacob:

# HG changeset patch
# User Manuel Jacob 
# 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.


I had a patch like this locally, but newer black versions insist on
incompatible output and that's where I stopped.


It’s right that the test requiring black don’t pass anyway with some 
newer black versions. However, there are black versions with the new 
version string which seem to format the Mercurial source code as it is 
currently (e.g. black 21.11b0). Also, if we want to re-format the source 
code with a newer black version, we would need a change like this anyway.



There is also the issue
that the regex itself seems wrong, e.g. the unescaped "." in the [].


According to the documentation of the re module: “Special characters 
lose their special meaning inside sets.”.



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


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


Re: [PATCH stable] hghave: make black version regex work with newer versions of black

2022-05-21 Thread Joerg Sonnenberger
Am Sun, May 22, 2022 at 02:13:03AM +0200 schrieb Manuel Jacob:
> # HG changeset patch
> # User Manuel Jacob 
> # 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.

I had a patch like this locally, but newer black versions insist on
incompatible output and that's where I stopped. There is also the issue
that the regex itself seems wrong, e.g. the unescaped "." in the [].

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


[PATCH stable] hghave: make black version regex work with newer versions of black

2022-05-21 Thread Manuel Jacob
# HG changeset patch
# User Manuel Jacob 
# 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