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 # TODO(hinoka): Use logging. | 6 # TODO(hinoka): Use logging. |
| 7 | 7 |
| 8 import cStringIO | 8 import cStringIO |
| 9 import codecs | 9 import codecs |
| 10 import copy | 10 import copy |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 print 'done' | 315 print 'done' |
| 316 | 316 |
| 317 | 317 |
| 318 def gclient_configure(solutions, target_os, target_os_only, git_cache_dir): | 318 def gclient_configure(solutions, target_os, target_os_only, git_cache_dir): |
| 319 """Should do the same thing as gclient --spec='...'.""" | 319 """Should do the same thing as gclient --spec='...'.""" |
| 320 with codecs.open('.gclient', mode='w', encoding='utf-8') as f: | 320 with codecs.open('.gclient', mode='w', encoding='utf-8') as f: |
| 321 f.write(get_gclient_spec( | 321 f.write(get_gclient_spec( |
| 322 solutions, target_os, target_os_only, git_cache_dir)) | 322 solutions, target_os, target_os_only, git_cache_dir)) |
| 323 | 323 |
| 324 | 324 |
| 325 def gclient_sync(with_branch_heads, shallow): | 325 def gclient_sync(with_branch_heads, shallow, break_repo_locks): |
| 326 # We just need to allocate a filename. | 326 # We just need to allocate a filename. |
| 327 fd, gclient_output_file = tempfile.mkstemp(suffix='.json') | 327 fd, gclient_output_file = tempfile.mkstemp(suffix='.json') |
| 328 os.close(fd) | 328 os.close(fd) |
| 329 gclient_bin = 'gclient.bat' if sys.platform.startswith('win') else 'gclient' | 329 gclient_bin = 'gclient.bat' if sys.platform.startswith('win') else 'gclient' |
| 330 cmd = [gclient_bin, 'sync', '--verbose', '--reset', '--force', | 330 cmd = [gclient_bin, 'sync', '--verbose', '--reset', '--force', |
| 331 '--ignore_locks', '--output-json', gclient_output_file, | 331 '--ignore_locks', '--output-json', gclient_output_file, |
| 332 '--nohooks', '--noprehooks', '--delete_unversioned_trees'] | 332 '--nohooks', '--noprehooks', '--delete_unversioned_trees'] |
| 333 if with_branch_heads: | 333 if with_branch_heads: |
| 334 cmd += ['--with_branch_heads'] | 334 cmd += ['--with_branch_heads'] |
| 335 if shallow: | 335 if shallow: |
| 336 cmd += ['--shallow'] | 336 cmd += ['--shallow'] |
| 337 if break_repo_locks: | |
| 338 cmd += ['--break_repo_locks'] | |
| 337 | 339 |
| 338 try: | 340 try: |
| 339 call(*cmd, tries=1) | 341 call(*cmd, tries=1) |
| 340 except SubprocessFailed as e: | 342 except SubprocessFailed as e: |
| 341 # Throw a GclientSyncFailed exception so we can catch this independently. | 343 # Throw a GclientSyncFailed exception so we can catch this independently. |
| 342 raise GclientSyncFailed(e.message, e.code, e.output) | 344 raise GclientSyncFailed(e.message, e.code, e.output) |
| 343 else: | 345 else: |
| 344 with open(gclient_output_file) as f: | 346 with open(gclient_output_file) as f: |
| 345 return json.load(f) | 347 return json.load(f) |
| 346 finally: | 348 finally: |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 718 patch_root, issue, patchset, rietveld_server, gerrit_repo, | 720 patch_root, issue, patchset, rietveld_server, gerrit_repo, |
| 719 gerrit_ref, gerrit_rebase_patch_ref, revision_mapping, | 721 gerrit_ref, gerrit_rebase_patch_ref, revision_mapping, |
| 720 apply_issue_email_file, apply_issue_key_file, | 722 apply_issue_email_file, apply_issue_key_file, |
| 721 apply_issue_oauth2_file, shallow, refs, git_cache_dir, | 723 apply_issue_oauth2_file, shallow, refs, git_cache_dir, |
| 722 gerrit_reset): | 724 gerrit_reset): |
| 723 # Get a checkout of each solution, without DEPS or hooks. | 725 # Get a checkout of each solution, without DEPS or hooks. |
| 724 # Calling git directly because there is no way to run Gclient without | 726 # Calling git directly because there is no way to run Gclient without |
| 725 # invoking DEPS. | 727 # invoking DEPS. |
| 726 print 'Fetching Git checkout' | 728 print 'Fetching Git checkout' |
| 727 | 729 |
| 728 git_ref = git_checkout(solutions, revisions, shallow, refs, git_cache_dir) | 730 git_ref = git_checkout(solutions, revisions, shallow, refs, git_cache_dir) |
|
ddoman1
2016/10/25 19:08:55
@katthomas,
The following log shows that git chec
| |
| 729 | 731 |
| 730 print '===Processing patch solutions===' | 732 print '===Processing patch solutions===' |
| 731 already_patched = [] | 733 already_patched = [] |
| 732 patch_root = patch_root or '' | 734 patch_root = patch_root or '' |
| 733 applied_gerrit_patch = False | 735 applied_gerrit_patch = False |
| 734 print 'Patch root is %r' % patch_root | 736 print 'Patch root is %r' % patch_root |
| 735 for solution in solutions: | 737 for solution in solutions: |
| 736 print 'Processing solution %r' % solution['name'] | 738 print 'Processing solution %r' % solution['name'] |
| 737 if (patch_root == solution['name'] or | 739 if (patch_root == solution['name'] or |
| 738 solution['name'].startswith(patch_root + '/')): | 740 solution['name'].startswith(patch_root + '/')): |
| 739 relative_root = solution['name'][len(patch_root) + 1:] | 741 relative_root = solution['name'][len(patch_root) + 1:] |
| 740 target = '/'.join([relative_root, 'DEPS']).lstrip('/') | 742 target = '/'.join([relative_root, 'DEPS']).lstrip('/') |
| 741 print ' relative root is %r, target is %r' % (relative_root, target) | 743 print ' relative root is %r, target is %r' % (relative_root, target) |
| 742 if issue: | 744 if issue: |
| 743 apply_rietveld_issue(issue, patchset, patch_root, rietveld_server, | 745 apply_rietveld_issue(issue, patchset, patch_root, rietveld_server, |
| 744 revision_mapping, git_ref, apply_issue_email_file, | 746 revision_mapping, git_ref, apply_issue_email_file, |
| 745 apply_issue_key_file, apply_issue_oauth2_file, | 747 apply_issue_key_file, apply_issue_oauth2_file, |
| 746 whitelist=[target]) | 748 whitelist=[target]) |
| 747 already_patched.append(target) | 749 already_patched.append(target) |
| 748 elif gerrit_ref: | 750 elif gerrit_ref: |
| 749 apply_gerrit_ref(gerrit_repo, gerrit_ref, patch_root, gerrit_reset, | 751 apply_gerrit_ref(gerrit_repo, gerrit_ref, patch_root, gerrit_reset, |
| 750 gerrit_rebase_patch_ref) | 752 gerrit_rebase_patch_ref) |
| 751 applied_gerrit_patch = True | 753 applied_gerrit_patch = True |
| 752 | 754 |
| 753 # Ensure our build/ directory is set up with the correct .gclient file. | 755 # Ensure our build/ directory is set up with the correct .gclient file. |
| 754 gclient_configure(solutions, target_os, target_os_only, git_cache_dir) | 756 gclient_configure(solutions, target_os, target_os_only, git_cache_dir) |
| 755 | 757 |
| 758 # Windows sometimes has trouble deleting files. This can make git commands | |
| 759 # that rely on locks fail. | |
| 760 break_repo_locks = True if sys.platform.startswith('win') else False | |
| 756 # Let gclient do the DEPS syncing. | 761 # Let gclient do the DEPS syncing. |
| 757 # The branch-head refspec is a special case because its possible Chrome | 762 # The branch-head refspec is a special case because its possible Chrome |
| 758 # src, which contains the branch-head refspecs, is DEPSed in. | 763 # src, which contains the branch-head refspecs, is DEPSed in. |
| 759 gclient_output = gclient_sync(BRANCH_HEADS_REFSPEC in refs, shallow) | 764 gclient_output = gclient_sync(BRANCH_HEADS_REFSPEC in refs, shallow, |
| 765 break_repo_locks) | |
| 760 | 766 |
| 761 # Now that gclient_sync has finished, we should revert any .DEPS.git so that | 767 # Now that gclient_sync has finished, we should revert any .DEPS.git so that |
| 762 # presubmit doesn't complain about it being modified. | 768 # presubmit doesn't complain about it being modified. |
| 763 if git('ls-files', '.DEPS.git', cwd=first_sln).strip(): | 769 if git('ls-files', '.DEPS.git', cwd=first_sln).strip(): |
| 764 git('checkout', 'HEAD', '--', '.DEPS.git', cwd=first_sln) | 770 git('checkout', 'HEAD', '--', '.DEPS.git', cwd=first_sln) |
| 765 | 771 |
| 766 # Finally, ensure that all DEPS are pinned to the correct revision. | 772 # Finally, ensure that all DEPS are pinned to the correct revision. |
| 767 dir_names = [sln['name'] for sln in solutions] | 773 dir_names = [sln['name'] for sln in solutions] |
| 768 ensure_deps_revisions(gclient_output.get('solutions', {}), | 774 ensure_deps_revisions(gclient_output.get('solutions', {}), |
| 769 dir_names, revisions) | 775 dir_names, revisions) |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1090 # download patch failure is still an infra problem. | 1096 # download patch failure is still an infra problem. |
| 1091 if e.code == 3: | 1097 if e.code == 3: |
| 1092 # Patch download problem. | 1098 # Patch download problem. |
| 1093 return 87 | 1099 return 87 |
| 1094 # Genuine patch problem. | 1100 # Genuine patch problem. |
| 1095 return 88 | 1101 return 88 |
| 1096 | 1102 |
| 1097 | 1103 |
| 1098 if __name__ == '__main__': | 1104 if __name__ == '__main__': |
| 1099 sys.exit(main()) | 1105 sys.exit(main()) |
| OLD | NEW |