Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: recipe_modules/bot_update/resources/bot_update.py

Issue 2299693003: bot_update: don't forget to apply Gerrit patches for DEPS-ed in projects. (Closed)
Patch Set: Better comment. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 collections 10 import collections
(...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 # Only try once, since subsequent failures hide the real failure. 1073 # Only try once, since subsequent failures hide the real failure.
1074 try: 1074 try:
1075 call(*cmd, tries=1) 1075 call(*cmd, tries=1)
1076 except SubprocessFailed as e: 1076 except SubprocessFailed as e:
1077 raise PatchFailed(e.message, e.code, e.output) 1077 raise PatchFailed(e.message, e.code, e.output)
1078 1078
1079 def apply_gerrit_ref(gerrit_repo, gerrit_ref, root, gerrit_reset, 1079 def apply_gerrit_ref(gerrit_repo, gerrit_ref, root, gerrit_reset,
1080 gerrit_rebase_patch_ref): 1080 gerrit_rebase_patch_ref):
1081 gerrit_repo = gerrit_repo or 'origin' 1081 gerrit_repo = gerrit_repo or 'origin'
1082 assert gerrit_ref 1082 assert gerrit_ref
1083 base_rev = git('rev-parse', 'HEAD', cwd=root).strip()
1084
1083 print '===Applying gerrit ref===' 1085 print '===Applying gerrit ref==='
1084 print 'Repo is %r, ref is %r, root is %r' % (gerrit_repo, gerrit_ref, root) 1086 print 'Repo is %r @ %r, ref is %r, root is %r' % (
1087 gerrit_repo, base_rev, gerrit_ref, root)
1085 try: 1088 try:
1086 base_rev = git('rev-parse', 'HEAD', cwd=root).strip()
1087 git('retry', 'fetch', gerrit_repo, gerrit_ref, cwd=root, tries=1) 1089 git('retry', 'fetch', gerrit_repo, gerrit_ref, cwd=root, tries=1)
1088 git('checkout', 'FETCH_HEAD', cwd=root) 1090 git('checkout', 'FETCH_HEAD', cwd=root)
1089 1091
1090 if gerrit_rebase_patch_ref: 1092 if gerrit_rebase_patch_ref:
1091 print '===Rebasing===' 1093 print '===Rebasing==='
1092 # git rebase requires a branch to operate on. 1094 # git rebase requires a branch to operate on.
1093 temp_branch_name = 'tmp/' + uuid.uuid4().hex 1095 temp_branch_name = 'tmp/' + uuid.uuid4().hex
1094 try: 1096 try:
1095 ok = False 1097 ok = False
1096 git('checkout', '-b', temp_branch_name, cwd=root) 1098 git('checkout', '-b', temp_branch_name, cwd=root)
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 1277
1276 git_ref = git_checkout(solutions, revisions, shallow, refs, git_cache_dir) 1278 git_ref = git_checkout(solutions, revisions, shallow, refs, git_cache_dir)
1277 1279
1278 patches = None 1280 patches = None
1279 if patch_url: 1281 if patch_url:
1280 patches = get_svn_patch(patch_url) 1282 patches = get_svn_patch(patch_url)
1281 1283
1282 print '===Processing patch solutions===' 1284 print '===Processing patch solutions==='
1283 already_patched = [] 1285 already_patched = []
1284 patch_root = patch_root or '' 1286 patch_root = patch_root or ''
1287 applied_gerrit_patch = False
1285 print 'Patch root is %r' % patch_root 1288 print 'Patch root is %r' % patch_root
1286 for solution in solutions: 1289 for solution in solutions:
1287 print 'Processing solution %r' % solution['name'] 1290 print 'Processing solution %r' % solution['name']
1288 if (patch_root == solution['name'] or 1291 if (patch_root == solution['name'] or
1289 solution['name'].startswith(patch_root + '/')): 1292 solution['name'].startswith(patch_root + '/')):
1290 relative_root = solution['name'][len(patch_root) + 1:] 1293 relative_root = solution['name'][len(patch_root) + 1:]
1291 target = '/'.join([relative_root, 'DEPS']).lstrip('/') 1294 target = '/'.join([relative_root, 'DEPS']).lstrip('/')
1292 print ' relative root is %r, target is %r' % (relative_root, target) 1295 print ' relative root is %r, target is %r' % (relative_root, target)
1293 if patches: 1296 if patches:
1294 apply_svn_patch(patch_root, patches, whitelist=[target]) 1297 apply_svn_patch(patch_root, patches, whitelist=[target])
1295 already_patched.append(target) 1298 already_patched.append(target)
1296 elif issue: 1299 elif issue:
1297 apply_rietveld_issue(issue, patchset, patch_root, rietveld_server, 1300 apply_rietveld_issue(issue, patchset, patch_root, rietveld_server,
1298 revision_mapping, git_ref, apply_issue_email_file, 1301 revision_mapping, git_ref, apply_issue_email_file,
1299 apply_issue_key_file, whitelist=[target]) 1302 apply_issue_key_file, whitelist=[target])
1300 already_patched.append(target) 1303 already_patched.append(target)
1301 elif gerrit_ref and gerrit_rebase_patch_ref: 1304 elif gerrit_ref:
1302 apply_gerrit_ref(gerrit_repo, gerrit_ref, patch_root, gerrit_reset, 1305 apply_gerrit_ref(gerrit_repo, gerrit_ref, patch_root, gerrit_reset,
1303 True) 1306 gerrit_rebase_patch_ref)
1307 applied_gerrit_patch = True
1304 1308
1305 # Ensure our build/ directory is set up with the correct .gclient file. 1309 # Ensure our build/ directory is set up with the correct .gclient file.
1306 gclient_configure(solutions, target_os, target_os_only, git_cache_dir) 1310 gclient_configure(solutions, target_os, target_os_only, git_cache_dir)
1307 1311
1308 # Let gclient do the DEPS syncing. 1312 # Let gclient do the DEPS syncing.
1309 # The branch-head refspec is a special case because its possible Chrome 1313 # The branch-head refspec is a special case because its possible Chrome
1310 # src, which contains the branch-head refspecs, is DEPSed in. 1314 # src, which contains the branch-head refspecs, is DEPSed in.
1311 gclient_output = gclient_sync(buildspec or BRANCH_HEADS_REFSPEC in refs, 1315 gclient_output = gclient_sync(buildspec or BRANCH_HEADS_REFSPEC in refs,
1312 shallow) 1316 shallow)
1313 1317
(...skipping 13 matching lines...) Expand all
1327 dir_names = [sln['name'] for sln in solutions] 1331 dir_names = [sln['name'] for sln in solutions]
1328 ensure_deps_revisions(gclient_output.get('solutions', {}), 1332 ensure_deps_revisions(gclient_output.get('solutions', {}),
1329 dir_names, revisions) 1333 dir_names, revisions)
1330 # Apply the rest of the patch here (sans DEPS) 1334 # Apply the rest of the patch here (sans DEPS)
1331 if patches: 1335 if patches:
1332 apply_svn_patch(patch_root, patches, blacklist=already_patched) 1336 apply_svn_patch(patch_root, patches, blacklist=already_patched)
1333 elif issue: 1337 elif issue:
1334 apply_rietveld_issue(issue, patchset, patch_root, rietveld_server, 1338 apply_rietveld_issue(issue, patchset, patch_root, rietveld_server,
1335 revision_mapping, git_ref, apply_issue_email_file, 1339 revision_mapping, git_ref, apply_issue_email_file,
1336 apply_issue_key_file, blacklist=already_patched) 1340 apply_issue_key_file, blacklist=already_patched)
1337 elif gerrit_ref and not gerrit_rebase_patch_ref: 1341 elif gerrit_ref and not applied_gerrit_patch:
1338 apply_gerrit_ref(gerrit_repo, gerrit_ref, patch_root, gerrit_reset, False) 1342 # If gerrit_ref was for solution's main repository, it has already been
1343 # applied above. This chunk is executed only for patches to DEPS-ed in
1344 # git repositories.
1345 apply_gerrit_ref(gerrit_repo, gerrit_ref, patch_root, gerrit_reset,
1346 gerrit_rebase_patch_ref)
1339 1347
1340 # Reset the deps_file point in the solutions so that hooks get run properly. 1348 # Reset the deps_file point in the solutions so that hooks get run properly.
1341 for sln in solutions: 1349 for sln in solutions:
1342 sln['deps_file'] = sln.get('deps_file', 'DEPS').replace('.DEPS.git', 'DEPS') 1350 sln['deps_file'] = sln.get('deps_file', 'DEPS').replace('.DEPS.git', 'DEPS')
1343 gclient_configure(solutions, target_os, target_os_only, git_cache_dir) 1351 gclient_configure(solutions, target_os, target_os_only, git_cache_dir)
1344 1352
1345 return gclient_output 1353 return gclient_output
1346 1354
1347 1355
1348 def parse_revisions(revisions, root): 1356 def parse_revisions(revisions, root):
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1735 except Exception: 1743 except Exception:
1736 # Unexpected failure. 1744 # Unexpected failure.
1737 emit_flag(options.flag_file) 1745 emit_flag(options.flag_file)
1738 raise 1746 raise
1739 else: 1747 else:
1740 emit_flag(options.flag_file) 1748 emit_flag(options.flag_file)
1741 1749
1742 1750
1743 if __name__ == '__main__': 1751 if __name__ == '__main__':
1744 sys.exit(main()) 1752 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698