| 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 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 options, args = parser.parse_args() | 45 options, args = parser.parse_args() |
| 46 logging.basicConfig( | 46 logging.basicConfig( |
| 47 format='%(levelname)5s %(module)11s(%(lineno)4d): %(message)s', | 47 format='%(levelname)5s %(module)11s(%(lineno)4d): %(message)s', |
| 48 level=[logging.WARNING, logging.INFO, logging.DEBUG][ | 48 level=[logging.WARNING, logging.INFO, logging.DEBUG][ |
| 49 min(2, options.verbose)]) | 49 min(2, options.verbose)]) |
| 50 if args: | 50 if args: |
| 51 parser.error('Extra argument(s) "%s" not understood' % ' '.join(args)) | 51 parser.error('Extra argument(s) "%s" not understood' % ' '.join(args)) |
| 52 if not options.issue: | 52 if not options.issue: |
| 53 parser.error('Require --issue') | 53 parser.error('Require --issue') |
| 54 | 54 |
| 55 # TODO(rogerta): Remove me, it's ugly. |
| 56 if options.email == '=': |
| 57 options.email = '' |
| 58 |
| 55 obj = rietveld.Rietveld(options.server, options.email, None) | 59 obj = rietveld.Rietveld(options.server, options.email, None) |
| 56 | 60 |
| 57 if not options.patchset: | 61 if not options.patchset: |
| 58 options.patchset = obj.get_issue_properties( | 62 options.patchset = obj.get_issue_properties( |
| 59 options.issue, False)['patchsets'][-1] | 63 options.issue, False)['patchsets'][-1] |
| 60 logging.info('Using patchset %d' % options.patchset) | 64 logging.info('Using patchset %d' % options.patchset) |
| 61 # Download the patch. | 65 # Download the patch. |
| 62 patchset = obj.get_patch(options.issue, options.patchset) | 66 patchset = obj.get_patch(options.issue, options.patchset) |
| 63 for patch in patchset.patches: | 67 for patch in patchset.patches: |
| 64 logging.info(patch) | 68 logging.info(patch) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 77 scm_obj.apply_patch(patchset) | 81 scm_obj.apply_patch(patchset) |
| 78 except checkout.PatchApplicationFailed, e: | 82 except checkout.PatchApplicationFailed, e: |
| 79 print >> sys.stderr, str(e) | 83 print >> sys.stderr, str(e) |
| 80 return 1 | 84 return 1 |
| 81 return 0 | 85 return 0 |
| 82 | 86 |
| 83 | 87 |
| 84 if __name__ == "__main__": | 88 if __name__ == "__main__": |
| 85 fix_encoding.fix_encoding() | 89 fix_encoding.fix_encoding() |
| 86 sys.exit(main()) | 90 sys.exit(main()) |
| OLD | NEW |