Mercurial > hg-stable
comparison hgext/phabricator.py @ 40151:38ac525b44c9
phabricator: drop support for the legacy phabricator.auth.token config (BC)
The test for this broke in dc82ad1b7f77 when statistics started being tracked.
It wasn't noticed because none of the bots have the vcr module installed. It
looks like the custom_patches argument should patch in the custom
httpconnection, and I can't figure out what is going on.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 11 Oct 2018 21:51:17 -0400 |
parents | c0c703861b60 |
children | b015f30a91fb |
comparison
equal
deleted
inserted
replaced
40150:1be1689d9ce9 | 40151:38ac525b44c9 |
---|---|
163 else: | 163 else: |
164 process(k, v) | 164 process(k, v) |
165 process(b'', params) | 165 process(b'', params) |
166 return util.urlreq.urlencode(flatparams) | 166 return util.urlreq.urlencode(flatparams) |
167 | 167 |
168 printed_token_warning = False | |
169 | |
170 def readlegacytoken(repo, url): | |
171 """Transitional support for old phabricator tokens. | |
172 | |
173 Remove before the 4.7 release. | |
174 """ | |
175 groups = {} | |
176 for key, val in repo.ui.configitems(b'phabricator.auth'): | |
177 if b'.' not in key: | |
178 repo.ui.warn(_(b"ignoring invalid [phabricator.auth] key '%s'\n") | |
179 % key) | |
180 continue | |
181 group, setting = key.rsplit(b'.', 1) | |
182 groups.setdefault(group, {})[setting] = val | |
183 | |
184 token = None | |
185 for group, auth in groups.iteritems(): | |
186 if url != auth.get(b'url'): | |
187 continue | |
188 token = auth.get(b'token') | |
189 if token: | |
190 break | |
191 | |
192 global printed_token_warning | |
193 | |
194 if token and not printed_token_warning: | |
195 printed_token_warning = True | |
196 repo.ui.warn(_(b'phabricator.auth.token is deprecated - please ' | |
197 b'migrate to auth.phabtoken.\n')) | |
198 return token | |
199 | |
200 def readurltoken(repo): | 168 def readurltoken(repo): |
201 """return conduit url, token and make sure they exist | 169 """return conduit url, token and make sure they exist |
202 | 170 |
203 Currently read from [auth] config section. In the future, it might | 171 Currently read from [auth] config section. In the future, it might |
204 make sense to read from .arcconfig and .arcrc as well. | 172 make sense to read from .arcconfig and .arcrc as well. |
217 repo.ui.debug(b"using auth.%s.* for authentication\n" % group) | 185 repo.ui.debug(b"using auth.%s.* for authentication\n" % group) |
218 | 186 |
219 token = auth.get(b'phabtoken') | 187 token = auth.get(b'phabtoken') |
220 | 188 |
221 if not token: | 189 if not token: |
222 token = readlegacytoken(repo, url) | 190 raise error.Abort(_(b'Can\'t find conduit token associated to %s') |
223 if not token: | 191 % (url,)) |
224 raise error.Abort(_(b'Can\'t find conduit token associated to %s') | |
225 % (url,)) | |
226 | 192 |
227 return url, token | 193 return url, token |
228 | 194 |
229 def callconduit(repo, name, params): | 195 def callconduit(repo, name, params): |
230 """call Conduit API, params is a dict. return json.loads result, or None""" | 196 """call Conduit API, params is a dict. return json.loads result, or None""" |