Adding weekly tool to help with weekly snippets
This tool displays all checkins by one (or several) authors in the past week (or configurable time), in all dependencies. Only works on git dependencies currently.
Review URL: http://codereview.chromium.org/1602020
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@44612 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient_utils.py b/gclient_utils.py
index e08bf8e..a052d42 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -323,3 +323,33 @@
# provided.
root = os.path.join(root, '')
return subpath[len(root):]
+
+
+def FindFileUpwards(filename, path=None):
+ """Search upwards from the a directory (default: current) to find a file."""
+ if not path:
+ path = os.getcwd()
+ path = os.path.realpath(path)
+ while True:
+ file_path = os.path.join(path, filename)
+ if os.path.isfile(file_path):
+ return file_path
+ (new_path, _) = os.path.split(path)
+ if new_path == path:
+ return None
+ path = new_path
+
+
+def GetGClientRootAndEntries(path=None):
+ """Returns the gclient root and the dict of entries."""
+ config_file = '.gclient_entries'
+ config_path = FindFileUpwards(config_file, path)
+
+ if not config_path:
+ print "Can't find", config_file
+ return None
+
+ env = {}
+ execfile(config_path, env)
+ config_dir = os.path.dirname(config_path)
+ return config_dir, env['entries']