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

Side by Side Diff: gclient_utils.py

Issue 546022: gclient: git relative url implementation (Closed)
Patch Set: Created 10 years, 11 months 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_scm_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,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 # Make sure ssh://test@example.com/test.git@stable works 64 # Make sure ssh://test@example.com/test.git@stable works
65 regex = r"(ssh://(?:[\w]+@)?[-\w:\.]+/[-\w\./]+)(?:@(.+))?" 65 regex = r"(ssh://(?:[\w]+@)?[-\w:\.]+/[-\w\./]+)(?:@(.+))?"
66 components = re.search(regex, url).groups() 66 components = re.search(regex, url).groups()
67 else: 67 else:
68 components = url.split("@") 68 components = url.split("@")
69 if len(components) == 1: 69 if len(components) == 1:
70 components += [None] 70 components += [None]
71 return tuple(components) 71 return tuple(components)
72 72
73 73
74 def FullUrlFromRelative(base_url, url):
75 # Find the forth '/' and strip from there. A bit hackish.
76 return '/'.join(base_url.split('/')[:4]) + url
77
78
79 def FullUrlFromRelative2(base_url, url):
80 # Strip from last '/'
81 # Equivalent to unix basename
82 return base_url[:base_url.rfind('/')] + url
83
84
85 def ParseXML(output): 74 def ParseXML(output):
86 try: 75 try:
87 return xml.dom.minidom.parseString(output) 76 return xml.dom.minidom.parseString(output)
88 except xml.parsers.expat.ExpatError: 77 except xml.parsers.expat.ExpatError:
89 return None 78 return None
90 79
91 80
92 def GetNamedNodeText(node, node_name): 81 def GetNamedNodeText(node, node_name):
93 child_nodes = node.getElementsByTagName(node_name) 82 child_nodes = node.getElementsByTagName(node_name)
94 if not child_nodes: 83 if not child_nodes:
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 """Returns the difference subpath minus root.""" 315 """Returns the difference subpath minus root."""
327 root = os.path.realpath(root) 316 root = os.path.realpath(root)
328 subpath = os.path.realpath(subpath) 317 subpath = os.path.realpath(subpath)
329 if not subpath.startswith(root): 318 if not subpath.startswith(root):
330 return None 319 return None
331 # If the root does not have a trailing \ or /, we add it so the returned 320 # If the root does not have a trailing \ or /, we add it so the returned
332 # path starts immediately after the seperator regardless of whether it is 321 # path starts immediately after the seperator regardless of whether it is
333 # provided. 322 # provided.
334 root = os.path.join(root, '') 323 root = os.path.join(root, '')
335 return subpath[len(root):] 324 return subpath[len(root):]
OLDNEW
« no previous file with comments | « gclient_scm.py ('k') | tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698