Show More
@@ -66,6 +66,7 b' from mercurial import (' | |||||
66 | exthelper, |
|
66 | exthelper, | |
67 | graphmod, |
|
67 | graphmod, | |
68 | httpconnection as httpconnectionmod, |
|
68 | httpconnection as httpconnectionmod, | |
|
69 | localrepo, | |||
69 | logcmdutil, |
|
70 | logcmdutil, | |
70 | match, |
|
71 | match, | |
71 | mdiff, |
|
72 | mdiff, | |
@@ -101,6 +102,7 b' cmdtable = eh.cmdtable' | |||||
101 | command = eh.command |
|
102 | command = eh.command | |
102 | configtable = eh.configtable |
|
103 | configtable = eh.configtable | |
103 | templatekeyword = eh.templatekeyword |
|
104 | templatekeyword = eh.templatekeyword | |
|
105 | uisetup = eh.finaluisetup | |||
104 |
|
106 | |||
105 | # developer config: phabricator.batchsize |
|
107 | # developer config: phabricator.batchsize | |
106 | eh.configitem( |
|
108 | eh.configitem( | |
@@ -152,6 +154,39 b' colortable = {' | |||||
152 | ] |
|
154 | ] | |
153 |
|
155 | |||
154 |
|
156 | |||
|
157 | @eh.wrapfunction(localrepo, "loadhgrc") | |||
|
158 | def _loadhgrc(orig, ui, wdirvfs, hgvfs, requirements): | |||
|
159 | """Load ``.arcconfig`` content into a ui instance on repository open. | |||
|
160 | """ | |||
|
161 | result = False | |||
|
162 | arcconfig = {} | |||
|
163 | ||||
|
164 | try: | |||
|
165 | # json.loads only accepts bytes from 3.6+ | |||
|
166 | rawparams = encoding.unifromlocal(wdirvfs.read(b".arcconfig")) | |||
|
167 | # json.loads only returns unicode strings | |||
|
168 | arcconfig = pycompat.rapply( | |||
|
169 | lambda x: encoding.unitolocal(x) | |||
|
170 | if isinstance(x, pycompat.unicode) | |||
|
171 | else x, | |||
|
172 | pycompat.json_loads(rawparams), | |||
|
173 | ) | |||
|
174 | ||||
|
175 | result = True | |||
|
176 | except ValueError: | |||
|
177 | ui.warn(_(b"invalid JSON in %s\n") % wdirvfs.join(b".arcconfig")) | |||
|
178 | except IOError: | |||
|
179 | pass | |||
|
180 | ||||
|
181 | if b"repository.callsign" in arcconfig: | |||
|
182 | ui.applyconfig( | |||
|
183 | {(b"phabricator", b"callsign"): arcconfig[b"repository.callsign"]}, | |||
|
184 | source=wdirvfs.join(b".arcconfig"), | |||
|
185 | ) | |||
|
186 | ||||
|
187 | return orig(ui, wdirvfs, hgvfs, requirements) or result # Load .hg/hgrc | |||
|
188 | ||||
|
189 | ||||
155 | def vcrcommand(name, flags, spec, helpcategory=None, optionalrepo=False): |
|
190 | def vcrcommand(name, flags, spec, helpcategory=None, optionalrepo=False): | |
156 | fullflags = flags + _VCR_FLAGS |
|
191 | fullflags = flags + _VCR_FLAGS | |
157 |
|
192 |
@@ -210,5 +210,37 b' Phabreading a DREV with a local:commits ' | |||||
210 | extensions.loadall(self.ui) |
|
210 | extensions.loadall(self.ui) | |
211 |
|
211 | |||
212 |
|
212 | |||
|
213 | A bad .arcconfig doesn't error out | |||
|
214 | $ echo 'garbage' > .arcconfig | |||
|
215 | $ hg config phabricator --debug | |||
|
216 | invalid JSON in $TESTTMP/repo/.arcconfig | |||
|
217 | read config from: */.hgrc (glob) | |||
|
218 | $TESTTMP/repo/.hg/hgrc:*: phabricator.url=https://phab.mercurial-scm.org/ (glob) | |||
|
219 | $TESTTMP/repo/.hg/hgrc:*: phabricator.callsign=HG (glob) | |||
|
220 | ||||
|
221 | The .arcconfig content overrides global config | |||
|
222 | $ cat >> $HGRCPATH << EOF | |||
|
223 | > [phabricator] | |||
|
224 | > url = global | |||
|
225 | > callsign = global | |||
|
226 | > EOF | |||
|
227 | $ cp $TESTDIR/../.arcconfig . | |||
|
228 | $ mv .hg/hgrc .hg/hgrc.bak | |||
|
229 | $ hg config phabricator --debug | |||
|
230 | read config from: */.hgrc (glob) | |||
|
231 | */.hgrc:*: phabricator.url=global (glob) | |||
|
232 | $TESTTMP/repo/.arcconfig: phabricator.callsign=HG | |||
|
233 | ||||
|
234 | But it doesn't override local config | |||
|
235 | $ cat >> .hg/hgrc << EOF | |||
|
236 | > [phabricator] | |||
|
237 | > url = local | |||
|
238 | > callsign = local | |||
|
239 | > EOF | |||
|
240 | $ hg config phabricator --debug | |||
|
241 | read config from: */.hgrc (glob) | |||
|
242 | $TESTTMP/repo/.hg/hgrc:*: phabricator.url=local (glob) | |||
|
243 | $TESTTMP/repo/.hg/hgrc:*: phabricator.callsign=local (glob) | |||
|
244 | $ mv .hg/hgrc.bak .hg/hgrc | |||
213 |
|
245 | |||
214 | $ cd .. |
|
246 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now