On 3/22/17 7:50 AM, Jun Wu wrote:
# HG changeset patch
# User Jun Wu <qu...@fb.com>
# Date 1489449998 25200
# Mon Mar 13 17:06:38 2017 -0700
# Node ID fa1618118c0603dafd8b7afbeab0e95f3e4307b0
# Parent 102f291807c92864a2231e5e925d6cd64783bb59
# Available At
https://urldefense.proofpoint.com/v2/url?u=https-3A__bitbucket.org_quark-2Dzju_hg-2Ddraft&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=Jw8rundaE7TbmqBYd1txIQ&m=dOvsJimzZK2HUO1Uuv03sjad5iNJbyVwkDFJTjCGklk&s=5wu-xCgtBalppj9ukMNAcetnR0vS291ibigIMAEi-4Q&e=
# hg pull
https://urldefense.proofpoint.com/v2/url?u=https-3A__bitbucket.org_quark-2Dzju_hg-2Ddraft&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=Jw8rundaE7TbmqBYd1txIQ&m=dOvsJimzZK2HUO1Uuv03sjad5iNJbyVwkDFJTjCGklk&s=5wu-xCgtBalppj9ukMNAcetnR0vS291ibigIMAEi-4Q&e=
-r fa1618118c06
scmutil: add a method to convert environment variables to config items
We will put this "config generated by environment variables" thing in a
desired layer - ex. above system configs, below user configs.
The method was designed to be reusable if we want more complex layers - like
multiple environment-generated configs; or test environment configs using a
different environ dict.
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -405,4 +405,18 @@ def osrcpath():
return path
+def envconfig(envlist, env=None):
+ '''[(section, name, value, source)] extracted from environment variables
+
+ envlist is a list of (envname, section, configname)
+ '''
+ if env is None:
+ env = encoding.environ
+ result = []
+ for envname, section, configname in envlist:
+ if envname not in env:
+ continue
+ result.append((section, configname, env[envname], '$%s' % envname))
+ return result
+
_rcpath = None
This function is fine, but scmutil feels like the wrong place for it.
Why is it not in config.py?
This same question applies to patches 2-5 as well. I seems like most of
this should be living in config.py.
We can move it over in a future series, I suppose?
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel