[PATCH 03 of 11 V2] scmutil: split osrcpath to return default.d paths
# HG changeset patch # User Jun Wu # Date 1490165660 25200 # Tue Mar 21 23:54:20 2017 -0700 # Node ID 7775943a59cfaaae77e2143cbfa0bf0d8d95a447 # Parent 5de0f85888f87c705bcbc38d3e92e97b7e23d1d9 # Available At https://bitbucket.org/quark-zju/hg-draft # hg pull https://bitbucket.org/quark-zju/hg-draft -r 7775943a59cf scmutil: split osrcpath to return default.d paths After this change, there are 3 rcpath functions: - defaultrcpath - systemrcpath - userrcpath This will allow us to insert another config layer in the middle. diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -392,6 +392,6 @@ def walkrepos(path, followsym=False, see dirs[:] = newdirs -def osrcpath(): -'''return default os-specific hgrc search path''' +def defaultrcpath(): +'''return rc paths in default.d''' path = [] defaultpath = os.path.join(util.datapath, 'default.d') @@ -400,7 +400,4 @@ def osrcpath(): if f.endswith('.rc'): path.append(os.path.join(defaultpath, f)) -path.extend(systemrcpath()) -path.extend(userrcpath()) -path = [os.path.normpath(f) for f in path] return path @@ -449,5 +446,6 @@ def rcpath(): _rcpath.append(p) else: -_rcpath = osrcpath() +paths = defaultrcpath() + systemrcpath() + userrcpath() +_rcpath = map(os.path.normpath, paths) return _rcpath ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 03 of 11 V2] scmutil: split osrcpath to return default.d paths
On Wed, Mar 22, 2017 at 12:50 AM, Jun Wu wrote: > # HG changeset patch > # User Jun Wu > # Date 1490165660 25200 > # Tue Mar 21 23:54:20 2017 -0700 > # Node ID 7775943a59cfaaae77e2143cbfa0bf0d8d95a447 > # Parent 5de0f85888f87c705bcbc38d3e92e97b7e23d1d9 > # Available At https://bitbucket.org/quark-zju/hg-draft > # hg pull https://bitbucket.org/quark-zju/hg-draft -r > 7775943a59cf > scmutil: split osrcpath to return default.d paths > > After this change, there are 3 rcpath functions: > > - defaultrcpath > - systemrcpath > - userrcpath > > This will allow us to insert another config layer in the middle. > > diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py > --- a/mercurial/scmutil.py > +++ b/mercurial/scmutil.py > @@ -392,6 +392,6 @@ def walkrepos(path, followsym=False, see > dirs[:] = newdirs > > -def osrcpath(): > -'''return default os-specific hgrc search path''' > +def defaultrcpath(): Two related questions: 1) Should this patch be annotated with (API)? 2) Should this method be "private" (underscore-prefixed)? > +'''return rc paths in default.d''' > path = [] > defaultpath = os.path.join(util.datapath, 'default.d') > @@ -400,7 +400,4 @@ def osrcpath(): > if f.endswith('.rc'): > path.append(os.path.join(defaultpath, f)) > -path.extend(systemrcpath()) > -path.extend(userrcpath()) > -path = [os.path.normpath(f) for f in path] > return path > > @@ -449,5 +446,6 @@ def rcpath(): > _rcpath.append(p) > else: > -_rcpath = osrcpath() > +paths = defaultrcpath() + systemrcpath() + userrcpath() > +_rcpath = map(os.path.normpath, paths) > return _rcpath > > ___ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 03 of 11 V2] scmutil: split osrcpath to return default.d paths
Excerpts from Martin von Zweigbergk's message of 2017-03-22 09:53:48 -0700: > Two related questions: > > 1) Should this patch be annotated with (API)? Good point. I'll add "(API)". > 2) Should this method be "private" (underscore-prefixed)? Since systemrcpath and userrcpath are public, I think it's more consistent if defaultrcpath is public. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel