Changeset View
Changeset View
Standalone View
Standalone View
hgext/phabricator.py
Show First 20 Lines • Show All 97 Lines • ▼ Show 20 Line(s) | from mercurial import ( | ||||
templatefilters, | templatefilters, | ||||
templateutil, | templateutil, | ||||
url as urlmod, | url as urlmod, | ||||
util, | util, | ||||
) | ) | ||||
from mercurial.utils import ( | from mercurial.utils import ( | ||||
procutil, | procutil, | ||||
stringutil, | stringutil, | ||||
urlutil, | |||||
) | ) | ||||
from . import show | from . import show | ||||
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | ||||
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should | ||||
# be specifying the version(s) of Mercurial they are tested with, or | # be specifying the version(s) of Mercurial they are tested with, or | ||||
# leave the attribute unspecified. | # leave the attribute unspecified. | ||||
▲ Show 20 Lines • Show All 247 Lines • ▼ Show 20 Line(s) | def process(prefix, obj): | ||||
else: | else: | ||||
for k, v in items(obj): | for k, v in items(obj): | ||||
if prefix: | if prefix: | ||||
process(b'%s[%s]' % (prefix, k), v) | process(b'%s[%s]' % (prefix, k), v) | ||||
else: | else: | ||||
process(k, v) | process(k, v) | ||||
process(b'', params) | process(b'', params) | ||||
return util.urlreq.urlencode(flatparams) | return urlutil.urlreq.urlencode(flatparams) | ||||
def readurltoken(ui): | def readurltoken(ui): | ||||
"""return conduit url, token and make sure they exist | """return conduit url, token and make sure they exist | ||||
Currently read from [auth] config section. In the future, it might | Currently read from [auth] config section. In the future, it might | ||||
make sense to read from .arcconfig and .arcrc as well. | make sense to read from .arcconfig and .arcrc as well. | ||||
""" | """ | ||||
url = ui.config(b'phabricator', b'url') | url = ui.config(b'phabricator', b'url') | ||||
if not url: | if not url: | ||||
raise error.Abort( | raise error.Abort( | ||||
_(b'config %s.%s is required') % (b'phabricator', b'url') | _(b'config %s.%s is required') % (b'phabricator', b'url') | ||||
) | ) | ||||
res = httpconnectionmod.readauthforuri(ui, url, util.url(url).user) | res = httpconnectionmod.readauthforuri(ui, url, urlutil.url(url).user) | ||||
token = None | token = None | ||||
if res: | if res: | ||||
group, auth = res | group, auth = res | ||||
ui.debug(b"using auth.%s.* for authentication\n" % group) | ui.debug(b"using auth.%s.* for authentication\n" % group) | ||||
token = auth.get(b'phabtoken') | token = auth.get(b'phabtoken') | ||||
▲ Show 20 Lines • Show All 2008 Lines • Show Last 20 Lines |