 Chromium Code Reviews
 Chromium Code Reviews 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/
    
  
    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/| OLD | NEW | 
|---|---|
| 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 default=None, | |
| 
M-A Ruel
2012/07/06 17:15:20
remove default=None
 
Roger Tawa OOO till Jul 10th
2012/07/06 17:21:14
Done.
 | |
| 31 help='Email address for authenticating with Rietveld') | |
| 32 parser.add_option( | |
| 28 '-i', '--issue', type='int', help='Rietveld issue number') | 33 '-i', '--issue', type='int', help='Rietveld issue number') | 
| 29 parser.add_option( | 34 parser.add_option( | 
| 30 '-p', '--patchset', type='int', help='Rietveld issue\'s patchset number') | 35 '-p', '--patchset', type='int', help='Rietveld issue\'s patchset number') | 
| 31 parser.add_option( | 36 parser.add_option( | 
| 32 '-r', | 37 '-r', | 
| 33 '--root_dir', | 38 '--root_dir', | 
| 34 default=os.getcwd(), | 39 default=os.getcwd(), | 
| 35 help='Root directory to apply the patch') | 40 help='Root directory to apply the patch') | 
| 36 parser.add_option( | 41 parser.add_option( | 
| 37 '-s', | 42 '-s', | 
| 38 '--server', | 43 '--server', | 
| 39 default='http://codereview.chromium.org', | 44 default='http://codereview.chromium.org', | 
| 40 help='Rietveld server') | 45 help='Rietveld server') | 
| 41 options, args = parser.parse_args() | 46 options, args = parser.parse_args() | 
| 42 logging.basicConfig( | 47 logging.basicConfig( | 
| 43 format='%(levelname)5s %(module)11s(%(lineno)4d): %(message)s', | 48 format='%(levelname)5s %(module)11s(%(lineno)4d): %(message)s', | 
| 44 level=[logging.WARNING, logging.INFO, logging.DEBUG][ | 49 level=[logging.WARNING, logging.INFO, logging.DEBUG][ | 
| 45 min(2, options.verbose)]) | 50 min(2, options.verbose)]) | 
| 46 if args: | 51 if args: | 
| 47 parser.error('Extra argument(s) "%s" not understood' % ' '.join(args)) | 52 parser.error('Extra argument(s) "%s" not understood' % ' '.join(args)) | 
| 48 if not options.issue: | 53 if not options.issue: | 
| 49 parser.error('Require --issue') | 54 parser.error('Require --issue') | 
| 50 | 55 | 
| 51 obj = rietveld.Rietveld(options.server, None, None) | 56 obj = rietveld.Rietveld(options.server, options.email, None) | 
| 52 | 57 | 
| 53 if not options.patchset: | 58 if not options.patchset: | 
| 54 options.patchset = obj.get_issue_properties( | 59 options.patchset = obj.get_issue_properties( | 
| 55 options.issue, False)['patchsets'][-1] | 60 options.issue, False)['patchsets'][-1] | 
| 56 logging.info('Using patchset %d' % options.patchset) | 61 logging.info('Using patchset %d' % options.patchset) | 
| 57 # Download the patch. | 62 # Download the patch. | 
| 58 patchset = obj.get_patch(options.issue, options.patchset) | 63 patchset = obj.get_patch(options.issue, options.patchset) | 
| 59 for patch in patchset.patches: | 64 for patch in patchset.patches: | 
| 60 logging.info(patch) | 65 logging.info(patch) | 
| 61 scm_type = scm.determine_scm(options.root_dir) | 66 scm_type = scm.determine_scm(options.root_dir) | 
| (...skipping 11 matching lines...) Expand all Loading... | |
| 73 scm_obj.apply_patch(patchset) | 78 scm_obj.apply_patch(patchset) | 
| 74 except checkout.PatchApplicationFailed, e: | 79 except checkout.PatchApplicationFailed, e: | 
| 75 print >> sys.stderr, str(e) | 80 print >> sys.stderr, str(e) | 
| 76 return 1 | 81 return 1 | 
| 77 return 0 | 82 return 0 | 
| 78 | 83 | 
| 79 | 84 | 
| 80 if __name__ == "__main__": | 85 if __name__ == "__main__": | 
| 81 fix_encoding.fix_encoding() | 86 fix_encoding.fix_encoding() | 
| 82 sys.exit(main()) | 87 sys.exit(main()) | 
| OLD | NEW |