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

Side by Side Diff: gclient_utils.py

Issue 500015: gclient: implement a less hacky relative URL implementation (Closed)
Patch Set: Created 11 years 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
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,
(...skipping 20 matching lines...) Expand all
31 # Make sure ssh://test@example.com/test.git@stable works 31 # Make sure ssh://test@example.com/test.git@stable works
32 regex = r"(ssh://(?:[\w]+@)?[-\w:\.]+/[-\w\./]+)(?:@(.+))?" 32 regex = r"(ssh://(?:[\w]+@)?[-\w:\.]+/[-\w\./]+)(?:@(.+))?"
33 components = re.search(regex, url).groups() 33 components = re.search(regex, url).groups()
34 else: 34 else:
35 components = url.split("@") 35 components = url.split("@")
36 if len(components) == 1: 36 if len(components) == 1:
37 components += [None] 37 components += [None]
38 return tuple(components) 38 return tuple(components)
39 39
40 40
41 def FullUrlFromRelative(base_url, url):
42 # Find the forth '/' and strip from there. A bit hackish.
43 return '/'.join(base_url.split('/')[:4]) + url
44
45
46 def FullUrlFromRelative2(base_url, url):
M-A Ruel 2009/12/15 18:49:42 Frankly, I would have prefered it to be SCM-depend
Mandeep Singh Baines 2009/12/15 20:54:30 k, I'll send out a CL to do that. I don't want to
47 # Strip from last '/'
48 # Equivalent to unix basename
49 return base_url[:base_url.rfind('/')] + url
50
51
41 def ParseXML(output): 52 def ParseXML(output):
42 try: 53 try:
43 return xml.dom.minidom.parseString(output) 54 return xml.dom.minidom.parseString(output)
44 except xml.parsers.expat.ExpatError: 55 except xml.parsers.expat.ExpatError:
45 return None 56 return None
46 57
47 58
48 def GetNamedNodeText(node, node_name): 59 def GetNamedNodeText(node, node_name):
49 child_nodes = node.getElementsByTagName(node_name) 60 child_nodes = node.getElementsByTagName(node_name)
50 if not child_nodes: 61 if not child_nodes:
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 raise Error(msg) 269 raise Error(msg)
259 270
260 271
261 def IsUsingGit(root, paths): 272 def IsUsingGit(root, paths):
262 """Returns True if we're using git to manage any of our checkouts. 273 """Returns True if we're using git to manage any of our checkouts.
263 |entries| is a list of paths to check.""" 274 |entries| is a list of paths to check."""
264 for path in paths: 275 for path in paths:
265 if os.path.exists(os.path.join(root, path, '.git')): 276 if os.path.exists(os.path.join(root, path, '.git')):
266 return True 277 return True
267 return False 278 return False
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698