Show More
@@ -1804,8 +1804,11 def config(ui, repo, *values, **opts): | |||||
1804 | return |
|
1804 | return | |
1805 | ui.pager('config') |
|
1805 | ui.pager('config') | |
1806 | fm = ui.formatter('config', opts) |
|
1806 | fm = ui.formatter('config', opts) | |
1807 | for f in rcutil.rccomponents(): |
|
1807 | for t, f in rcutil.rccomponents(): | |
|
1808 | if t == 'path': | |||
1808 | ui.debug('read config from: %s\n' % f) |
|
1809 | ui.debug('read config from: %s\n' % f) | |
|
1810 | else: | |||
|
1811 | raise error.ProgrammingError('unknown rctype: %s' % t) | |||
1809 | untrusted = bool(opts.get('untrusted')) |
|
1812 | untrusted = bool(opts.get('untrusted')) | |
1810 | if values: |
|
1813 | if values: | |
1811 | sections = [v for v in values if '.' not in v] |
|
1814 | sections = [v for v in values if '.' not in v] |
@@ -43,11 +43,17 def defaultrcpath(): | |||||
43 | _rccomponents = None |
|
43 | _rccomponents = None | |
44 |
|
44 | |||
45 | def rccomponents(): |
|
45 | def rccomponents(): | |
46 | '''return hgrc search path. if env var HGRCPATH is set, use it. |
|
46 | '''return an ordered [(type, obj)] about where to load configs. | |
47 | for each item in path, if directory, use files ending in .rc, |
|
47 | ||
48 | else use item. |
|
48 | respect $HGRCPATH. if $HGRCPATH is empty, only .hg/hgrc of current repo is | |
49 | make HGRCPATH empty to only look in .hg/hgrc of current repo. |
|
49 | used. if $HGRCPATH is not set, the platform default will be used. | |
50 | if no HGRCPATH, use default os-specific path.''' |
|
50 | ||
|
51 | if a directory is provided, *.rc files under it will be used. | |||
|
52 | ||||
|
53 | type could be either 'path' or 'items', if type is 'path', obj is a string, | |||
|
54 | and is the config file path. if type is 'items', obj is a list of (section, | |||
|
55 | name, value, source) that should fill the config directly. | |||
|
56 | ''' | |||
51 | global _rccomponents |
|
57 | global _rccomponents | |
52 | if _rccomponents is None: |
|
58 | if _rccomponents is None: | |
53 | if 'HGRCPATH' in encoding.environ: |
|
59 | if 'HGRCPATH' in encoding.environ: | |
@@ -55,8 +61,8 def rccomponents(): | |||||
55 | for p in encoding.environ['HGRCPATH'].split(pycompat.ospathsep): |
|
61 | for p in encoding.environ['HGRCPATH'].split(pycompat.ospathsep): | |
56 | if not p: |
|
62 | if not p: | |
57 | continue |
|
63 | continue | |
58 | _rccomponents.extend(_expandrcpath(p)) |
|
64 | _rccomponents.extend(('path', p) for p in _expandrcpath(p)) | |
59 | else: |
|
65 | else: | |
60 | paths = defaultrcpath() + systemrcpath() + userrcpath() |
|
66 | paths = defaultrcpath() + systemrcpath() + userrcpath() | |
61 |
_rccomponents = |
|
67 | _rccomponents = [('path', os.path.normpath(p)) for p in paths] | |
62 | return _rccomponents |
|
68 | return _rccomponents |
@@ -212,8 +212,11 class ui(object): | |||||
212 | """Create a ui and load global and user configs""" |
|
212 | """Create a ui and load global and user configs""" | |
213 | u = cls() |
|
213 | u = cls() | |
214 | # we always trust global config files |
|
214 | # we always trust global config files | |
215 | for f in rcutil.rccomponents(): |
|
215 | for t, f in rcutil.rccomponents(): | |
|
216 | if t == 'path': | |||
216 | u.readconfig(f, trust=True) |
|
217 | u.readconfig(f, trust=True) | |
|
218 | else: | |||
|
219 | raise error.ProgrammingError('unknown rctype: %s' % t) | |||
217 | return u |
|
220 | return u | |
218 |
|
221 | |||
219 | def copy(self): |
|
222 | def copy(self): |
General Comments 0
You need to be logged in to leave comments.
Login now