| 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 getpass | 9 import getpass |
| 10 import logging | 10 import logging |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 parser.add_option( | 58 parser.add_option( |
| 59 '-r', | 59 '-r', |
| 60 '--root_dir', | 60 '--root_dir', |
| 61 default=os.getcwd(), | 61 default=os.getcwd(), |
| 62 help='Root directory to apply the patch') | 62 help='Root directory to apply the patch') |
| 63 parser.add_option( | 63 parser.add_option( |
| 64 '-s', | 64 '-s', |
| 65 '--server', | 65 '--server', |
| 66 default='http://codereview.chromium.org', | 66 default='http://codereview.chromium.org', |
| 67 help='Rietveld server') | 67 help='Rietveld server') |
| 68 parser.add_option('--no-commit', action='store_true', | |
| 69 help='Do not try to commit patch to SCM (git only)') | |
| 70 options, args = parser.parse_args() | 68 options, args = parser.parse_args() |
| 71 logging.basicConfig( | 69 logging.basicConfig( |
| 72 format='%(levelname)5s %(module)11s(%(lineno)4d): %(message)s', | 70 format='%(levelname)5s %(module)11s(%(lineno)4d): %(message)s', |
| 73 level=[logging.WARNING, logging.INFO, logging.DEBUG][ | 71 level=[logging.WARNING, logging.INFO, logging.DEBUG][ |
| 74 min(2, options.verbose)]) | 72 min(2, options.verbose)]) |
| 75 if args: | 73 if args: |
| 76 parser.error('Extra argument(s) "%s" not understood' % ' '.join(args)) | 74 parser.error('Extra argument(s) "%s" not understood' % ' '.join(args)) |
| 77 if not options.issue: | 75 if not options.issue: |
| 78 parser.error('Require --issue') | 76 parser.error('Require --issue') |
| 79 options.server = options.server.rstrip('/') | 77 options.server = options.server.rstrip('/') |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 print( | 130 print( |
| 133 'Failed to fetch the patch for issue %d, patchset %d.\n' | 131 'Failed to fetch the patch for issue %d, patchset %d.\n' |
| 134 'Try visiting %s/%d') % ( | 132 'Try visiting %s/%d') % ( |
| 135 options.issue, options.patchset, | 133 options.issue, options.patchset, |
| 136 options.server, options.issue) | 134 options.server, options.issue) |
| 137 return 1 | 135 return 1 |
| 138 for patch in patchset.patches: | 136 for patch in patchset.patches: |
| 139 print(patch) | 137 print(patch) |
| 140 full_dir = os.path.abspath(options.root_dir) | 138 full_dir = os.path.abspath(options.root_dir) |
| 141 scm_type = scm.determine_scm(full_dir) | 139 scm_type = scm.determine_scm(full_dir) |
| 142 | |
| 143 # FIXME: re-enable --no-commit. | |
| 144 if scm_type == 'svn': | 140 if scm_type == 'svn': |
| 145 scm_obj = checkout.SvnCheckout(full_dir, None, None, None, None) | 141 scm_obj = checkout.SvnCheckout(full_dir, None, None, None, None) |
| 146 elif scm_type == 'git': | 142 elif scm_type == 'git': |
| 147 scm_obj = checkout.GitCheckoutBase(full_dir, None, None) | 143 scm_obj = checkout.GitCheckoutBase(full_dir, None, None) |
| 148 elif scm_type is None: | 144 elif scm_type == None: |
| 149 scm_obj = checkout.RawCheckout(full_dir, None, None) | 145 scm_obj = checkout.RawCheckout(full_dir, None, None) |
| 150 else: | 146 else: |
| 151 parser.error('Couldn\'t determine the scm') | 147 parser.error('Couldn\'t determine the scm') |
| 152 | 148 |
| 153 # TODO(maruel): HACK, remove me. | 149 # TODO(maruel): HACK, remove me. |
| 154 # When run a build slave, make sure buildbot knows that the checkout was | 150 # When run a build slave, make sure buildbot knows that the checkout was |
| 155 # modified. | 151 # modified. |
| 156 if options.root_dir == 'src' and getpass.getuser() == 'chrome-bot': | 152 if options.root_dir == 'src' and getpass.getuser() == 'chrome-bot': |
| 157 # See sourcedirIsPatched() in: | 153 # See sourcedirIsPatched() in: |
| 158 # http://src.chromium.org/viewvc/chrome/trunk/tools/build/scripts/slave/ | 154 # http://src.chromium.org/viewvc/chrome/trunk/tools/build/scripts/slave/ |
| (...skipping 26 matching lines...) Expand all Loading... |
| 185 '--nohooks', | 181 '--nohooks', |
| 186 '--delete_unversioned_trees', | 182 '--delete_unversioned_trees', |
| 187 ], | 183 ], |
| 188 cwd=gclient_root) | 184 cwd=gclient_root) |
| 189 return 0 | 185 return 0 |
| 190 | 186 |
| 191 | 187 |
| 192 if __name__ == "__main__": | 188 if __name__ == "__main__": |
| 193 fix_encoding.fix_encoding() | 189 fix_encoding.fix_encoding() |
| 194 sys.exit(main()) | 190 sys.exit(main()) |
| OLD | NEW |