125 _rccomponents.append(envrc) |
128 _rccomponents.append(envrc) |
126 _rccomponents.extend(normpaths(userrcpath())) |
129 _rccomponents.extend(normpaths(userrcpath())) |
127 return _rccomponents |
130 return _rccomponents |
128 |
131 |
129 |
132 |
|
133 def _shared_source_component(path: bytes) -> List[FileRCT]: |
|
134 """if the current repository is shared one, this tries to read |
|
135 .hg/hgrc of shared source if we are in share-safe mode |
|
136 |
|
137 This should be called before reading .hg/hgrc or the main repo |
|
138 as that overrides config set in shared source""" |
|
139 try: |
|
140 with open(os.path.join(path, b".hg", b"requires"), "rb") as fp: |
|
141 requirements = set(fp.read().splitlines()) |
|
142 if not ( |
|
143 requirementsmod.SHARESAFE_REQUIREMENT in requirements |
|
144 and requirementsmod.SHARED_REQUIREMENT in requirements |
|
145 ): |
|
146 return [] |
|
147 hgvfs = vfs.vfs(os.path.join(path, b".hg")) |
|
148 sharedvfs = localrepo._getsharedvfs(hgvfs, requirements) |
|
149 return [sharedvfs.join(b"hgrc")] |
|
150 except IOError: |
|
151 pass |
|
152 return [] |
|
153 |
|
154 |
|
155 def repo_components(repo_path: bytes) -> List[FileRCT]: |
|
156 """return the list of config file to read for a repository""" |
|
157 components = [] |
|
158 components.extend(_shared_source_component(repo_path)) |
|
159 components.append(os.path.join(repo_path, b".hg", b"hgrc")) |
|
160 components.append(os.path.join(repo_path, b".hg", b"hgrc-not-shared")) |
|
161 return components |
|
162 |
|
163 |
130 def defaultpagerenv() -> Dict[bytes, bytes]: |
164 def defaultpagerenv() -> Dict[bytes, bytes]: |
131 """return a dict of default environment variables and their values, |
165 """return a dict of default environment variables and their values, |
132 intended to be set before starting a pager. |
166 intended to be set before starting a pager. |
133 """ |
167 """ |
134 return {b'LESS': b'FRX', b'LV': b'-c'} |
168 return {b'LESS': b'FRX', b'LV': b'-c'} |