Re: config: avoid using a mutable default

2017-03-12 Thread Augie Fackler
On Sun, Mar 12, 2017 at 12:56:20PM -0700, Martijn Pieters wrote:
> # HG changeset patch
> # User Martijn Pieters <mjpiet...@fb.com>
> # Date 1489348572 25200
> #  Sun Mar 12 12:56:12 2017 -0700
> # Node ID 22c38e571b5ccf3bb6d9f075526170954843f37a
> # Parent  719e64bf9ec2d7b8e86b6550a5d193b3c67944d1
> config: avoid using a mutable default

Queued, thanks.

>
> Nothing *currently* mutates this list, but the moment something does it'll be
> shared between all config instances. Avoid this eventuality.
>
> diff --git a/mercurial/config.py b/mercurial/config.py
> --- a/mercurial/config.py
> +++ b/mercurial/config.py
> @@ -18,11 +18,11 @@
>  )
>
>  class config(object):
> -def __init__(self, data=None, includepaths=[]):
> +def __init__(self, data=None, includepaths=None):
>  self._data = {}
>  self._source = {}
>  self._unset = []
> -self._includepaths = includepaths
> +self._includepaths = includepaths or []
>  if data:
>  for k in data._data:
>  self._data[k] = data[k].copy()
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH] config: avoid using a mutable default

2017-03-12 Thread Martijn Pieters
# HG changeset patch
# User Martijn Pieters <mjpiet...@fb.com>
# Date 1489348572 25200
#  Sun Mar 12 12:56:12 2017 -0700
# Node ID 22c38e571b5ccf3bb6d9f075526170954843f37a
# Parent  719e64bf9ec2d7b8e86b6550a5d193b3c67944d1
config: avoid using a mutable default

Nothing *currently* mutates this list, but the moment something does it'll be
shared between all config instances. Avoid this eventuality.

diff --git a/mercurial/config.py b/mercurial/config.py
--- a/mercurial/config.py
+++ b/mercurial/config.py
@@ -18,11 +18,11 @@
 )
 
 class config(object):
-def __init__(self, data=None, includepaths=[]):
+def __init__(self, data=None, includepaths=None):
 self._data = {}
 self._source = {}
 self._unset = []
-self._includepaths = includepaths
+self._includepaths = includepaths or []
 if data:
 for k in data._data:
 self._data[k] = data[k].copy()
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel