Mercurial > hg
changeset 25563:69e8384a436c
fancyopts: allow all callable as default parameter value
The current fancyopts allows function as default parameter value
but not other callables.
By supporting other callables, we can have the benefits of e.g.,
custom __str__ method, which will be printed by 'hg help' as
the default value.
author | introom <i@introo.me> |
---|---|
date | Thu, 11 Jun 2015 08:54:24 -0400 |
parents | 2b2108c35bfc |
children | 847fce27effc |
files | mercurial/fancyopts.py |
diffstat | 1 files changed, 3 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/fancyopts.py Fri Jun 12 16:11:42 2015 -0400 +++ b/mercurial/fancyopts.py Thu Jun 11 08:54:24 2015 -0400 @@ -103,8 +103,9 @@ # transfer result to state for opt, val in opts: name = argmap[opt] - t = type(defmap[name]) - if t is type(fancyopts): + obj = defmap[name] + t = type(obj) + if callable(obj): state[name] = defmap[name](val) elif t is type(1): try: