| 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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 custom_env['LC_MESSAGES'] = 'en_GB' | 359 custom_env['LC_MESSAGES'] = 'en_GB' |
| 360 p = subprocess.Popen(['svn', 'info'], stdout = subprocess.PIPE, | 360 p = subprocess.Popen(['svn', 'info'], stdout = subprocess.PIPE, |
| 361 stderr = subprocess.STDOUT, shell=IsWindows(), | 361 stderr = subprocess.STDOUT, shell=IsWindows(), |
| 362 env = custom_env, | 362 env = custom_env, |
| 363 cwd = DART_DIR) | 363 cwd = DART_DIR) |
| 364 output, _ = p.communicate() | 364 output, _ = p.communicate() |
| 365 revision = ParseSvnInfoOutput(output) | 365 revision = ParseSvnInfoOutput(output) |
| 366 if revision: | 366 if revision: |
| 367 return revision | 367 return revision |
| 368 | 368 |
| 369 # maybe the builder is using git-svn, try that | 369 # Check for revision using git (Note: we can't use git-svn because in a |
| 370 # pure-git checkout, "git-svn anyCommand" just hangs!). We look an arbitrary |
| 371 # number of commits backwards (100) to get past any local commits. |
| 372 p = subprocess.Popen(['git', 'log', '-100'], stdout = subprocess.PIPE, |
| 373 stderr = subprocess.STDOUT, shell=IsWindows(), cwd = DART_DIR) |
| 374 output, _ = p.communicate() |
| 375 revision = ParseGitInfoOutput(output) |
| 376 if revision: |
| 377 return revision |
| 378 |
| 379 # In the rare off-chance that git log -100 doesn't have a svn repo number, |
| 380 # attempt to use "git svn info." |
| 370 p = subprocess.Popen(['git', 'svn', 'info'], stdout = subprocess.PIPE, | 381 p = subprocess.Popen(['git', 'svn', 'info'], stdout = subprocess.PIPE, |
| 371 stderr = subprocess.STDOUT, shell=IsWindows(), cwd = DART_DIR) | 382 stderr = subprocess.STDOUT, shell=IsWindows(), cwd = DART_DIR) |
| 372 output, _ = p.communicate() | 383 output, _ = p.communicate() |
| 373 revision = ParseSvnInfoOutput(output) | 384 revision = ParseSvnInfoOutput(output) |
| 374 if revision: | 385 if revision: |
| 375 return revision | 386 return revision |
| 376 | 387 |
| 377 # Only fail on the buildbot in case of a SVN client version mismatch. | 388 # Only fail on the buildbot in case of a SVN client version mismatch. |
| 378 user = GetUserName() | 389 user = GetUserName() |
| 379 if user != 'chrome-bot': | 390 if user != 'chrome-bot': |
| 380 return '0' | 391 return '0' |
| 381 | 392 |
| 382 return None | 393 return None |
| 383 | 394 |
| 395 def ParseGitInfoOutput(output): |
| 396 """Given a git log, determine the latest corresponding svn revision.""" |
| 397 for line in output.split('\n'): |
| 398 tokens = line.split() |
| 399 if len(tokens) > 0 and tokens[0] == 'git-svn-id:': |
| 400 return tokens[1].split('@')[1] |
| 401 return None |
| 402 |
| 384 def ParseSvnInfoOutput(output): | 403 def ParseSvnInfoOutput(output): |
| 385 revision_match = re.search('Last Changed Rev: (\d+)', output) | 404 revision_match = re.search('Last Changed Rev: (\d+)', output) |
| 386 if revision_match: | 405 if revision_match: |
| 387 return revision_match.group(1) | 406 return revision_match.group(1) |
| 388 return None | 407 return None |
| 389 | 408 |
| 390 def RewritePathSeparator(path, workspace): | 409 def RewritePathSeparator(path, workspace): |
| 391 # Paths in test files are always specified using '/' | 410 # Paths in test files are always specified using '/' |
| 392 # as the path separator. Replace with the actual | 411 # as the path separator. Replace with the actual |
| 393 # path separator before use. | 412 # path separator before use. |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 os.chdir(self._working_directory) | 584 os.chdir(self._working_directory) |
| 566 | 585 |
| 567 def __exit__(self, *_): | 586 def __exit__(self, *_): |
| 568 print "Enter directory = ", self._old_cwd | 587 print "Enter directory = ", self._old_cwd |
| 569 os.chdir(self._old_cwd) | 588 os.chdir(self._old_cwd) |
| 570 | 589 |
| 571 | 590 |
| 572 if __name__ == "__main__": | 591 if __name__ == "__main__": |
| 573 import sys | 592 import sys |
| 574 Main(sys.argv) | 593 Main(sys.argv) |
| OLD | NEW |