OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
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 | |
4 # found in the LICENSE file. | |
5 | |
6 """Applies an issue from Rietveld. | |
7 """ | |
8 | |
9 import logging | |
10 import optparse | |
11 import sys | |
12 | |
13 import breakpad # pylint: disable=W0611 | |
14 import fix_encoding | |
15 import rietveld | |
16 | |
17 | |
18 def main(): | |
19 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) | |
20 parser.add_option( | |
21 '-v', '--verbose', action='count', help='Prints debugging infos') | |
22 parser.add_option( | |
23 '-i', '--issue', type='int', help='Rietveld issue number') | |
Dirk Pranke
2011/04/12 20:52:12
Maybe this should be a positional parameter instea
M-A Ruel
2011/04/12 20:58:23
Right. I've just set it this way since it's strict
| |
24 parser.add_option( | |
25 '-p', '--patchset', type='int', help='Rietveld issue\'s patchset number') | |
26 parser.add_option( | |
27 '-r', | |
28 '--root_dir', | |
29 action='store', | |
30 help='Root directory to apply the patch') | |
31 parser.add_option( | |
32 '-s', | |
33 '--server', | |
34 action='store', | |
35 default='http://codereview.chromium.org', | |
36 help='Rietveld server') | |
37 options, args = parser.parse_args() | |
38 LOG_FORMAT = '%(levelname)s %(filename)s(%(lineno)d): %(message)s' | |
39 if not options.verbose: | |
40 logging.basicConfig(level=logging.WARNING, format=LOG_FORMAT) | |
41 elif options.verbose == 1: | |
42 logging.basicConfig(level=logging.INFO, format=LOG_FORMAT) | |
43 elif options.verbose > 1: | |
44 logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT) | |
45 if args: | |
46 parser.error('Extra argument(s) "%s" not understood' % ' '.join(args)) | |
47 if not options.issue: | |
48 parser.error('Require --issue') | |
49 | |
50 obj = rietveld.Rietveld(options.server, None, None) | |
51 | |
52 if not options.patchset: | |
53 options.patchset = obj.get_issue_properties( | |
54 options.issue, False)['patchsets'][-1] | |
55 logging.info('Using patchset %d' % options.patchset) | |
56 obj.get_patch(options.issue, options.patchset) | |
57 return 0 | |
58 | |
59 | |
60 if __name__ == "__main__": | |
61 fix_encoding.fix_encoding() | |
62 sys.exit(main()) | |
OLD | NEW |