OLD | NEW |
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 Loading... |
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):] |
OLD | NEW |