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 import getpass | 8 import getpass |
9 import json | 9 import json |
10 import logging | 10 import logging |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 parser.add_option('-f', '--force', action='store_true', | 85 parser.add_option('-f', '--force', action='store_true', |
86 help='Really run apply_issue, even if .update.flag ' | 86 help='Really run apply_issue, even if .update.flag ' |
87 'is detected.') | 87 'is detected.') |
88 parser.add_option('-b', '--base_ref', help='DEPRECATED do not use.') | 88 parser.add_option('-b', '--base_ref', help='DEPRECATED do not use.') |
89 parser.add_option('--whitelist', action='append', default=[], | 89 parser.add_option('--whitelist', action='append', default=[], |
90 help='Patch only specified file(s).') | 90 help='Patch only specified file(s).') |
91 parser.add_option('--blacklist', action='append', default=[], | 91 parser.add_option('--blacklist', action='append', default=[], |
92 help='Don\'t patch specified file(s).') | 92 help='Don\'t patch specified file(s).') |
93 parser.add_option('-d', '--ignore_deps', action='store_true', | 93 parser.add_option('-d', '--ignore_deps', action='store_true', |
94 help='Don\'t run gclient sync on DEPS changes.') | 94 help='Don\'t run gclient sync on DEPS changes.') |
| 95 parser.add_option('--extra_patchlevel', type='int', |
| 96 help='Number of directories the patch level number should ' |
| 97 'be incremented (useful for patches from repos with ' |
| 98 'different directory hierarchies).') |
95 | 99 |
96 auth.add_auth_options(parser) | 100 auth.add_auth_options(parser) |
97 return parser | 101 return parser |
98 | 102 |
99 | 103 |
100 def main(): | 104 def main(): |
101 # TODO(pgervais,tandrii): split this func, it's still too long. | 105 # TODO(pgervais,tandrii): split this func, it's still too long. |
102 sys.stdout = Unbuffered(sys.stdout) | 106 sys.stdout = Unbuffered(sys.stdout) |
103 parser = _get_arg_parser() | 107 parser = _get_arg_parser() |
104 options, args = parser.parse_args() | 108 options, args = parser.parse_args() |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 issue_to_apply, patchset_to_apply) | 252 issue_to_apply, patchset_to_apply) |
249 return RETURN_CODE_INFRA_FAILURE | 253 return RETURN_CODE_INFRA_FAILURE |
250 if options.whitelist: | 254 if options.whitelist: |
251 patchset.patches = [patch for patch in patchset.patches | 255 patchset.patches = [patch for patch in patchset.patches |
252 if patch.filename in options.whitelist] | 256 if patch.filename in options.whitelist] |
253 if options.blacklist: | 257 if options.blacklist: |
254 patchset.patches = [patch for patch in patchset.patches | 258 patchset.patches = [patch for patch in patchset.patches |
255 if patch.filename not in options.blacklist] | 259 if patch.filename not in options.blacklist] |
256 for patch in patchset.patches: | 260 for patch in patchset.patches: |
257 print(patch) | 261 print(patch) |
| 262 if options.extra_patchlevel: |
| 263 patch.patchlevel += options.extra_patchlevel |
258 full_dir = os.path.abspath(options.root_dir) | 264 full_dir = os.path.abspath(options.root_dir) |
259 scm_type = scm.determine_scm(full_dir) | 265 scm_type = scm.determine_scm(full_dir) |
260 if scm_type == 'svn': | 266 if scm_type == 'svn': |
261 scm_obj = checkout.SvnCheckout(full_dir, None, None, None, None) | 267 scm_obj = checkout.SvnCheckout(full_dir, None, None, None, None) |
262 elif scm_type == 'git': | 268 elif scm_type == 'git': |
263 scm_obj = checkout.GitCheckout(full_dir, None, None, None, None) | 269 scm_obj = checkout.GitCheckout(full_dir, None, None, None, None) |
264 elif scm_type == None: | 270 elif scm_type == None: |
265 scm_obj = checkout.RawCheckout(full_dir, None, None) | 271 scm_obj = checkout.RawCheckout(full_dir, None, None) |
266 else: | 272 else: |
267 parser.error('Couldn\'t determine the scm') | 273 parser.error('Couldn\'t determine the scm') |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 return RETURN_CODE_OK | 322 return RETURN_CODE_OK |
317 | 323 |
318 | 324 |
319 if __name__ == "__main__": | 325 if __name__ == "__main__": |
320 fix_encoding.fix_encoding() | 326 fix_encoding.fix_encoding() |
321 try: | 327 try: |
322 sys.exit(main()) | 328 sys.exit(main()) |
323 except KeyboardInterrupt: | 329 except KeyboardInterrupt: |
324 sys.stderr.write('interrupted\n') | 330 sys.stderr.write('interrupted\n') |
325 sys.exit(RETURN_CODE_OTHER_FAILURE) | 331 sys.exit(RETURN_CODE_OTHER_FAILURE) |
OLD | NEW |