Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/diffutil.py @ 49974: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 | 6000f5b25c9b |
children | a6b8b1ab9116 |
comparison
equal
deleted
inserted
replaced
49973:a78dfb1ad60e | 49974:024e0580b853 |
---|---|
118 buildopts[b'ignoreblanklines'] = get( | 118 buildopts[b'ignoreblanklines'] = get( |
119 b'ignore_blank_lines', b'ignoreblanklines' | 119 b'ignore_blank_lines', b'ignoreblanklines' |
120 ) | 120 ) |
121 buildopts[b'ignorewseol'] = get(b'ignore_space_at_eol', b'ignorewseol') | 121 buildopts[b'ignorewseol'] = get(b'ignore_space_at_eol', b'ignorewseol') |
122 if formatchanging: | 122 if formatchanging: |
123 buildopts[b'text'] = opts and opts.get(b'text') | 123 buildopts[b'text'] = None if opts is None else opts.get(b'text') |
124 binary = None if opts is None else opts.get(b'binary') | 124 binary = None if opts is None else opts.get(b'binary') |
125 buildopts[b'nobinary'] = ( | 125 buildopts[b'nobinary'] = ( |
126 not binary | 126 not binary |
127 if binary is not None | 127 if binary is not None |
128 else get(b'nobinary', forceplain=False) | 128 else get(b'nobinary', forceplain=False) |