| OLD | NEW |
| 1 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
| 3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 # This file contains a set of utilities functions used by other Python-based | 5 # This file contains a set of utilities functions used by other Python-based |
| 6 # scripts. | 6 # scripts. |
| 7 | 7 |
| 8 import commands | 8 import commands |
| 9 import os | 9 import os |
| 10 import platform | 10 import platform |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 prerelease_patch = match_against('^PRERELEASE_PATCH (\d+)$', content) | 311 prerelease_patch = match_against('^PRERELEASE_PATCH (\d+)$', content) |
| 312 | 312 |
| 313 if channel and major and minor and prerelease and prerelease_patch: | 313 if channel and major and minor and prerelease and prerelease_patch: |
| 314 return Version( | 314 return Version( |
| 315 channel, major, minor, patch, prerelease, prerelease_patch) | 315 channel, major, minor, patch, prerelease, prerelease_patch) |
| 316 else: | 316 else: |
| 317 print "Warning: VERSION file (%s) has wrong format" % version_file | 317 print "Warning: VERSION file (%s) has wrong format" % version_file |
| 318 return None | 318 return None |
| 319 | 319 |
| 320 def GetSVNRevision(): | 320 def GetSVNRevision(): |
| 321 # When building from tarball use tools/SVN_REVISION |
| 322 svn_revision_file = os.path.join(DART_DIR, 'tools', 'SVN_REVISION') |
| 323 try: |
| 324 with open(svn_revision_file) as fd: |
| 325 return fd.read() |
| 326 except: |
| 327 pass |
| 328 |
| 321 # FIXME(kustermann): Make this work for newer SVN versions as well (where | 329 # FIXME(kustermann): Make this work for newer SVN versions as well (where |
| 322 # we've got only one '.svn' directory) | 330 # we've got only one '.svn' directory) |
| 323 custom_env = dict(os.environ) | 331 custom_env = dict(os.environ) |
| 324 custom_env['LC_MESSAGES'] = 'en_GB' | 332 custom_env['LC_MESSAGES'] = 'en_GB' |
| 325 p = subprocess.Popen(['svn', 'info'], stdout = subprocess.PIPE, | 333 p = subprocess.Popen(['svn', 'info'], stdout = subprocess.PIPE, |
| 326 stderr = subprocess.STDOUT, shell=IsWindows(), | 334 stderr = subprocess.STDOUT, shell=IsWindows(), |
| 327 env = custom_env, | 335 env = custom_env, |
| 328 cwd = DART_DIR) | 336 cwd = DART_DIR) |
| 329 output, _ = p.communicate() | 337 output, _ = p.communicate() |
| 330 revision = ParseSvnInfoOutput(output) | 338 revision = ParseSvnInfoOutput(output) |
| 331 if revision: | 339 if revision: |
| 332 return revision | 340 return revision |
| 333 | 341 |
| 334 # maybe the builder is using git-svn, try that | 342 # maybe the builder is using git-svn, try that |
| 335 p = subprocess.Popen(['git', 'svn', 'info'], stdout = subprocess.PIPE, | 343 p = subprocess.Popen(['git', 'svn', 'info'], stdout = subprocess.PIPE, |
| 336 stderr = subprocess.STDOUT, shell=IsWindows(), cwd = DART_DIR) | 344 stderr = subprocess.STDOUT, shell=IsWindows(), cwd = DART_DIR) |
| 337 output, _ = p.communicate() | 345 output, _ = p.communicate() |
| 338 revision = ParseSvnInfoOutput(output) | 346 revision = ParseSvnInfoOutput(output) |
| 339 if revision: | 347 if revision: |
| 340 return revision | 348 return revision |
| 341 | 349 |
| 342 # When building from tarball use tools/SVN_REVISION | |
| 343 svn_revision_file = os.path.join(DART_DIR, 'tools', 'SVN_REVISION') | |
| 344 try: | |
| 345 with open(svn_revision_file) as fd: | |
| 346 return fd.read() | |
| 347 except: | |
| 348 pass | |
| 349 | |
| 350 # Only fail on the buildbot in case of a SVN client version mismatch. | 350 # Only fail on the buildbot in case of a SVN client version mismatch. |
| 351 user = GetUserName() | 351 user = GetUserName() |
| 352 if user != 'chrome-bot': | 352 if user != 'chrome-bot': |
| 353 return '0' | 353 return '0' |
| 354 | 354 |
| 355 return None | 355 return None |
| 356 | 356 |
| 357 def ParseSvnInfoOutput(output): | 357 def ParseSvnInfoOutput(output): |
| 358 revision_match = re.search('Last Changed Rev: (\d+)', output) | 358 revision_match = re.search('Last Changed Rev: (\d+)', output) |
| 359 if revision_match: | 359 if revision_match: |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 os.chdir(self._working_directory) | 534 os.chdir(self._working_directory) |
| 535 | 535 |
| 536 def __exit__(self, *_): | 536 def __exit__(self, *_): |
| 537 print "Enter directory = ", self._old_cwd | 537 print "Enter directory = ", self._old_cwd |
| 538 os.chdir(self._old_cwd) | 538 os.chdir(self._old_cwd) |
| 539 | 539 |
| 540 | 540 |
| 541 if __name__ == "__main__": | 541 if __name__ == "__main__": |
| 542 import sys | 542 import sys |
| 543 Main(sys.argv) | 543 Main(sys.argv) |
| OLD | NEW |