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

Side by Side Diff: gclient_utils.py

Issue 507072: Factor out PathDifference into gclient_utils for a later reuse. (Closed)
Patch Set: Created 10 years, 12 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 | « gcl.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,
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 310
311 def FindGclientRoot(from_dir): 311 def FindGclientRoot(from_dir):
312 """Tries to find the gclient root.""" 312 """Tries to find the gclient root."""
313 path = os.path.realpath(from_dir) 313 path = os.path.realpath(from_dir)
314 while not os.path.exists(os.path.join(path, '.gclient')): 314 while not os.path.exists(os.path.join(path, '.gclient')):
315 next = os.path.split(path) 315 next = os.path.split(path)
316 if not next[1]: 316 if not next[1]:
317 return None 317 return None
318 path = next[0] 318 path = next[0]
319 return path 319 return path
320
321 def PathDifference(root, subpath):
322 """Returns the difference subpath minus root."""
323 root = os.path.realpath(root)
324 subpath = os.path.realpath(subpath)
325 if not subpath.startswith(root):
326 return None
327 # If the root does not have a trailing \ or /, we add it so the returned
328 # path starts immediately after the seperator regardless of whether it is
329 # provided.
330 root = os.path.join(root, '')
331 return subpath[len(root):]
OLDNEW
« no previous file with comments | « gcl.py ('k') | tests/gclient_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698