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: Aaron Gable <agable@chromium.org>
diff --git a/gclient.py b/gclient.py
index 83ea4ce..21eeeb5 100755
--- a/gclient.py
+++ b/gclient.py
@@ -962,8 +962,9 @@
     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 @@
                     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 '