[PATCH 03 of 10] scmutil: split osrcpath to return system and user paths separately

Yuya Nishihara yuya at tcha.org
Sat Mar 18 04:48:41 EDT 2017


On Mon, 13 Mar 2017 20:44:48 -0700, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1489452019 25200
> #      Mon Mar 13 17:40:19 2017 -0700
> # Node ID 4211d15ea4df24e3825a481a2fd7eaf5e96416c3
> # Parent  742ced65214c96869a4305e6d621a9a0d2b1282d
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 4211d15ea4df
> scmutil: split osrcpath to return system and user paths separately
> 
> This will allow us to insert another config layer in-between.
> 
> diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
> --- a/mercurial/scmutil.py
> +++ b/mercurial/scmutil.py
> @@ -393,5 +393,5 @@ def walkrepos(path, followsym=False, see
>  
>  def osrcpath():
> -    '''return default os-specific hgrc search path'''
> +    '''return default os-specific hgrc search path: (syspaths, userpaths)'''
>      path = []
>      defaultpath = os.path.join(util.datapath, 'default.d')
> @@ -401,7 +401,8 @@ def osrcpath():
>                  path.append(os.path.join(defaultpath, f))
>      path.extend(systemrcpath())
> -    path.extend(userrcpath())
> -    path = [os.path.normpath(f) for f in path]
> -    return path
> +    normpath = os.path.normpath
> +    syspath = map(normpath, path)
> +    userpath = map(normpath, userrcpath())
> +    return syspath, userpath

It makes little sense to keep osrcpath() function. How about making platform
functions private and splitting osrcpath() into new systemrcpath() and
userrcpath() ?


More information about the Mercurial-devel mailing list