diffutil: rewrite an ersatz ternary operator for building diffopts.text
authorMatt Harbison <matt_harbison@yahoo.com>
Tue, 10 Jan 2023 12:55:49 -0500
changeset 49898 024e0580b853
parent 49897 a78dfb1ad60e
child 49899 3eef8baf6b92
diffutil: rewrite an ersatz ternary operator for building diffopts.text Pytype tends to get confused by these, but the real problem here is that if the caller passes `opts={}` as TortoiseHg has been doing, that is set as the value for `diffopts.text` when in reality it expects a boolean. When `None` is passed explicitly, the default value in `mdiff.defaultopts` is assigned.
mercurial/diffutil.py
--- a/mercurial/diffutil.py	Mon Jan 09 14:34:19 2023 -0500
+++ b/mercurial/diffutil.py	Tue Jan 10 12:55:49 2023 -0500
@@ -120,7 +120,7 @@
         )
         buildopts[b'ignorewseol'] = get(b'ignore_space_at_eol', b'ignorewseol')
     if formatchanging:
-        buildopts[b'text'] = opts and opts.get(b'text')
+        buildopts[b'text'] = None if opts is None else opts.get(b'text')
         binary = None if opts is None else opts.get(b'binary')
         buildopts[b'nobinary'] = (
             not binary