From 2bb4be9680eeb9007ecaff90a8aa8d0637647b20 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Mon, 22 Jul 2013 23:47:50 +0000 Subject: [PATCH] Merge revision 1329 and revision 1330 changes: - Fix script detection of git checkouts. git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1547@1333 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- tools/check_revision.py | 4 ++++ tools/make_version_header.py | 10 ++++++---- tools/revision.py | 7 +++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tools/check_revision.py b/tools/check_revision.py index e9334dca2..4d96c2267 100644 --- a/tools/check_revision.py +++ b/tools/check_revision.py @@ -27,6 +27,10 @@ parser.add_option('-q', '--quiet', # The CEF root directory is the parent directory of _this_ script. cef_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) +if not os.path.exists(os.path.join(cef_dir, '.svn')): + sys.stdout.write("Not an SVN checkout.\n") + sys.exit(0) + # Retrieve the CEF SVN info. cef_info = get_svn_info(cef_dir) if not options.quiet: diff --git a/tools/make_version_header.py b/tools/make_version_header.py index 080f09b83..3c85ccd98 100644 --- a/tools/make_version_header.py +++ b/tools/make_version_header.py @@ -60,10 +60,12 @@ def write_svn_header(header, chrome_version, cef_version, cpp_header_dir): year = get_year() - try: - revision = svn.get_revision() - except: - revision = git.get_svn_revision() + if os.path.exists(os.path.join('.', '.svn')): + revision = svn.get_revision() + elif os.path.exists(os.path.join('.', '.git')): + revision = git.get_svn_revision() + else: + raise Exception('Not a valid checkout') # calculate api hashes api_hash_calculator = cef_api_hash(cpp_header_dir, verbose = False) diff --git a/tools/revision.py b/tools/revision.py index 1096c12dd..1d946029f 100644 --- a/tools/revision.py +++ b/tools/revision.py @@ -4,6 +4,7 @@ import svn_util as svn import git_util as git +import os import sys # cannot be loaded as a module @@ -11,9 +12,11 @@ if __name__ != "__main__": sys.stderr.write('This file cannot be loaded as a module!') sys.exit() -try: +if os.path.exists(os.path.join('.', '.svn')): sys.stdout.write(svn.get_revision()) -except: +elif os.path.exists(os.path.join('.', '.git')): sys.stdout.write(git.get_svn_revision()) +else: + raise Exception('Not a valid checkout')