| OLD | NEW |
| 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 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 '--root_dir', | 33 '--root_dir', |
| 34 default=os.getcwd(), | 34 default=os.getcwd(), |
| 35 help='Root directory to apply the patch') | 35 help='Root directory to apply the patch') |
| 36 parser.add_option( | 36 parser.add_option( |
| 37 '-s', | 37 '-s', |
| 38 '--server', | 38 '--server', |
| 39 default='http://codereview.chromium.org', | 39 default='http://codereview.chromium.org', |
| 40 help='Rietveld server') | 40 help='Rietveld server') |
| 41 options, args = parser.parse_args() | 41 options, args = parser.parse_args() |
| 42 logging.basicConfig( | 42 logging.basicConfig( |
| 43 format='%(levelname)s %(filename)s(%(lineno)d): %(message)s', | 43 format='%(levelname)5s %(module)11s(%(lineno)4d): %(message)s', |
| 44 level=[logging.WARNING, logging.INFO, logging.DEBUG][ | 44 level=[logging.WARNING, logging.INFO, logging.DEBUG][ |
| 45 min(2, options.verbose)]) | 45 min(2, options.verbose)]) |
| 46 if args: | 46 if args: |
| 47 parser.error('Extra argument(s) "%s" not understood' % ' '.join(args)) | 47 parser.error('Extra argument(s) "%s" not understood' % ' '.join(args)) |
| 48 if not options.issue: | 48 if not options.issue: |
| 49 parser.error('Require --issue') | 49 parser.error('Require --issue') |
| 50 | 50 |
| 51 obj = rietveld.Rietveld(options.server, None, None) | 51 obj = rietveld.Rietveld(options.server, None, None) |
| 52 | 52 |
| 53 if not options.patchset: | 53 if not options.patchset: |
| 54 options.patchset = obj.get_issue_properties( | 54 options.patchset = obj.get_issue_properties( |
| 55 options.issue, False)['patchsets'][-1] | 55 options.issue, False)['patchsets'][-1] |
| 56 logging.info('Using patchset %d' % options.patchset) | 56 logging.info('Using patchset %d' % options.patchset) |
| 57 # Download the patch. | 57 # Download the patch. |
| 58 patchset = obj.get_patch(options.issue, options.patchset) | 58 patchset = obj.get_patch(options.issue, options.patchset) |
| 59 | 59 for patch in patchset.patches: |
| 60 logging.info(patch) |
| 60 scm_type = scm.determine_scm(options.root_dir) | 61 scm_type = scm.determine_scm(options.root_dir) |
| 61 if scm_type == 'svn': | 62 if scm_type == 'svn': |
| 62 scm_obj = checkout.SvnCheckout(options.root_dir, None, None, None, None) | 63 scm_obj = checkout.SvnCheckout(options.root_dir, None, None, None, None) |
| 63 elif scm_type == 'git': | 64 elif scm_type == 'git': |
| 64 scm_obj = checkout.GitCheckoutBase(options.root_dir, None, None) | 65 scm_obj = checkout.GitCheckoutBase(options.root_dir, None, None) |
| 65 elif scm_type == None: | 66 elif scm_type == None: |
| 66 scm_obj = checkout.RawCheckout(options.root_dir, None) | 67 scm_obj = checkout.RawCheckout(options.root_dir, None) |
| 67 else: | 68 else: |
| 68 parser.error('Couldn\'t determine the scm') | 69 parser.error('Couldn\'t determine the scm') |
| 69 | 70 |
| 70 # Apply the patch. | 71 # Apply the patch. |
| 71 scm_obj.apply_patch(patchset) | 72 scm_obj.apply_patch(patchset) |
| 72 return 0 | 73 return 0 |
| 73 | 74 |
| 74 | 75 |
| 75 if __name__ == "__main__": | 76 if __name__ == "__main__": |
| 76 fix_encoding.fix_encoding() | 77 fix_encoding.fix_encoding() |
| 77 sys.exit(main()) | 78 sys.exit(main()) |
| OLD | NEW |