Chromium Code Reviews

Side by Side Diff: commit_queue.py

Issue 1485663002: Add ability to retrieve cl commit bit on cmd line. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 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 """Access the commit queue from the command line. 6 """Access the commit queue from the command line.
7 """ 7 """
8 8
9 __version__ = '0.1' 9 __version__ = '0.1'
10 10
(...skipping 59 matching lines...)
70 help='Rietveld server, default: %default') 70 help='Rietveld server, default: %default')
71 auth.add_auth_options(parser) 71 auth.add_auth_options(parser)
72 72
73 # Call the original function with the modified parser. 73 # Call the original function with the modified parser.
74 return fn(parser, args, *extra_args, **kwargs) 74 return fn(parser, args, *extra_args, **kwargs)
75 75
76 hook.func_usage_more = '[options]' 76 hook.func_usage_more = '[options]'
77 return hook 77 return hook
78 78
79 79
80 def get_commit(obj, issue):
81 """Gets the commit bit flag of an issue."""
82 try:
83 print int(obj.get_issue_properties(issue, False)['commit'])
84 except urllib2.HTTPError, e:
85 if e.code == 404:
Michael Hablich 2015/11/30 13:24:19 Nit: Line 85 to 91 could be extracted in a separat
Michael Achenbach 2015/11/30 13:35:37 Done.
86 print >> sys.stderr, 'Issue %d doesn\'t exist.' % issue
87 elif e.code == 403:
88 print >> sys.stderr, 'Access denied to issue %d.' % issue
89 else:
90 raise
91 return 1
92
80 def set_commit(obj, issue, flag): 93 def set_commit(obj, issue, flag):
81 """Sets the commit bit flag on an issue.""" 94 """Sets the commit bit flag on an issue."""
82 try: 95 try:
83 patchset = obj.get_issue_properties(issue, False)['patchsets'][-1] 96 patchset = obj.get_issue_properties(issue, False)['patchsets'][-1]
84 print obj.set_flag(issue, patchset, 'commit', flag) 97 print obj.set_flag(issue, patchset, 'commit', flag)
85 except urllib2.HTTPError, e: 98 except urllib2.HTTPError, e:
86 if e.code == 404: 99 if e.code == 404:
87 print >> sys.stderr, 'Issue %d doesn\'t exist.' % issue 100 print >> sys.stderr, 'Issue %d doesn\'t exist.' % issue
88 elif e.code == 403: 101 elif e.code == 403:
89 print >> sys.stderr, 'Access denied to issue %d.' % issue 102 print >> sys.stderr, 'Access denied to issue %d.' % issue
90 else: 103 else:
91 raise 104 raise
92 return 1 105 return 1
93 106
94 @need_issue 107 @need_issue
95 def CMDset(parser, args): 108 def CMDset(parser, args):
96 """Sets the commit bit.""" 109 """Sets the commit bit."""
97 options, args, obj = parser.parse_args(args) 110 options, args, obj = parser.parse_args(args)
98 if args: 111 if args:
99 parser.error('Unrecognized args: %s' % ' '.join(args)) 112 parser.error('Unrecognized args: %s' % ' '.join(args))
100 return set_commit(obj, options.issue, '1') 113 return set_commit(obj, options.issue, '1')
101 114
115 @need_issue
116 def CMDget(parser, args):
117 """Gets the commit bit."""
118 options, args, obj = parser.parse_args(args)
119 if args:
120 parser.error('Unrecognized args: %s' % ' '.join(args))
121 return get_commit(obj, options.issue)
102 122
103 @need_issue 123 @need_issue
104 def CMDclear(parser, args): 124 def CMDclear(parser, args):
105 """Clears the commit bit.""" 125 """Clears the commit bit."""
106 options, args, obj = parser.parse_args(args) 126 options, args, obj = parser.parse_args(args)
107 if args: 127 if args:
108 parser.error('Unrecognized args: %s' % ' '.join(args)) 128 parser.error('Unrecognized args: %s' % ' '.join(args))
109 return set_commit(obj, options.issue, '0') 129 return set_commit(obj, options.issue, '0')
110 130
111 131
(...skipping 131 matching lines...)
243 return CMDhelp(parser, args) 263 return CMDhelp(parser, args)
244 264
245 265
246 if __name__ == "__main__": 266 if __name__ == "__main__":
247 fix_encoding.fix_encoding() 267 fix_encoding.fix_encoding()
248 try: 268 try:
249 sys.exit(main()) 269 sys.exit(main())
250 except KeyboardInterrupt: 270 except KeyboardInterrupt:
251 sys.stderr.write('interrupted\n') 271 sys.stderr.write('interrupted\n')
252 sys.exit(1) 272 sys.exit(1)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine