Commit a05be0ba authored by maruel@chromium.org's avatar maruel@chromium.org

Fix 'gcl help' when not run inside a svn checkout.

TEST=none
BUG=none

Review URL: http://codereview.chromium.org/150114

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@19628 0039d316-1c4b-4281-b951-d872f2087c98
parent b8b6b871
...@@ -96,7 +96,7 @@ def GetRepositoryRoot(): ...@@ -96,7 +96,7 @@ def GetRepositoryRoot():
infos = gclient.CaptureSVNInfo(os.getcwd(), print_error=False) infos = gclient.CaptureSVNInfo(os.getcwd(), print_error=False)
cur_dir_repo_root = infos.get("Repository Root") cur_dir_repo_root = infos.get("Repository Root")
if not cur_dir_repo_root: if not cur_dir_repo_root:
raise Exception("gcl run outside of repository") raise gclient.Error("gcl run outside of repository")
REPOSITORY_ROOT = os.getcwd() REPOSITORY_ROOT = os.getcwd()
while True: while True:
...@@ -138,7 +138,10 @@ def GetCachedFile(filename, max_age=60*60*24*3, use_root=False): ...@@ -138,7 +138,10 @@ def GetCachedFile(filename, max_age=60*60*24*3, use_root=False):
# Don't try to look up twice. # Don't try to look up twice.
FILES_CACHE[filename] = None FILES_CACHE[filename] = None
# First we check if we have a cached version. # First we check if we have a cached version.
try:
cached_file = os.path.join(GetCacheDir(), filename) cached_file = os.path.join(GetCacheDir(), filename)
except gclient.Error:
return None
if (not os.path.exists(cached_file) or if (not os.path.exists(cached_file) or
os.stat(cached_file).st_mtime > max_age): os.stat(cached_file).st_mtime > max_age):
dir_info = gclient.CaptureSVNInfo(".") dir_info = gclient.CaptureSVNInfo(".")
...@@ -1099,6 +1102,7 @@ def main(argv=None): ...@@ -1099,6 +1102,7 @@ def main(argv=None):
Help() Help()
return 0; return 0;
try:
# Create the directories where we store information about changelists if it # Create the directories where we store information about changelists if it
# doesn't exist. # doesn't exist.
if not os.path.exists(GetInfoDir()): if not os.path.exists(GetInfoDir()):
...@@ -1114,6 +1118,9 @@ def main(argv=None): ...@@ -1114,6 +1118,9 @@ def main(argv=None):
shutil.move(file_path, GetChangesDir()) shutil.move(file_path, GetChangesDir())
if not os.path.exists(GetCacheDir()): if not os.path.exists(GetCacheDir()):
os.mkdir(GetCacheDir()) os.mkdir(GetCacheDir())
except gclient.Error:
# Will throw an exception if not run in a svn checkout.
pass
# Commands that don't require an argument. # Commands that don't require an argument.
command = argv[1] command = argv[1]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment