diff --git a/gclient.py b/gclient.py index 83ea4ce0a..21eeeb5a1 100755 --- a/gclient.py +++ b/gclient.py @@ -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 ' diff --git a/tests/gclient_smoketest.py b/tests/gclient_smoketest.py index 586548bae..a4906096a 100755 --- a/tests/gclient_smoketest.py +++ b/tests/gclient_smoketest.py @@ -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