phabricator: follow-up phab auth improvements with backwards compat mode
authorAugie Fackler <augie@google.com>
Sun, 04 Mar 2018 11:46:03 -0500
changeset 36796 b434965f984e
parent 36795 4397909f82d3
child 36797 09b58af83d44
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
contrib/phabricator.py
--- 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