[PATCH] mdiff: use fallback arg of get() instead of if-clause
Alexis S. L. Carvalho
alexis at cecm.usp.br
Tue Feb 13 11:25:27 UTC 2007
Thus spake Christian Ebert:
> mdiff: use fallback arg of get() instead of if-clause
>
> diff -r bbdba01cce28 -r b13889f48552 mercurial/mdiff.py
> --- a/mercurial/mdiff.py Wed Jan 17 22:19:36 2007 +0100
> +++ b/mercurial/mdiff.py Thu Jan 18 14:54:43 2007 +0100
> @@ -38,14 +38,9 @@
> 'ignoreblanklines': False,
> }
>
> - __slots__ = defaults.keys()
> -
> def __init__(self, **opts):
> - for k in self.__slots__:
> - v = opts.get(k)
> - if v is None:
> - v = self.defaults[k]
> - setattr(self, k, v)
> + for k in self.defaults:
> + setattr(self, k, opts.get(k, self.defaults[k]))
This doesn't really work since some code (e.g. commands.diff) assumes it
can pass a value of None to mean "use the default value".
Alexis
More information about the Mercurial-devel
mailing list