# HG changeset patch # User introom # Date 2015-06-11 12:54:24 # Node ID 69e8384a436ce703dba436fd8d6e49a63efe517b # Parent 2b2108c35bfca8d553602b8e3f765f36b2c97a41 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. diff --git a/mercurial/fancyopts.py b/mercurial/fancyopts.py --- a/mercurial/fancyopts.py +++ b/mercurial/fancyopts.py @@ -103,8 +103,9 @@ def fancyopts(args, options, state, gnu= # 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: