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

Side by Side Diff: apply_issue.py

Issue 7054057: Add support for empty files, __init__.py is a common example. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 6 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 | checkout.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) 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 """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', help='Prints debugging infos') 25 '-v', '--verbose', action='count', default=0,
26 help='Prints debugging infos')
26 parser.add_option( 27 parser.add_option(
27 '-i', '--issue', type='int', help='Rietveld issue number') 28 '-i', '--issue', type='int', help='Rietveld issue number')
28 parser.add_option( 29 parser.add_option(
29 '-p', '--patchset', type='int', help='Rietveld issue\'s patchset number') 30 '-p', '--patchset', type='int', help='Rietveld issue\'s patchset number')
30 parser.add_option( 31 parser.add_option(
31 '-r', 32 '-r',
32 '--root_dir', 33 '--root_dir',
33 default=os.getcwd(), 34 default=os.getcwd(),
34 help='Root directory to apply the patch') 35 help='Root directory to apply the patch')
35 parser.add_option( 36 parser.add_option(
36 '-s', 37 '-s',
37 '--server', 38 '--server',
38 default='http://codereview.chromium.org', 39 default='http://codereview.chromium.org',
39 help='Rietveld server') 40 help='Rietveld server')
40 options, args = parser.parse_args() 41 options, args = parser.parse_args()
41 LOG_FORMAT = '%(levelname)s %(filename)s(%(lineno)d): %(message)s' 42 logging.basicConfig(
42 if not options.verbose: 43 format='%(levelname)s %(filename)s(%(lineno)d): %(message)s',
43 logging.basicConfig(level=logging.WARNING, format=LOG_FORMAT) 44 level=[logging.WARNING, logging.INFO, logging.DEBUG][
44 elif options.verbose == 1: 45 min(2, options.verbose)])
45 logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
46 elif options.verbose > 1:
47 logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT)
48 if args: 46 if args:
49 parser.error('Extra argument(s) "%s" not understood' % ' '.join(args)) 47 parser.error('Extra argument(s) "%s" not understood' % ' '.join(args))
50 if not options.issue: 48 if not options.issue:
51 parser.error('Require --issue') 49 parser.error('Require --issue')
52 50
53 obj = rietveld.Rietveld(options.server, None, None) 51 obj = rietveld.Rietveld(options.server, None, None)
54 52
55 if not options.patchset: 53 if not options.patchset:
56 options.patchset = obj.get_issue_properties( 54 options.patchset = obj.get_issue_properties(
57 options.issue, False)['patchsets'][-1] 55 options.issue, False)['patchsets'][-1]
(...skipping 12 matching lines...) Expand all
70 parser.error('Couldn\'t determine the scm') 68 parser.error('Couldn\'t determine the scm')
71 69
72 # Apply the patch. 70 # Apply the patch.
73 scm_obj.apply_patch(patchset) 71 scm_obj.apply_patch(patchset)
74 return 0 72 return 0
75 73
76 74
77 if __name__ == "__main__": 75 if __name__ == "__main__":
78 fix_encoding.fix_encoding() 76 fix_encoding.fix_encoding()
79 sys.exit(main()) 77 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | checkout.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698