webkit: expose webkit branch and revision number in about pages
- Change lastchange.py to work in other directories and to provide SVN URL. - Use lastchange.py in place where we generate WebKit versioning info. - Include branch@revision string in glue API. BUG=41264 TEST=compiles Review URL: http://codereview.chromium.org/6354014 git-svn-id: http://src.chromium.org/svn/trunk/src/build@72245 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
Родитель
24f90193dc
Коммит
b7144dba1e
|
@ -9,46 +9,71 @@ lastchange.py -- Chromium revision fetching utility.
|
||||||
|
|
||||||
import optparse
|
import optparse
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
class VersionInfo(object):
|
||||||
|
def __init__(self, url, root, revision):
|
||||||
|
self.url = url
|
||||||
|
self.root = root
|
||||||
|
self.revision = revision
|
||||||
|
|
||||||
def FetchSVNRevision(command):
|
|
||||||
|
def FetchSVNRevision(command, directory):
|
||||||
"""
|
"""
|
||||||
Fetch the Subversion revision for the local tree.
|
Fetch the Subversion branch and revision for the a given directory
|
||||||
|
by running the given command (e.g. "svn info").
|
||||||
|
|
||||||
Errors are swallowed.
|
Errors are swallowed.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
a VersionInfo object or None on error.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
proc = subprocess.Popen(command,
|
proc = subprocess.Popen(command,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
|
cwd=directory,
|
||||||
shell=(sys.platform=='win32'))
|
shell=(sys.platform=='win32'))
|
||||||
except OSError:
|
except OSError:
|
||||||
# command is apparently either not installed or not executable.
|
# command is apparently either not installed or not executable.
|
||||||
return None
|
return None
|
||||||
if proc:
|
if not proc:
|
||||||
svn_re = re.compile('^Revision:\s+(\d+)', re.M)
|
return None
|
||||||
match = svn_re.search(proc.stdout.read())
|
|
||||||
if match:
|
attrs = {}
|
||||||
return match.group(1)
|
for line in proc.stdout:
|
||||||
return None
|
line = line.strip()
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
key, val = line.split(': ', 1)
|
||||||
|
attrs[key] = val
|
||||||
|
|
||||||
|
try:
|
||||||
|
url = attrs['URL']
|
||||||
|
root = attrs['Repository Root']
|
||||||
|
revision = attrs['Revision']
|
||||||
|
except KeyError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return VersionInfo(url, root, revision)
|
||||||
|
|
||||||
|
|
||||||
def FetchChange(default_lastchange):
|
def FetchVersionInfo(default_lastchange, directory=None):
|
||||||
"""
|
"""
|
||||||
Returns the last change, from some appropriate revision control system.
|
Returns the last change (in the form of a branch, revision tuple),
|
||||||
|
from some appropriate revision control system.
|
||||||
"""
|
"""
|
||||||
change = FetchSVNRevision(['svn', 'info'])
|
version_info = FetchSVNRevision(['svn', 'info'], directory)
|
||||||
if not change and sys.platform in ('linux2',):
|
if not version_info and sys.platform in ('linux2',):
|
||||||
change = FetchSVNRevision(['git', 'svn', 'info'])
|
version_info = FetchSVNRevision(['git', 'svn', 'info'], directory)
|
||||||
if not change:
|
if not version_info:
|
||||||
if default_lastchange and os.path.exists(default_lastchange):
|
if default_lastchange and os.path.exists(default_lastchange):
|
||||||
change = open(default_lastchange, 'r').read().strip()
|
revision = open(default_lastchange, 'r').read().strip()
|
||||||
|
version_info = VersionInfo(None, None, revision)
|
||||||
else:
|
else:
|
||||||
change = '0'
|
version_info = VersionInfo('', '', '0')
|
||||||
return change
|
return version_info
|
||||||
|
|
||||||
|
|
||||||
def WriteIfChanged(file_name, contents):
|
def WriteIfChanged(file_name, contents):
|
||||||
|
@ -90,12 +115,12 @@ def main(argv=None):
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
change = FetchChange(opts.default_lastchange)
|
version_info = FetchVersionInfo(opts.default_lastchange)
|
||||||
|
|
||||||
if opts.revision_only:
|
if opts.revision_only:
|
||||||
print change
|
print version_info.revision
|
||||||
else:
|
else:
|
||||||
contents = "LASTCHANGE=%s\n" % change
|
contents = "LASTCHANGE=%s\n" % version_info.revision
|
||||||
if out_file:
|
if out_file:
|
||||||
WriteIfChanged(out_file, contents)
|
WriteIfChanged(out_file, contents)
|
||||||
else:
|
else:
|
||||||
|
|
Загрузка…
Ссылка в новой задаче