mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add a new check_revision.py tool that is called from cef_create_projects to verify the current Chromium revision and URL against the values specified in CHROMIUM_BUILD_COMPATIBILITY.txt (issue #297).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@349 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -3,16 +3,38 @@
|
||||
# can be found in the LICENSE file.
|
||||
|
||||
import os
|
||||
import urllib
|
||||
|
||||
def check_url(url):
|
||||
""" Check the URL and raise an exception if invalid. """
|
||||
if ':' in url[:7]:
|
||||
parts = url.split(':', 1)
|
||||
if (parts[0] == 'http' or parts[0] == 'https') and \
|
||||
parts[1] == urllib.quote(parts[1]):
|
||||
return url
|
||||
sys.stderr.write('Invalid URL: '+url+"\n")
|
||||
raise Exception('Invalid URL: '+url)
|
||||
|
||||
def get_svn_info(path):
|
||||
""" Retrieves the URL and revision from svn info. """
|
||||
url = 'None'
|
||||
rev = 'None'
|
||||
if path[0:4] == 'http' or os.path.exists(path):
|
||||
try:
|
||||
stream = os.popen('svn info '+path)
|
||||
for line in stream:
|
||||
if line[0:4] == "URL:":
|
||||
url = check_url(line[5:-1])
|
||||
elif line[0:9] == "Revision:":
|
||||
rev = str(int(line[10:-1]))
|
||||
except IOError, (errno, strerror):
|
||||
sys.stderr.write('Failed to read svn info: '+strerror+"\n")
|
||||
raise
|
||||
return {'url': url, 'revision': rev}
|
||||
|
||||
def get_revision(path = '.'):
|
||||
""" Retrieves the revision number from stdin. """
|
||||
try:
|
||||
stream = os.popen('svn info '+path);
|
||||
# read the revision number
|
||||
for line in stream:
|
||||
if line[0:9] == "Revision:":
|
||||
return line[10:-1];
|
||||
raise IOError("Revision line not found.")
|
||||
except IOError, (errno, strerror):
|
||||
sys.stderr.write('Failed to read revision from "svn info": ' + strerror)
|
||||
raise
|
||||
""" Retrieves the revision from svn info. """
|
||||
info = get_svn_info(path)
|
||||
if info['revision'] == 'None':
|
||||
raise Exception('Unable to retrieve SVN revision for "'+path+'"')
|
||||
return info['revision']
|
||||
|
Reference in New Issue
Block a user