Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(680)

Side by Side Diff: git_cl.py

Issue 2127633003: Implement git cl set-commit --dry-run for Rietveld. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: be consistent Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | rietveld.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # Copyright (C) 2008 Evan Martin <martine@danga.com> 6 # Copyright (C) 2008 Evan Martin <martine@danga.com>
7 7
8 """A git-command for integrating reviews on Rietveld and Gerrit.""" 8 """A git-command for integrating reviews on Rietveld and Gerrit."""
9 9
10 from __future__ import print_function 10 from __future__ import print_function
(...skipping 1719 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 return 'waiting' 1730 return 'waiting'
1731 1731
1732 def UpdateDescriptionRemote(self, description): 1732 def UpdateDescriptionRemote(self, description):
1733 return self.RpcServer().update_description( 1733 return self.RpcServer().update_description(
1734 self.GetIssue(), self.description) 1734 self.GetIssue(), self.description)
1735 1735
1736 def CloseIssue(self): 1736 def CloseIssue(self):
1737 return self.RpcServer().close_issue(self.GetIssue()) 1737 return self.RpcServer().close_issue(self.GetIssue())
1738 1738
1739 def SetFlag(self, flag, value): 1739 def SetFlag(self, flag, value):
1740 """Patchset must match.""" 1740 return self.SetFlags({flag: value})
1741
1742 def SetFlags(self, flags):
1743 """Sets flags on this CL/patchset in Rietveld.
1744
1745 The latest patchset in Rietveld must be the same as latest known locally.
1746 """
1741 if not self.GetPatchset(): 1747 if not self.GetPatchset():
1742 DieWithError('The patchset needs to match. Send another patchset.') 1748 DieWithError('The patchset needs to match. Send another patchset.')
1743 try: 1749 try:
1744 return self.RpcServer().set_flag( 1750 return self.RpcServer().set_flags(
1745 self.GetIssue(), self.GetPatchset(), flag, value) 1751 self.GetIssue(), self.GetPatchset(), flags)
1746 except urllib2.HTTPError as e: 1752 except urllib2.HTTPError as e:
1747 if e.code == 404: 1753 if e.code == 404:
1748 DieWithError('The issue %s doesn\'t exist.' % self.GetIssue()) 1754 DieWithError('The issue %s doesn\'t exist.' % self.GetIssue())
1749 if e.code == 403: 1755 if e.code == 403:
1750 DieWithError( 1756 DieWithError(
1751 ('Access denied to issue %s. Maybe the patchset %s doesn\'t ' 1757 ('Access denied to issue %s. Maybe the patchset %s doesn\'t '
1752 'match?') % (self.GetIssue(), self.GetPatchset())) 1758 'match?') % (self.GetIssue(), self.GetPatchset()))
1753 raise 1759 raise
1754 1760
1755 def RpcServer(self): 1761 def RpcServer(self):
(...skipping 28 matching lines...) Expand all
1784 return self.RpcServer() 1790 return self.RpcServer()
1785 1791
1786 def SetCQState(self, new_state): 1792 def SetCQState(self, new_state):
1787 props = self.GetIssueProperties() 1793 props = self.GetIssueProperties()
1788 if props.get('private'): 1794 if props.get('private'):
1789 DieWithError('Cannot set-commit on private issue') 1795 DieWithError('Cannot set-commit on private issue')
1790 1796
1791 if new_state == _CQState.COMMIT: 1797 if new_state == _CQState.COMMIT:
1792 self.SetFlag('commit', '1') 1798 self.SetFlag('commit', '1')
1793 elif new_state == _CQState.NONE: 1799 elif new_state == _CQState.NONE:
1794 self.SetFlag('commit', '0') 1800 self.SetFlags({'commit': '0', 'cq_dry_run': '0'})
1795 else: 1801 else:
1796 raise NotImplementedError() 1802 assert new_state == _CQState.DRY_RUN
1803 self.SetFlags({'commit': '1', 'cq_dry_run': '1'})
1797 1804
1798 1805
1799 def CMDPatchWithParsedIssue(self, parsed_issue_arg, reject, nocommit, 1806 def CMDPatchWithParsedIssue(self, parsed_issue_arg, reject, nocommit,
1800 directory): 1807 directory):
1801 # TODO(maruel): Use apply_issue.py 1808 # TODO(maruel): Use apply_issue.py
1802 1809
1803 # PatchIssue should never be called with a dirty tree. It is up to the 1810 # PatchIssue should never be called with a dirty tree. It is up to the
1804 # caller to check this, but just in case we assert here since the 1811 # caller to check this, but just in case we assert here since the
1805 # consequences of the caller not checking this could be dire. 1812 # consequences of the caller not checking this could be dire.
1806 assert(not git_common.is_dirty_git_tree('apply')) 1813 assert(not git_common.is_dirty_git_tree('apply'))
(...skipping 3290 matching lines...) Expand 10 before | Expand all | Expand 10 after
5097 if __name__ == '__main__': 5104 if __name__ == '__main__':
5098 # These affect sys.stdout so do it outside of main() to simplify mocks in 5105 # These affect sys.stdout so do it outside of main() to simplify mocks in
5099 # unit testing. 5106 # unit testing.
5100 fix_encoding.fix_encoding() 5107 fix_encoding.fix_encoding()
5101 setup_color.init() 5108 setup_color.init()
5102 try: 5109 try:
5103 sys.exit(main(sys.argv[1:])) 5110 sys.exit(main(sys.argv[1:]))
5104 except KeyboardInterrupt: 5111 except KeyboardInterrupt:
5105 sys.stderr.write('interrupted\n') 5112 sys.stderr.write('interrupted\n')
5106 sys.exit(1) 5113 sys.exit(1)
OLDNEW
« no previous file with comments | « no previous file | rietveld.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698