Commit 612d62d0 authored by Andrii Shyshkalov's avatar Andrii Shyshkalov Committed by Commit Bot

Revert "bot_update: Don't force solutions to be unmanaged."

This reverts commit c48318a3.

Reason for revert: likely broke ChromeOS

Original change's description:
> bot_update: Don't force solutions to be unmanaged.
> 
> gclient should be the one syncing the solutions to the appropriate
> revisions.
> 
> Bug: 850812, 853032
> Change-Id: Ieefc5661627d4864deb0d4e7053168a99da29d29
> Reviewed-on: https://chromium-review.googlesource.com/1102833
> Reviewed-by: Aaron Gable <agable@chromium.org>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>

TBR=hinoka@chromium.org,agable@chromium.org,ehmaldonado@chromium.org

Change-Id: I7e110108a9687d703ea8be39cc83e0888f7813c6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 850812, 853032, 855700
Reviewed-on: https://chromium-review.googlesource.com/1111925Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
parent 565fa6a4
...@@ -572,6 +572,26 @@ def get_target_pin(solution_name, git_url, revisions): ...@@ -572,6 +572,26 @@ def get_target_pin(solution_name, git_url, revisions):
return None return None
def force_solution_revision(solution_name, git_url, revisions, cwd):
branch, revision = _get_target_branch_and_revision(
solution_name, git_url, revisions)
if revision and revision.upper() != 'HEAD':
treeish = revision
else:
# TODO(machenbach): This won't work with branch-heads, as Gerrit's
# destination branch would be e.g. refs/branch-heads/123. But here
# we need to pass refs/remotes/branch-heads/123 to check out.
# This will also not work if somebody passes a local refspec like
# refs/heads/master. It needs to translate to refs/remotes/origin/master
# first. See also https://crbug.com/740456 .
treeish = branch if branch.startswith('refs/') else 'origin/%s' % branch
# Note that -- argument is necessary to ensure that git treats `treeish`
# argument as revision or ref, and not as a file/directory which happens to
# have the exact same name.
git('checkout', '--force', treeish, '--', cwd=cwd)
def _has_in_git_cache(revision_sha1, git_cache_dir, url): def _has_in_git_cache(revision_sha1, git_cache_dir, url):
"""Returns whether given revision_sha1 is contained in cache of a given repo. """Returns whether given revision_sha1 is contained in cache of a given repo.
""" """
...@@ -721,6 +741,8 @@ def _git_checkout(sln, sln_dir, revisions, shallow, refs, git_cache_dir, ...@@ -721,6 +741,8 @@ def _git_checkout(sln, sln_dir, revisions, shallow, refs, git_cache_dir,
if sys.platform.startswith('win'): if sys.platform.startswith('win'):
_maybe_break_locks(sln_dir, tries=3) _maybe_break_locks(sln_dir, tries=3)
force_solution_revision(name, url, revisions, sln_dir)
git('clean', '-dff', cwd=sln_dir)
return return
except SubprocessFailed as e: except SubprocessFailed as e:
# Exited abnormally, theres probably something wrong. # Exited abnormally, theres probably something wrong.
...@@ -894,6 +916,16 @@ def ensure_checkout(solutions, revisions, first_sln, target_os, target_os_only, ...@@ -894,6 +916,16 @@ def ensure_checkout(solutions, revisions, first_sln, target_os, target_os_only,
# Windows sometimes has trouble deleting files. This can make git commands # Windows sometimes has trouble deleting files. This can make git commands
# that rely on locks fail. # that rely on locks fail.
break_repo_locks = True if sys.platform.startswith('win') else False break_repo_locks = True if sys.platform.startswith('win') else False
# We want to pass all non-solution revisions into the gclient sync call.
solution_dirs = {sln['name'] for sln in solutions}
gc_revisions = {
dirname: rev for dirname, rev in revisions.iteritems()
if dirname not in solution_dirs}
# Gclient sometimes ignores "unmanaged": "False" in the gclient solution
# if --revision <anything> is passed (for example, for subrepos).
# This forces gclient to always treat solutions deps as unmanaged.
for solution_name in list(solution_dirs):
gc_revisions[solution_name] = 'unmanaged'
with git_config_if_not_set('user.name', 'chrome-bot'): with git_config_if_not_set('user.name', 'chrome-bot'):
with git_config_if_not_set('user.email', 'chrome-bot@chromium.org'): with git_config_if_not_set('user.email', 'chrome-bot@chromium.org'):
...@@ -904,7 +936,7 @@ def ensure_checkout(solutions, revisions, first_sln, target_os, target_os_only, ...@@ -904,7 +936,7 @@ def ensure_checkout(solutions, revisions, first_sln, target_os, target_os_only,
BRANCH_HEADS_REFSPEC in refs, BRANCH_HEADS_REFSPEC in refs,
TAGS_REFSPEC in refs, TAGS_REFSPEC in refs,
shallow, shallow,
revisions, gc_revisions,
break_repo_locks, break_repo_locks,
disable_syntax_validation, disable_syntax_validation,
gerrit_repo, gerrit_repo,
......
...@@ -211,7 +211,7 @@ class BotUpdateUnittests(unittest.TestCase): ...@@ -211,7 +211,7 @@ class BotUpdateUnittests(unittest.TestCase):
idx_second_revision = args.index( idx_second_revision = args.index(
'--revision', idx_first_revision+1) '--revision', idx_first_revision+1)
idx_third_revision = args.index('--revision', idx_second_revision+1) idx_third_revision = args.index('--revision', idx_second_revision+1)
self.assertEquals(args[idx_first_revision+1], 'somename@DNE') self.assertEquals(args[idx_first_revision+1], 'somename@unmanaged')
self.assertEquals(args[idx_second_revision+1], 'src@origin/master') self.assertEquals(args[idx_second_revision+1], 'src@origin/master')
self.assertEquals(args[idx_third_revision+1], 'src/v8@deadbeef') self.assertEquals(args[idx_third_revision+1], 'src/v8@deadbeef')
return self.call.records return self.call.records
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment