changeset 49898:024e0580b853

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.
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 10 Jan 2023 12:55:49 -0500
parents a78dfb1ad60e
children 3eef8baf6b92
files mercurial/diffutil.py
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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