Show More
@@ -2223,6 +2223,8 b' def config(ui, repo, *values, **opts):' | |||
|
2223 | 2223 | for t, f in rcutil.rccomponents(): |
|
2224 | 2224 | if t == b'path': |
|
2225 | 2225 | ui.debug(b'read config from: %s\n' % f) |
|
2226 | elif t == b'resource': | |
|
2227 | ui.debug(b'read config from: resource:%s.%s\n' % (f[0], f[1])) | |
|
2226 | 2228 | elif t == b'items': |
|
2227 | 2229 | # Don't print anything for 'items'. |
|
2228 | 2230 | pass |
@@ -67,6 +67,17 b' def defaultrcpath():' | |||
|
67 | 67 | return _expandrcpath(defaultpath) |
|
68 | 68 | |
|
69 | 69 | |
|
70 | def default_rc_resources(): | |
|
71 | """return rc resource IDs in defaultrc""" | |
|
72 | rsrcs = resourceutil.contents(b'mercurial.defaultrc') | |
|
73 | return [ | |
|
74 | (b'mercurial.defaultrc', r) | |
|
75 | for r in sorted(rsrcs) | |
|
76 | if resourceutil.is_resource(b'mercurial.defaultrc', r) | |
|
77 | and r.endswith(b'.rc') | |
|
78 | ] | |
|
79 | ||
|
80 | ||
|
70 | 81 | def rccomponents(): |
|
71 | 82 | '''return an ordered [(type, obj)] about where to load configs. |
|
72 | 83 | |
@@ -75,9 +86,10 b' def rccomponents():' | |||
|
75 | 86 | |
|
76 | 87 | if a directory is provided, *.rc files under it will be used. |
|
77 | 88 | |
|
78 |
type could be either 'path' |
|
|
79 |
and is the config file path. if type is 'items', obj is a |
|
|
80 | name, value, source) that should fill the config directly. | |
|
89 | type could be either 'path', 'items' or 'resource'. If type is 'path', | |
|
90 | obj is a string, and is the config file path. if type is 'items', obj is a | |
|
91 | list of (section, name, value, source) that should fill the config directly. | |
|
92 | If type is 'resource', obj is a tuple of (package name, resource name). | |
|
81 | 93 | ''' |
|
82 | 94 | envrc = (b'items', envrcitems()) |
|
83 | 95 | |
@@ -90,10 +102,12 b' def rccomponents():' | |||
|
90 | 102 | continue |
|
91 | 103 | _rccomponents.extend((b'path', p) for p in _expandrcpath(p)) |
|
92 | 104 | else: |
|
105 | _rccomponents = [(b'resource', r) for r in default_rc_resources()] | |
|
106 | ||
|
93 | 107 | normpaths = lambda paths: [ |
|
94 | 108 | (b'path', os.path.normpath(p)) for p in paths |
|
95 | 109 | ] |
|
96 |
_rccomponents |
|
|
110 | _rccomponents.extend(normpaths(defaultrcpath() + systemrcpath())) | |
|
97 | 111 | _rccomponents.append(envrc) |
|
98 | 112 | _rccomponents.extend(normpaths(userrcpath())) |
|
99 | 113 | return _rccomponents |
@@ -308,6 +308,8 b' class ui(object):' | |||
|
308 | 308 | for t, f in rcutil.rccomponents(): |
|
309 | 309 | if t == b'path': |
|
310 | 310 | u.readconfig(f, trust=True) |
|
311 | elif t == b'resource': | |
|
312 | u.read_resource_config(f, trust=True) | |
|
311 | 313 | elif t == b'items': |
|
312 | 314 | sections = set() |
|
313 | 315 | for section, name, value, source in f: |
General Comments 0
You need to be logged in to leave comments.
Login now