Commit 4b233bdb authored by tandrii's avatar tandrii Committed by Commit bot

Implement git cl set-commit --dry-run for Rietveld.

BUG=622828
R=emso@chromium.org,machenbach@chromium.org

Review-Url: https://codereview.chromium.org/2127633003
parent f8a3b38c
......@@ -1737,12 +1737,18 @@ class _RietveldChangelistImpl(_ChangelistCodereviewBase):
return self.RpcServer().close_issue(self.GetIssue())
def SetFlag(self, flag, value):
"""Patchset must match."""
return self.SetFlags({flag: value})
def SetFlags(self, flags):
"""Sets flags on this CL/patchset in Rietveld.
The latest patchset in Rietveld must be the same as latest known locally.
"""
if not self.GetPatchset():
DieWithError('The patchset needs to match. Send another patchset.')
try:
return self.RpcServer().set_flag(
self.GetIssue(), self.GetPatchset(), flag, value)
return self.RpcServer().set_flags(
self.GetIssue(), self.GetPatchset(), flags)
except urllib2.HTTPError as e:
if e.code == 404:
DieWithError('The issue %s doesn\'t exist.' % self.GetIssue())
......@@ -1791,9 +1797,10 @@ class _RietveldChangelistImpl(_ChangelistCodereviewBase):
if new_state == _CQState.COMMIT:
self.SetFlag('commit', '1')
elif new_state == _CQState.NONE:
self.SetFlag('commit', '0')
self.SetFlags({'commit': '0', 'cq_dry_run': '0'})
else:
raise NotImplementedError()
assert new_state == _CQState.DRY_RUN
self.SetFlags({'commit': '1', 'cq_dry_run': '1'})
def CMDPatchWithParsedIssue(self, parsed_issue_arg, reject, nocommit,
......
......@@ -278,6 +278,12 @@ class Rietveld(object):
('xsrf_token', self.xsrf_token()),
(flag, str(value))])
def set_flags(self, issue, patchset, flags):
return self.post('/%d/edit_flags' % issue, [
('last_patchset', str(patchset)),
('xsrf_token', self.xsrf_token()),
] + [(flag, str(value)) for flag, value in flags.iteritems()])
def search(
self,
owner=None, reviewer=None,
......@@ -744,6 +750,10 @@ class ReadOnlyRietveld(object):
(flag, value, issue))
ReadOnlyRietveld._local_changes.setdefault(issue, {})[flag] = value
def set_flags(self, issue, patchset, flags):
for flag, value in flags.iteritems():
self.set_flag(issue, patchset, flag, value)
def trigger_try_jobs( # pylint:disable=R0201
self, issue, patchset, reason, clobber, revision, builders_and_tests,
master=None, category='cq'):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment