Mercurial > hg
comparison mercurial/patch.py @ 29948:e40343ce9c4c
diffopts: notice a negated boolean flag in diffopts
This means that if you have git-diffs enabled by default (pretty
common) and you hit the rare (but real) case where a git-diff breaks
patch(1) or some other tool, you can easily disable it by just
specifying --no-git on the command line.
I feel a little bad about the isinstance() check, but some values in
diffopts are not booleans and so we need to preserve false iff the
flag is a boolean flag: failing to do this means we end up with empty
string defaults for flags clobbering meaningful values from the [diff]
section in hgrc.
author | Augie Fackler <augie@google.com> |
---|---|
date | Tue, 30 Aug 2016 15:55:07 -0400 |
parents | 50f2966f86ca |
children | 173bdb502503 |
comparison
equal
deleted
inserted
replaced
29947:e1f0ec0b7d2d | 29948:e40343ce9c4c |
---|---|
2142 with most diff parsers | 2142 with most diff parsers |
2143 ''' | 2143 ''' |
2144 def get(key, name=None, getter=ui.configbool, forceplain=None): | 2144 def get(key, name=None, getter=ui.configbool, forceplain=None): |
2145 if opts: | 2145 if opts: |
2146 v = opts.get(key) | 2146 v = opts.get(key) |
2147 if v: | 2147 # diffopts flags are either None-default (which is passed |
2148 # through unchanged, so we can identify unset values), or | |
2149 # some other falsey default (eg --unified, which defaults | |
2150 # to an empty string). We only want to override the config | |
2151 # entries from hgrc with command line values if they | |
2152 # appear to have been set, which is any truthy value, | |
2153 # True, or False. | |
2154 if v or isinstance(v, bool): | |
2148 return v | 2155 return v |
2149 if forceplain is not None and ui.plain(): | 2156 if forceplain is not None and ui.plain(): |
2150 return forceplain | 2157 return forceplain |
2151 return getter(section, name or key, None, untrusted=untrusted) | 2158 return getter(section, name or key, None, untrusted=untrusted) |
2152 | 2159 |