[PATCH 07 of 13 V3] scmutil: extract rc.d listing function from rccomponents

Martin von Zweigbergk martinvonz at google.com
Thu Mar 23 01:32:53 EDT 2017


On Wed, Mar 22, 2017 at 10:23 AM, Jun Wu <quark at fb.com> wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1490201429 25200
> #      Wed Mar 22 09:50:29 2017 -0700
> # Node ID d604e5baed4ac2f5470860bff89728c282d71e3a
> # Parent  44c865487bfd2f081bfb322b1fb1b700d57f7adf
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r d604e5baed4a
> scmutil: extract rc.d listing function from rccomponents
>
> This is suggested by dsop and makes the code cleaner. A side effect is
> "normpath" will be called on paths in $HGRCPATH, which seems to be more
> correct.

Is that last part still true? It looks like pathize() is called on all
paths even in the preimage, and I believe pathize() calls normpath().
I'm thinking that maybe the commit message is outdated.

>
> diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
> --- a/mercurial/scmutil.py
> +++ b/mercurial/scmutil.py
> @@ -452,4 +452,13 @@ def rcpath():
>  _rccomponents = None
>
> +def _expandrcpath(path):
> +    '''path could be a file or a directory. return a list of file paths'''
> +    p = util.expandpath(path)
> +    join = os.path.join
> +    if os.path.isdir(p):
> +        return [join(p, f) for f, k in osutil.listdir(p) if f.endswith('.rc')]
> +    else:
> +        return [p]
> +
>  def rccomponents():
>      '''return an ordered [(type, obj)] about where to load configs.
> @@ -478,11 +487,5 @@ def rccomponents():
>                  if not p:
>                      continue
> -                p = util.expandpath(p)
> -                if os.path.isdir(p):
> -                    for f, kind in osutil.listdir(p):
> -                        if f.endswith('.rc'):
> -                            _rccomponents.append(pathize(os.path.join(p, f)))
> -                else:
> -                    _rccomponents.append(pathize(p))
> +                _rccomponents.extend(map(pathize, _expandrcpath(p)))
>          else:
>              _rccomponents = map(pathize, defaultrcpath() + systemrcpath())
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list