Add repo-managed checkout support to trychange.py
BUG=chromium-os:21286
TEST=Ran 'git-try' with/without --root=src, and with/without .gclient file
Review URL: http://codereview.chromium.org/8174009
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@105229 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient_utils.py b/gclient_utils.py
index 39fb2f6..637b995 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -432,14 +432,17 @@
def FindFileUpwards(filename, path=None):
- """Search upwards from the a directory (default: current) to find a file."""
+ """Search upwards from the a directory (default: current) to find a file.
+
+ Returns nearest upper-level directory with the passed in 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
+ if os.path.exists(file_path):
+ return path
(new_path, _) = os.path.split(path)
if new_path == path:
return None
@@ -449,7 +452,7 @@
def GetGClientRootAndEntries(path=None):
"""Returns the gclient root and the dict of entries."""
config_file = '.gclient_entries'
- config_path = FindFileUpwards(config_file, path)
+ config_path = os.path.join(FindFileUpwards(config_file, path), config_file)
if not config_path:
print "Can't find %s" % config_file