contrib/phabricator.py
changeset 36788 b434965f984e
parent 36787 4397909f82d3
child 36817 98cbfbbe33bb
equal deleted inserted replaced
36787:4397909f82d3 36788:b434965f984e
    97                 else:
    97                 else:
    98                     process(k, v)
    98                     process(k, v)
    99     process('', params)
    99     process('', params)
   100     return util.urlreq.urlencode(flatparams)
   100     return util.urlreq.urlencode(flatparams)
   101 
   101 
       
   102 def readlegacytoken(repo):
       
   103     """Transitional support for old phabricator tokens.
       
   104 
       
   105     Remove before the 4.6 release.
       
   106     """
       
   107     token = repo.ui.config('phabricator', 'token')
       
   108     if token:
       
   109         repo.ui.warn(_('phabricator.token is deprecated - please '
       
   110                        'migrate to the phabricator.auth section.\n'))
       
   111     return token
       
   112 
   102 def readurltoken(repo):
   113 def readurltoken(repo):
   103     """return conduit url, token and make sure they exist
   114     """return conduit url, token and make sure they exist
   104 
   115 
   105     Currently read from [phabricator] config section. In the future, it might
   116     Currently read from [phabricator] config section. In the future, it might
   106     make sense to read from .arcconfig and .arcrc as well.
   117     make sense to read from .arcconfig and .arcrc as well.
   126         token = auth.get('token')
   137         token = auth.get('token')
   127         if token:
   138         if token:
   128             break
   139             break
   129 
   140 
   130     if not token:
   141     if not token:
   131         raise error.Abort(_('Can\'t find conduit token associated to %s')
   142         token = readlegacytoken(repo)
   132                           % (url,))
   143         if not token:
       
   144             raise error.Abort(_('Can\'t find conduit token associated to %s')
       
   145                               % (url,))
   133 
   146 
   134     return url, token
   147     return url, token
   135 
   148 
   136 def callconduit(repo, name, params):
   149 def callconduit(repo, name, params):
   137     """call Conduit API, params is a dict. return json.loads result, or None"""
   150     """call Conduit API, params is a dict. return json.loads result, or None"""