Fix bug in git cl patch using raw patch URL.

When using a raw URL from a different Rietveld instance than the one
in codereview.settings, you get an error like this:

File "depot_tools/git_cl.py", line 2767, in PatchIssue
    RunGit(['commit', '-m', (cl.GetDescription() + '\n\n' +
UnboundLocalError: local variable 'cl' referenced before assignment

This fixes that. It is needed for the WebRTC transition to the
Chromium Rietveld instance using https://codereview.webrtc.org

BUG=webrtc:3884
TESTED=In a WebRTC checkout: ran 'git cl patch https://codereview.webrtc.org/download/issue1135893005_1.diff'
on a clean branch and had it apply correctly.
In a Chromium checkout, ran 'git cl patch 1154023002' and verified
the commit message was correct.
I also ran using the raw URL and verified the result was the same.

Review URL: https://codereview.chromium.org/1166673002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@295491 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/git_cl.py b/git_cl.py
index 8cc37bf..ce36541 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -318,7 +318,7 @@
     time.sleep(0.5 + 1.5*try_count)
 
   print '\n'.join(print_text)
-      
+
 
 def MatchSvnGlob(url, base_url, glob_spec, allow_wildcards):
   """Return the corresponding git ref if |base_url| together with |glob_spec|
@@ -2720,12 +2720,14 @@
   else:
     # Assume it's a URL to the patch. Default to https.
     issue_url = gclient_utils.UpgradeToHttps(issue_arg)
-    match = re.match(r'.*?/issue(\d+)_(\d+).diff', issue_url)
+    match = re.match(r'(.*?)/download/issue(\d+)_(\d+).diff', issue_url)
     if not match:
       DieWithError('Must pass an issue ID or full URL for '
           '\'Download raw patch set\'')
-    issue = int(match.group(1))
-    patchset = int(match.group(2))
+    issue = int(match.group(2))
+    cl = Changelist(issue=issue, auth_config=auth_config)
+    cl.rietveld_server = match.group(1)
+    patchset = int(match.group(3))
     patch_data = urllib2.urlopen(issue_arg).read()
 
   # Switch up to the top-level directory, if necessary, in preparation for