Commit 8594182e authored by Ben Smith's avatar Ben Smith

[NaCl SDK] Fix the SDK builders to use Cr-Commit-Position.

We are relying on lastchange.FetchVersionInfo in build_sdk.py. The revision
changed from being an SVN revision to a git sha, but we want to be able to
compare the values numerically.

This change modifies build_version.py to get "Cr-Commit-Position", which for
our purposes is functionally equivalent to the SVN revision.

BUG=none
R=bradnelson@google.com, bradnelson@chromium.org

Review URL: https://codereview.chromium.org/507883003

Cr-Commit-Position: refs/heads/master@{#292179}
parent fb6cea80
......@@ -6,6 +6,7 @@
"""
import os
import re
import sys
# pylint: disable=E0602
......@@ -27,7 +28,7 @@ def ChromeVersion():
Returns:
Chrome version string or trunk + svn rev.
'''
info = lastchange.FetchVersionInfo(None)
info = FetchVersionInfo()
if info.url.startswith('/trunk/'):
return 'trunk.%s' % info.revision
else:
......@@ -58,10 +59,15 @@ def ChromeMajorVersion():
def ChromeRevision():
'''Extract chrome revision from svn.
Now that the Chrome source-of-truth is git, this will return the
Cr-Commit-Position instead. fortunately, this value is equal to the SVN
revision if one exists.
Returns:
The Chrome revision as a string. e.g. "12345"
'''
return lastchange.FetchVersionInfo(None).revision
return FetchVersionInfo().revision
def NaClRevision():
'''Extract NaCl revision from svn.
......@@ -70,4 +76,48 @@ def NaClRevision():
The NaCl revision as a string. e.g. "12345"
'''
nacl_dir = os.path.join(SRC_DIR, 'native_client')
return lastchange.FetchVersionInfo(None, nacl_dir).revision
return FetchVersionInfo(nacl_dir, 'native_client').revision
def FetchVersionInfo(directory=None,
directory_regex_prior_to_src_url='chrome|blink|svn'):
"""
Returns the last change (in the form of a branch, revision tuple),
from some appropriate revision control system.
TODO(binji): This is copied from lastchange.py. Remove this function and use
lastchange.py directly when the dust settles. (see crbug.com/406783)
"""
svn_url_regex = re.compile(
r'.*/(' + directory_regex_prior_to_src_url + r')(/.*)')
version_info = (lastchange.FetchSVNRevision(directory, svn_url_regex) or
lastchange.FetchGitSVNRevision(directory, svn_url_regex) or
FetchGitCommitPosition(directory))
if not version_info:
version_info = lastchange.VersionInfo(None, None)
return version_info
def FetchGitCommitPosition(directory=None):
"""
Return the "commit-position" of the Chromium git repo. This should be
equivalent to the SVN revision if one eixsts.
This is a copy of the (recently reverted) change in lastchange.py.
TODO(binji): Move this logic to lastchange.py when the dust settles.
(see crbug.com/406783)
"""
proc = lastchange.RunGitCommand(directory,
['show', '-s', '--format=%B', 'HEAD'])
pos = ''
if proc:
output = proc.communicate()[0]
if proc.returncode == 0 and output:
for line in reversed(output.splitlines()):
match = re.search('Cr-Commit-Position: .*@{#(\d+)}', line)
if match:
pos = match.group(1)
if not pos:
return lastchange.VersionInfo(None, None)
return lastchange.VersionInfo('git', pos)
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