Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 import codecs | 6 import codecs |
| 7 import copy | 7 import copy |
| 8 import optparse | 8 import optparse |
| 9 import os | 9 import os |
| 10 import pprint | 10 import pprint |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 else: | 333 else: |
| 334 # rev_num is actually a git hash or ref, we can just use it. | 334 # rev_num is actually a git hash or ref, we can just use it. |
| 335 git_ref = revision | 335 git_ref = revision |
| 336 git('checkout', git_ref, cwd=sln_dir) | 336 git('checkout', git_ref, cwd=sln_dir) |
| 337 else: | 337 else: |
| 338 git('checkout', 'origin/master', cwd=sln_dir) | 338 git('checkout', 'origin/master', cwd=sln_dir) |
| 339 | 339 |
| 340 first_solution = False | 340 first_solution = False |
| 341 | 341 |
| 342 | 342 |
| 343 def _download(url): | |
| 344 """Fetch url and return content, with retries for flake.""" | |
| 345 attempts_left = 3 | |
|
agable
2014/02/18 22:36:10
This should use the same RETRIES mechanism as call
Ryan Tseng
2014/02/19 22:05:40
Done.
| |
| 346 while attempts_left: | |
| 347 attempts_left -= 1 | |
| 348 try: | |
| 349 return urllib2.urlopen(url).read() | |
| 350 except Exception: | |
| 351 if not attempts_left: | |
| 352 raise | |
| 353 pass | |
| 354 | |
| 355 | |
| 343 def apply_issue(issue, patchset, root, server): | 356 def apply_issue(issue, patchset, root, server): |
| 344 pass | 357 print 'Fetching patch from %s' % patch_url |
| 358 patch_url = 'https://%s/download/issue%s_%s.diff' % (server, issue, patchset) | |
| 359 patch_data = _download(patch_url) | |
| 360 # Git patches have a/ at the beginning of source paths. We strip that out | |
| 361 # with a sed script rather than the -p flag to patch so we can feed either | |
| 362 # Git or svn-style patches into the same apply command. | |
| 363 patch_data = re.sub(r'^(---|\+\+\+) a/', r'\1 ', patch_data, re.MULTILINE) | |
|
agable
2014/02/18 22:36:10
So we are supporting svn-style patches? I guess we
Ryan Tseng
2014/02/19 22:05:40
Copypasta from here:
https://code.google.com/p/chr
| |
| 364 print 'Patch contents:' | |
| 365 print patch_data | |
| 366 git('apply', '--index', '-p0', '--3way', stdin=patch_data) | |
|
agable
2014/02/18 22:36:10
No need to specify --index when --3way is passed.
Ryan Tseng
2014/02/19 22:05:40
Also copypasta'ed, probably from a more simpler ti
| |
| 345 | 367 |
| 346 | 368 |
| 347 def check_flag(flag_file): | 369 def check_flag(flag_file): |
| 348 """Returns True if the flag file is present.""" | 370 """Returns True if the flag file is present.""" |
| 349 return os.path.isfile(flag_file) | 371 return os.path.isfile(flag_file) |
| 350 | 372 |
| 351 | 373 |
| 352 def delete_flag(flag_file): | 374 def delete_flag(flag_file): |
| 353 """Remove bot update flag.""" | 375 """Remove bot update flag.""" |
| 354 if os.path.isfile(flag_file): | 376 if os.path.isfile(flag_file): |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 428 else: | 450 else: |
| 429 delete_flag(options.flag_file) | 451 delete_flag(options.flag_file) |
| 430 return | 452 return |
| 431 | 453 |
| 432 # Get a checkout of each solution, without DEPS or hooks. | 454 # Get a checkout of each solution, without DEPS or hooks. |
| 433 # Calling git directory because there is no way to run Gclient without | 455 # Calling git directory because there is no way to run Gclient without |
| 434 # invoking DEPS. | 456 # invoking DEPS. |
| 435 print 'Fetching Git checkout' | 457 print 'Fetching Git checkout' |
| 436 git_checkout(git_solutions, options.revision) | 458 git_checkout(git_solutions, options.revision) |
| 437 | 459 |
| 438 # TODO(hinoka): This must be implemented before we can turn this on for TS. | 460 if options.issue: |
| 439 # if options.issue: | 461 apply_issue(options.issue, options.patchset, options.root, options.server) |
| 440 # apply_issue(options.issue, options.patchset, options.root, options.server) | |
| 441 | 462 |
| 442 # Magic to get deps2git to work with internal DEPS. | 463 # Magic to get deps2git to work with internal DEPS. |
| 443 shutil.copyfile(S2G_INTERNAL_FROM_PATH, S2G_INTERNAL_DEST_PATH) | 464 shutil.copyfile(S2G_INTERNAL_FROM_PATH, S2G_INTERNAL_DEST_PATH) |
| 444 deps2git(dir_names) | 465 deps2git(dir_names) |
| 445 | 466 |
| 446 gclient_configure(git_solutions) | 467 gclient_configure(git_solutions) |
| 447 gclient_sync() | 468 gclient_sync() |
| 448 | 469 |
| 449 | 470 |
| 450 if __name__ == '__main__': | 471 if __name__ == '__main__': |
| 451 sys.exit(main()) | 472 sys.exit(main()) |
| OLD | NEW |