changeset 36796:b434965f984e

phabricator: follow-up phab auth improvements with backwards compat mode We'll rip this out before we ship 4.6, but this gives people a window to migrate. Differential Revision: https://phab.mercurial-scm.org/D2703
author Augie Fackler <augie@google.com>
date Sun, 04 Mar 2018 11:46:03 -0500
parents 4397909f82d3
children 09b58af83d44
files contrib/phabricator.py
diffstat 1 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/phabricator.py	Sat Jan 20 02:41:10 2018 -0700
+++ b/contrib/phabricator.py	Sun Mar 04 11:46:03 2018 -0500
@@ -99,6 +99,17 @@
     process('', params)
     return util.urlreq.urlencode(flatparams)
 
+def readlegacytoken(repo):
+    """Transitional support for old phabricator tokens.
+
+    Remove before the 4.6 release.
+    """
+    token = repo.ui.config('phabricator', 'token')
+    if token:
+        repo.ui.warn(_('phabricator.token is deprecated - please '
+                       'migrate to the phabricator.auth section.\n'))
+    return token
+
 def readurltoken(repo):
     """return conduit url, token and make sure they exist
 
@@ -128,8 +139,10 @@
             break
 
     if not token:
-        raise error.Abort(_('Can\'t find conduit token associated to %s')
-                          % (url,))
+        token = readlegacytoken(repo)
+        if not token:
+            raise error.Abort(_('Can\'t find conduit token associated to %s')
+                              % (url,))
 
     return url, token