First stab at using Rietveld wrapper object in both gcl.py and git-cl.
Exposes InputApi.rietveld and deprecate host_url.
This is useful since it places authentication at a single place.
BUG=
TEST=
Review URL: http://codereview.chromium.org/6825008
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@81019 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/git_cl.py b/git_cl.py
index ba31e18..8cdf131 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -39,6 +39,7 @@
import breakpad # pylint: disable=W0611
import fix_encoding
import presubmit_support
+import rietveld
import scm
import watchlists
@@ -463,7 +464,7 @@
if not self.has_description:
if self.GetIssue():
path = '/' + self.GetIssue() + '/description'
- rpc_server = self._RpcServer()
+ rpc_server = self.RpcServer()
self.description = rpc_server.Send(path).strip()
self.has_description = True
if pretty:
@@ -494,9 +495,9 @@
def GetPatchSetDiff(self, issue):
# Grab the last patchset of the issue first.
- data = json.loads(self._RpcServer().Send('/api/%s' % issue))
+ data = json.loads(self.RpcServer().Send('/api/%s' % issue))
patchset = data['patchsets'][-1]
- return self._RpcServer().Send(
+ return self.RpcServer().Send(
'/download/issue%s_%s.diff' % (issue, patchset))
def SetIssue(self, issue):
@@ -511,7 +512,7 @@
self.has_issue = False
def CloseIssue(self):
- rpc_server = self._RpcServer()
+ rpc_server = self.RpcServer()
# Newer versions of Rietveld require us to pass an XSRF token to POST, so
# we fetch it from the server. (The version used by Chromium has been
# modified so the token isn't required when closing an issue.)
@@ -523,14 +524,15 @@
data = [("description", self.description),
("xsrf_token", xsrf_token)]
ctype, body = upload.EncodeMultipartFormData(data, [])
- rpc_server.Send('/' + self.GetIssue() + '/close', body, ctype)
+ rpc_server.Send(
+ '/' + self.GetIssue() + '/close', payload=body, content_type=ctype)
- def _RpcServer(self):
+ def RpcServer(self):
"""Returns an upload.RpcServer() to access this review's rietveld instance.
"""
if not self._rpc_server:
- server = self.GetRietveldServer()
- self._rpc_server = upload.GetRpcServer(server, save_cookies=True)
+ self.GetIssue()
+ self._rpc_server = rietveld.Rietveld(self.rietveld_server, None, None)
return self._rpc_server
def _IssueSetting(self):
@@ -848,7 +850,7 @@
output = presubmit_support.DoPresubmitChecks(change, committing,
verbose=verbose, output_stream=sys.stdout, input_stream=sys.stdin,
default_presubmit=None, may_prompt=may_prompt, tbr=tbr,
- host_url=cl.GetRietveldServer())
+ rietveld=cl.RpcServer())
except presubmit_support.PresubmitFailure, e:
DieWithError(
('%s\nMaybe your depot_tools is out of date?\n'