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

Side by Side Diff: apply_issue.py

Issue 10704111: Allow apply_issue.py to make api calls to rietveld that don't require (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/depot_tools/
Patch Set: Removed default for --email option Created 8 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 | Annotate | Revision Log
« 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 """Applies an issue from Rietveld. 6 """Applies an issue from Rietveld.
7 """ 7 """
8 8
9 import logging 9 import logging
10 import optparse 10 import optparse
11 import os 11 import os
12 import sys 12 import sys
13 13
14 import breakpad # pylint: disable=W0611 14 import breakpad # pylint: disable=W0611
15 15
16 import checkout 16 import checkout
17 import fix_encoding 17 import fix_encoding
18 import rietveld 18 import rietveld
19 import scm 19 import scm
20 20
21 21
22 def main(): 22 def main():
23 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) 23 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__)
24 parser.add_option( 24 parser.add_option(
25 '-v', '--verbose', action='count', default=0, 25 '-v', '--verbose', action='count', default=0,
26 help='Prints debugging infos') 26 help='Prints debugging infos')
27 parser.add_option( 27 parser.add_option(
28 '-e',
29 '--email',
30 help='Email address for authenticating with Rietveld')
31 parser.add_option(
28 '-i', '--issue', type='int', help='Rietveld issue number') 32 '-i', '--issue', type='int', help='Rietveld issue number')
29 parser.add_option( 33 parser.add_option(
30 '-p', '--patchset', type='int', help='Rietveld issue\'s patchset number') 34 '-p', '--patchset', type='int', help='Rietveld issue\'s patchset number')
31 parser.add_option( 35 parser.add_option(
32 '-r', 36 '-r',
33 '--root_dir', 37 '--root_dir',
34 default=os.getcwd(), 38 default=os.getcwd(),
35 help='Root directory to apply the patch') 39 help='Root directory to apply the patch')
36 parser.add_option( 40 parser.add_option(
37 '-s', 41 '-s',
38 '--server', 42 '--server',
39 default='http://codereview.chromium.org', 43 default='http://codereview.chromium.org',
40 help='Rietveld server') 44 help='Rietveld server')
41 options, args = parser.parse_args() 45 options, args = parser.parse_args()
42 logging.basicConfig( 46 logging.basicConfig(
43 format='%(levelname)5s %(module)11s(%(lineno)4d): %(message)s', 47 format='%(levelname)5s %(module)11s(%(lineno)4d): %(message)s',
44 level=[logging.WARNING, logging.INFO, logging.DEBUG][ 48 level=[logging.WARNING, logging.INFO, logging.DEBUG][
45 min(2, options.verbose)]) 49 min(2, options.verbose)])
46 if args: 50 if args:
47 parser.error('Extra argument(s) "%s" not understood' % ' '.join(args)) 51 parser.error('Extra argument(s) "%s" not understood' % ' '.join(args))
48 if not options.issue: 52 if not options.issue:
49 parser.error('Require --issue') 53 parser.error('Require --issue')
50 54
51 obj = rietveld.Rietveld(options.server, None, None) 55 obj = rietveld.Rietveld(options.server, options.email, None)
52 56
53 if not options.patchset: 57 if not options.patchset:
54 options.patchset = obj.get_issue_properties( 58 options.patchset = obj.get_issue_properties(
55 options.issue, False)['patchsets'][-1] 59 options.issue, False)['patchsets'][-1]
56 logging.info('Using patchset %d' % options.patchset) 60 logging.info('Using patchset %d' % options.patchset)
57 # Download the patch. 61 # Download the patch.
58 patchset = obj.get_patch(options.issue, options.patchset) 62 patchset = obj.get_patch(options.issue, options.patchset)
59 for patch in patchset.patches: 63 for patch in patchset.patches:
60 logging.info(patch) 64 logging.info(patch)
61 scm_type = scm.determine_scm(options.root_dir) 65 scm_type = scm.determine_scm(options.root_dir)
(...skipping 11 matching lines...) Expand all
73 scm_obj.apply_patch(patchset) 77 scm_obj.apply_patch(patchset)
74 except checkout.PatchApplicationFailed, e: 78 except checkout.PatchApplicationFailed, e:
75 print >> sys.stderr, str(e) 79 print >> sys.stderr, str(e)
76 return 1 80 return 1
77 return 0 81 return 0
78 82
79 83
80 if __name__ == "__main__": 84 if __name__ == "__main__":
81 fix_encoding.fix_encoding() 85 fix_encoding.fix_encoding()
82 sys.exit(main()) 86 sys.exit(main())
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