[PATCH 1 of 2] patch: exclude diff opt from difffeatureopts by setting to false

Yuya Nishihara yuya at tcha.org
Wed Apr 20 10:51:01 EDT 2016


On Tue, 19 Apr 2016 19:22:36 +0200, liscju wrote:
> # HG changeset patch
> # User liscju <piotr.listkiewicz at gmail.com>
> # Date 1461079954 -7200
> #      Tue Apr 19 17:32:34 2016 +0200
> # Branch stable
> # Node ID d528ea7502ab7fc0ef01d3a8a44dc78df8d73563
> # Parent  97811ff7964710d32cae951df1da8019b46151a2
> patch: exclude diff opt from difffeatureopts by setting to false
> 
> Before difffeatureopts changed diff option from opts parameter
> only if it was true, so there was no way to make diff option false.
> 
> diff -r 97811ff79647 -r d528ea7502ab mercurial/patch.py
> --- a/mercurial/patch.py	Sat Mar 26 18:50:56 2016 +0900
> +++ b/mercurial/patch.py	Tue Apr 19 17:32:34 2016 +0200
> @@ -2143,7 +2143,7 @@ def difffeatureopts(ui, opts=None, untru
>      def get(key, name=None, getter=ui.configbool, forceplain=None):
>          if opts:
>              v = opts.get(key)
> -            if v:
> +            if v or isinstance(v, bool):
>                  return v

Making it a tri-state would cause subtle bugs. opts generally come from
command-line options, where we sometimes use False as well as None for default
value.

I'd rather make ctx.diff() accept diffopts object in place of **opts, which
will allow us to utilize dedicated diffopts factory functions.

  diffopts = patch.difffeatureopts(...)
  ctx.diff(opts=diffopts)


More information about the Mercurial-devel mailing list