Show More
@@ -32,7 +32,9 b' Config::' | |||||
32 | curlcmd = curl --connect-timeout 2 --retry 3 --silent |
|
32 | curlcmd = curl --connect-timeout 2 --retry 3 --silent | |
33 |
|
33 | |||
34 | [auth] |
|
34 | [auth] | |
35 | example.url = https://phab.example.com/ |
|
35 | example.schemes = https | |
|
36 | example.prefix = phab.example.com | |||
|
37 | ||||
36 | # API token. Get it from https://$HOST/conduit/login/ |
|
38 | # API token. Get it from https://$HOST/conduit/login/ | |
37 | example.phabtoken = cli-xxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|
39 | example.phabtoken = cli-xxxxxxxxxxxxxxxxxxxxxxxxxxxx | |
38 | """ |
|
40 | """ | |
@@ -51,6 +53,7 b' from mercurial import (' | |||||
51 | context, |
|
53 | context, | |
52 | encoding, |
|
54 | encoding, | |
53 | error, |
|
55 | error, | |
|
56 | httpconnection as httpconnectionmod, | |||
54 | mdiff, |
|
57 | mdiff, | |
55 | obsutil, |
|
58 | obsutil, | |
56 | parser, |
|
59 | parser, | |
@@ -135,7 +138,7 b' def readlegacytoken(repo, url):' | |||||
135 | def readurltoken(repo): |
|
138 | def readurltoken(repo): | |
136 | """return conduit url, token and make sure they exist |
|
139 | """return conduit url, token and make sure they exist | |
137 |
|
140 | |||
138 |
Currently read from [ |
|
141 | Currently read from [auth] config section. In the future, it might | |
139 | make sense to read from .arcconfig and .arcrc as well. |
|
142 | make sense to read from .arcconfig and .arcrc as well. | |
140 | """ |
|
143 | """ | |
141 | url = repo.ui.config('phabricator', 'url') |
|
144 | url = repo.ui.config('phabricator', 'url') | |
@@ -143,22 +146,15 b' def readurltoken(repo):' | |||||
143 | raise error.Abort(_('config %s.%s is required') |
|
146 | raise error.Abort(_('config %s.%s is required') | |
144 | % ('phabricator', 'url')) |
|
147 | % ('phabricator', 'url')) | |
145 |
|
148 | |||
146 | groups = {} |
|
149 | res = httpconnectionmod.readauthforuri(repo.ui, url, util.url(url).user) | |
147 | for key, val in repo.ui.configitems('auth'): |
|
150 | token = None | |
148 | if '.' not in key: |
|
|||
149 | repo.ui.warn(_("ignoring invalid [auth] key '%s'\n") |
|
|||
150 | % key) |
|
|||
151 | continue |
|
|||
152 | group, setting = key.rsplit('.', 1) |
|
|||
153 | groups.setdefault(group, {})[setting] = val |
|
|||
154 |
|
151 | |||
155 | token = None |
|
152 | if res: | |
156 | for group, auth in groups.iteritems(): |
|
153 | group, auth = res | |
157 | if url != auth.get('url'): |
|
154 | ||
158 | continue |
|
155 | repo.ui.debug("using auth.%s.* for authentication\n" % group) | |
|
156 | ||||
159 | token = auth.get('phabtoken') |
|
157 | token = auth.get('phabtoken') | |
160 | if token: |
|
|||
161 | break |
|
|||
162 |
|
158 | |||
163 | if not token: |
|
159 | if not token: | |
164 | token = readlegacytoken(repo, url) |
|
160 | token = readlegacytoken(repo, url) |
General Comments 0
You need to be logged in to leave comments.
Login now