Submitter | Pierre-Yves David |
---|---|
Date | June 28, 2017, 12:17 p.m. |
Message ID | <2aff498b940b59f6ec18.1498652237@nodosa.octopoid.net> |
Download | mbox | patch |
Permalink | /patch/21797/ |
State | Accepted |
Headers | show |
Comments
Pierre-Yves David <pierre-yves.david@ens-lyon.org> writes: > # HG changeset patch > # User Pierre-Yves David <pierre-yves.david@octobus.net> > # Date 1498650620 -7200 > # Wed Jun 28 13:50:20 2017 +0200 > # Node ID 2aff498b940b59f6ec1872096ba0d02dc362696c > # Parent 1f704b77446b3e22c4352ebb85d51bfca837a3a7 > # EXP-Topic config.register > # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ > # hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 2aff498b940b > configitems: support callable as a default value > > Yuya pointed out that using mutable value as the default could be problematic. > To work around this we now support callable object as default value. This > allows for creating new mutable objects on demand when needed. Sure, makes sense. Queued!
Patch
diff --git a/mercurial/configitems.py b/mercurial/configitems.py --- a/mercurial/configitems.py +++ b/mercurial/configitems.py @@ -60,7 +60,7 @@ coreconfigitem('patch', 'fuzz', default=2, ) coreconfigitem('ui', 'clonebundleprefers', - default=[], + default=list, ) coreconfigitem('ui', 'interactive', default=None, diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -455,6 +455,8 @@ class ui(object): if default is _unset: if item is None: value = default + elif callable(item.default): + value = item.default() else: value = item.default elif item is not None: