Commit 53014653 authored by Edward Lesmes's avatar Edward Lesmes Committed by Commit Bot

gclient: Give priority to URL over paths when specifying revisions.

e.g. when specifying both '--revision src@<something>' and
'--revision <src_gerrit_repo>@<some_gerrit_ref>', gclient will sync to
'<some_gerrit_ref>' instead of '<something>'.

This is useful when specifying which gerrit change to patch, which
should take priority over other revision specifications.

Bug: chromium:643346
Change-Id: Ibc21ede355b56e4da966f38f144ce6f6f1743403
Reviewed-on: https://chromium-review.googlesource.com/949981
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: 's avatarAaron Gable <agable@chromium.org>
parent c2960246
......@@ -962,8 +962,9 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
parsed_url = self.LateOverride(self.url)
file_list = [] if not options.nohooks else None
revision_override = revision_overrides.pop(self.name, None)
if not revision_override and parsed_url:
revision_override = revision_overrides.get(parsed_url.split('@')[0], None)
if parsed_url:
revision_override = revision_overrides.pop(
parsed_url.split('@')[0], revision_override)
if run_scm and parsed_url:
# Create a shallow copy to mutate revision.
options = copy.copy(options)
......@@ -2599,9 +2600,12 @@ def CMDsync(parser, args):
dest='revisions', metavar='REV', default=[],
help='Enforces revision/hash for the solutions with the '
'format src@rev. The src@ part is optional and can be '
'skipped. -r can be used multiple times when .gclient '
'has multiple solutions configured and will work even '
'if the src@ part is skipped.')
'skipped. You can also specify URLs instead of paths '
'and gclient will find the solution corresponding to '
'the given URL. If a path is also specified, the URL '
'takes precedence. -r can be used multiple times when '
'.gclient has multiple solutions configured, and will '
'work even if the src@ part is skipped.')
parser.add_option('--with_branch_heads', action='store_true',
help='Clone git "branch_heads" refspecs in addition to '
'the default refspecs. This adds about 1/2GB to a '
......
......@@ -514,6 +514,24 @@ class GClientSmokeGIT(GClientSmokeBase):
['sync', '-v', '-v', '-v', '--revision', 'refs/changes/1212'])
self.assertEquals(0, rc)
def testSyncUrl(self):
if not self.enabled:
return
self.gclient(['config', self.git_base + 'repo_1', '--name', 'src'])
self.gclient([
'sync', '-v', '-v', '-v',
'--revision', 'src/repo2@%s' % self.githash('repo_2', 1),
'--revision', '%srepo_2@%s' % (self.git_base, self.githash('repo_2', 2))
])
# repo_2 should've been synced to @2 instead of @1, since URLs override
# paths.
tree = self.mangle_git_tree(('repo_1@2', 'src'),
('repo_2@2', 'src/repo2'),
('repo_3@2', 'src/repo2/repo_renamed'))
tree['src/git_hooked1'] = 'git_hooked1'
tree['src/git_hooked2'] = 'git_hooked2'
self.assertTree(tree)
def testRunHooks(self):
if not self.enabled:
return
......
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