This revision was automatically updated to reflect the committed changes. Closed by commit rHG4397909f82d3: phabricator: specify API tokens per host, rather than per repo (authored by tom.prince, committed by ).
REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D1919?vs=4960&id=6730 REVISION DETAIL https://phab.mercurial-scm.org/D1919 AFFECTED FILES contrib/phabricator.py CHANGE DETAILS diff --git a/contrib/phabricator.py b/contrib/phabricator.py --- a/contrib/phabricator.py +++ b/contrib/phabricator.py @@ -33,6 +33,11 @@ # if you need to specify advanced options that is not easily supported by # the internal library. curlcmd = curl --connect-timeout 2 --retry 3 --silent + + [phabricator.auth] + example.url = https://phab.example.com/ + # API token. Get it from https://$HOST/conduit/login/ + example.token = cli-xxxxxxxxxxxxxxxxxxxxxxxxxxxx """ from __future__ import absolute_import @@ -100,14 +105,33 @@ Currently read from [phabricator] config section. In the future, it might make sense to read from .arcconfig and .arcrc as well. """ - values = [] - section = 'phabricator' - for name in ['url', 'token']: - value = repo.ui.config(section, name) - if not value: - raise error.Abort(_('config %s.%s is required') % (section, name)) - values.append(value) - return values + url = repo.ui.config('phabricator', 'url') + if not url: + raise error.Abort(_('config %s.%s is required') + % ('phabricator', 'url')) + + groups = {} + for key, val in repo.ui.configitems('phabricator.auth'): + if '.' not in key: + repo.ui.warn(_("ignoring invalid [phabricator.auth] key '%s'\n") + % key) + continue + group, setting = key.rsplit('.', 1) + groups.setdefault(group, {})[setting] = val + + token = None + for group, auth in groups.iteritems(): + if url != auth.get('url'): + continue + token = auth.get('token') + if token: + break + + if not token: + raise error.Abort(_('Can\'t find conduit token associated to %s') + % (url,)) + + return url, token def callconduit(repo, name, params): """call Conduit API, params is a dict. return json.loads result, or None""" To: tom.prince, #hg-reviewers, durin42 Cc: quark, indygreg, durin42, pulkit, mercurial-devel _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel