Patchwork [8,of,8] configitems: register 'ui.clonebundleprefers' as example for 'configlist'

login
register
mail settings
Submitter Pierre-Yves David
Date June 21, 2017, 8:55 a.m.
Message ID <c4b137fd72618fc5c761.1498035309@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/21593/
State Accepted
Headers show

Comments

Pierre-Yves David - June 21, 2017, 8:55 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1497698742 -7200
#      Sat Jun 17 13:25:42 2017 +0200
# Node ID c4b137fd72618fc5c761304bddf5ac9d2b887305
# Parent  71c55875e1d4342eb1165a81e45dd8ac42b546fa
# 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 c4b137fd7261
configitems: register 'ui.clonebundleprefers' as example for 'configlist'

This exercise the default value handling in 'configlist'.
Yuya Nishihara - June 23, 2017, 2:47 p.m.
On Wed, 21 Jun 2017 10:55:09 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1497698742 -7200
> #      Sat Jun 17 13:25:42 2017 +0200
> # Node ID c4b137fd72618fc5c761304bddf5ac9d2b887305
> # Parent  71c55875e1d4342eb1165a81e45dd8ac42b546fa
> # 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 c4b137fd7261
> configitems: register 'ui.clonebundleprefers' as example for 'configlist'
> 
> This exercise the default value handling in 'configlist'.
> 
> diff --git a/mercurial/configitems.py b/mercurial/configitems.py
> --- a/mercurial/configitems.py
> +++ b/mercurial/configitems.py
> @@ -39,6 +39,9 @@ def coreconfigitem(*args, **kwargs):
>  coreconfigitem('patch', 'fuzz',
>      default=2,
>  )
> +coreconfigitem('ui', 'clonebundleprefers',
> +    default=[],
> +)

Perhaps this list would be returned to the caller without copying, and could
be mutated unintentionally?
Pierre-Yves David - June 23, 2017, 3:01 p.m.
On 06/23/2017 04:47 PM, Yuya Nishihara wrote:
> On Wed, 21 Jun 2017 10:55:09 +0200, Pierre-Yves David wrote:
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@octobus.net>
>> # Date 1497698742 -7200
>> #      Sat Jun 17 13:25:42 2017 +0200
>> # Node ID c4b137fd72618fc5c761304bddf5ac9d2b887305
>> # Parent  71c55875e1d4342eb1165a81e45dd8ac42b546fa
>> # 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 c4b137fd7261
>> configitems: register 'ui.clonebundleprefers' as example for 'configlist'
>>
>> This exercise the default value handling in 'configlist'.
>>
>> diff --git a/mercurial/configitems.py b/mercurial/configitems.py
>> --- a/mercurial/configitems.py
>> +++ b/mercurial/configitems.py
>> @@ -39,6 +39,9 @@ def coreconfigitem(*args, **kwargs):
>>   coreconfigitem('patch', 'fuzz',
>>       default=2,
>>   )
>> +coreconfigitem('ui', 'clonebundleprefers',
>> +    default=[],
>> +)
> 
> Perhaps this list would be returned to the caller without copying, and could
> be mutated unintentionally?

Good catch, I'll follow up.

Patch

diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -39,6 +39,9 @@  def coreconfigitem(*args, **kwargs):
 coreconfigitem('patch', 'fuzz',
     default=2,
 )
+coreconfigitem('ui', 'clonebundleprefers',
+    default=[],
+)
 coreconfigitem('ui', 'interactive',
     default=None,
 )
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1980,7 +1980,7 @@  class clonebundleentry(object):
         return self._cmp(other) != 0
 
 def sortclonebundleentries(ui, entries):
-    prefers = ui.configlist('ui', 'clonebundleprefers', default=[])
+    prefers = ui.configlist('ui', 'clonebundleprefers')
     if not prefers:
         return list(entries)