Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: gclient_utils.py

Issue 391048: gclient: fix another bug where ssh urls weren't parsed correctly (Closed)
Patch Set: fix per code review Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gclient_scm.py ('k') | tests/gclient_utils_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2009 Google Inc. All Rights Reserved. 1 # Copyright 2009 Google Inc. All Rights Reserved.
2 # 2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); 3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License. 4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at 5 # You may obtain a copy of the License at
6 # 6 #
7 # http://www.apache.org/licenses/LICENSE-2.0 7 # http://www.apache.org/licenses/LICENSE-2.0
8 # 8 #
9 # Unless required by applicable law or agreed to in writing, software 9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, 10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and 12 # See the License for the specific language governing permissions and
13 # limitations under the License. 13 # limitations under the License.
14 14
15 import errno 15 import errno
16 import os 16 import os
17 import re
17 import stat 18 import stat
18 import subprocess 19 import subprocess
19 import sys 20 import sys
20 import time 21 import time
21 import xml.dom.minidom 22 import xml.dom.minidom
22 import xml.parsers.expat 23 import xml.parsers.expat
23 24
24 ## Generic utils 25 ## Generic utils
25 26
26 27
28 def SplitUrlRevision(url):
29 """Splits url and returns a two-tuple: url, rev"""
30 if url.startswith('ssh:'):
31 # Make sure ssh://test@example.com/test.git@stable works
32 regex = r"(ssh://(?:[\w]+@)?[-\w:\.]+/[-\w\.]+)(?:@([\w/]+))?"
33 components = re.search(regex, url).groups()
34 else:
35 components = url.split("@")
36 if len(components) == 1:
37 components += [None]
38 return tuple(components)
39
40
27 def ParseXML(output): 41 def ParseXML(output):
28 try: 42 try:
29 return xml.dom.minidom.parseString(output) 43 return xml.dom.minidom.parseString(output)
30 except xml.parsers.expat.ExpatError: 44 except xml.parsers.expat.ExpatError:
31 return None 45 return None
32 46
33 47
34 def GetNamedNodeText(node, node_name): 48 def GetNamedNodeText(node, node_name):
35 child_nodes = node.getElementsByTagName(node_name) 49 child_nodes = node.getElementsByTagName(node_name)
36 if not child_nodes: 50 if not child_nodes:
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 raise Error(msg) 258 raise Error(msg)
245 259
246 260
247 def IsUsingGit(root, paths): 261 def IsUsingGit(root, paths):
248 """Returns True if we're using git to manage any of our checkouts. 262 """Returns True if we're using git to manage any of our checkouts.
249 |entries| is a list of paths to check.""" 263 |entries| is a list of paths to check."""
250 for path in paths: 264 for path in paths:
251 if os.path.exists(os.path.join(root, path, '.git')): 265 if os.path.exists(os.path.join(root, path, '.git')):
252 return True 266 return True
253 return False 267 return False
OLDNEW
« no previous file with comments | « gclient_scm.py ('k') | tests/gclient_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698