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

Unified Diff: gclient_utils.py

Issue 507072: Factor out PathDifference into gclient_utils for a later reuse. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gcl.py ('k') | tests/gclient_utils_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_utils.py
diff --git a/gclient_utils.py b/gclient_utils.py
index 97d05edd12893eef56e7b4543cbae3db94b30411..af9845784a23d603e30350ec6f4c30ac333edd7c 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -317,3 +317,15 @@ def FindGclientRoot(from_dir):
return None
path = next[0]
return path
+
+def PathDifference(root, subpath):
+ """Returns the difference subpath minus root."""
+ root = os.path.realpath(root)
+ subpath = os.path.realpath(subpath)
+ if not subpath.startswith(root):
+ return None
+ # If the root does not have a trailing \ or /, we add it so the returned
+ # path starts immediately after the seperator regardless of whether it is
+ # provided.
+ root = os.path.join(root, '')
+ return subpath[len(root):]
« 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