Patchwork D6497: phabricator: pass ui into readurltoken instead of passing repo

login
register
mail settings
Submitter phabricator
Date June 8, 2019, 4:07 p.m.
Message ID <differential-rev-PHID-DREV-jyxqhk7orookkkubzkpy-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/40366/
State Superseded
Headers show

Comments

phabricator - June 8, 2019, 4:07 p.m.
pulkit created this revision.
Herald added subscribers: mercurial-devel, Kwan.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The goal of this series is to make `hg debugcallconduit` work outside of a hg
  repo.
  
  This patch, removes requirement of repo object from readurltoken as we only need
  ui there. It also updates the callers to pass in ui instead of repo.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6497

AFFECTED FILES
  hgext/phabricator.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: Kwan, mercurial-devel

Patch

diff --git a/hgext/phabricator.py b/hgext/phabricator.py
--- a/hgext/phabricator.py
+++ b/hgext/phabricator.py
@@ -183,24 +183,24 @@ 
     process(b'', params)
     return util.urlreq.urlencode(flatparams)
 
-def readurltoken(repo):
+def readurltoken(ui):
     """return conduit url, token and make sure they exist
 
     Currently read from [auth] config section. In the future, it might
     make sense to read from .arcconfig and .arcrc as well.
     """
-    url = repo.ui.config(b'phabricator', b'url')
+    url = ui.config(b'phabricator', b'url')
     if not url:
         raise error.Abort(_(b'config %s.%s is required')
                           % (b'phabricator', b'url'))
 
-    res = httpconnectionmod.readauthforuri(repo.ui, url, util.url(url).user)
+    res = httpconnectionmod.readauthforuri(ui, url, util.url(url).user)
     token = None
 
     if res:
         group, auth = res
 
-        repo.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')
 
@@ -212,7 +212,7 @@ 
 
 def callconduit(repo, name, params):
     """call Conduit API, params is a dict. return json.loads result, or None"""
-    host, token = readurltoken(repo)
+    host, token = readurltoken(repo.ui)
     url, authinfo = util.url(b'/'.join([host, b'api', name])).authinfo()
     repo.ui.debug(b'Conduit Call: %s %s\n' % (url, pycompat.byterepr(params)))
     params = params.copy()
@@ -648,7 +648,7 @@ 
                               (b'parent', b'Parent ')])
 
 def _confirmbeforesend(repo, revs, oldmap):
-    url, token = readurltoken(repo)
+    url, token = readurltoken(repo.ui)
     ui = repo.ui
     for rev in revs:
         ctx = repo[rev]