gclient: fix another bug where ssh urls weren't parsed correctly

ssh://test@example.com wasn't being parsed correctly for revinfo.

Fixed by factoring out all code which splits url into a base_url
and revision.

Review URL: http://codereview.chromium.org/391048

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@31910 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient_utils.py b/gclient_utils.py
index d21467f..9016270 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -14,6 +14,7 @@
 
 import errno
 import os
+import re
 import stat
 import subprocess
 import sys
@@ -24,6 +25,19 @@
 ## Generic utils
 
 
+def SplitUrlRevision(url):
+  """Splits url and returns a two-tuple: url, rev"""
+  if url.startswith('ssh:'):
+    # Make sure ssh://test@example.com/test.git@stable works
+    regex = r"(ssh://(?:[\w]+@)?[-\w:\.]+/[-\w\.]+)(?:@([\w/]+))?"
+    components = re.search(regex, url).groups()
+  else:
+    components = url.split("@")
+    if len(components) == 1:
+      components += [None]
+  return tuple(components)
+
+
 def ParseXML(output):
   try:
     return xml.dom.minidom.parseString(output)