Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: tools/utils.py

Issue 327563003: Use "git log" instead of "git svn info" for revision number information, since (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 p = subprocess.Popen(['git', 'svn', 'info'], stdout = subprocess.PIPE, 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.
ricow1 2014/06/10 10:44:10 will this actually give the correct revision?
Emily Fortuna 2014/06/10 16:08:47 Yup, as long as there are no more than 100 local c
372 p = subprocess.Popen(['git', 'log', '-100'], stdout = subprocess.PIPE,
371 stderr = subprocess.STDOUT, shell=IsWindows(), cwd = DART_DIR) 373 stderr = subprocess.STDOUT, shell=IsWindows(), cwd = DART_DIR)
Emily Fortuna 2014/06/09 17:45:41 Yeah, the 100 is gross, but better than hanging in
372 output, _ = p.communicate() 374 output, _ = p.communicate()
373 revision = ParseSvnInfoOutput(output) 375 revision = ParseGitInfoOutput(output)
374 if revision: 376 if revision:
blois 2014/06/16 19:20:12 Could fall back to git svn info if this fails, jus
375 return revision 377 return revision
376 378
377 # Only fail on the buildbot in case of a SVN client version mismatch. 379 # Only fail on the buildbot in case of a SVN client version mismatch.
378 user = GetUserName() 380 user = GetUserName()
379 if user != 'chrome-bot': 381 if user != 'chrome-bot':
380 return '0' 382 return '0'
381 383
382 return None 384 return None
383 385
386 def ParseGitInfoOutput(output):
387 """Given a git log, determine the latest corresponding svn revision."""
388 for line in output.split('\n'):
389 tokens = line.split()
390 if len(tokens) > 0 and tokens[0] == 'git-svn-id:':
391 return tokens[1].split('@')[1]
392 return None
393
384 def ParseSvnInfoOutput(output): 394 def ParseSvnInfoOutput(output):
385 revision_match = re.search('Last Changed Rev: (\d+)', output) 395 revision_match = re.search('Last Changed Rev: (\d+)', output)
386 if revision_match: 396 if revision_match:
387 return revision_match.group(1) 397 return revision_match.group(1)
388 return None 398 return None
389 399
390 def RewritePathSeparator(path, workspace): 400 def RewritePathSeparator(path, workspace):
391 # Paths in test files are always specified using '/' 401 # Paths in test files are always specified using '/'
392 # as the path separator. Replace with the actual 402 # as the path separator. Replace with the actual
393 # path separator before use. 403 # path separator before use.
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 os.chdir(self._working_directory) 575 os.chdir(self._working_directory)
566 576
567 def __exit__(self, *_): 577 def __exit__(self, *_):
568 print "Enter directory = ", self._old_cwd 578 print "Enter directory = ", self._old_cwd
569 os.chdir(self._old_cwd) 579 os.chdir(self._old_cwd)
570 580
571 581
572 if __name__ == "__main__": 582 if __name__ == "__main__":
573 import sys 583 import sys
574 Main(sys.argv) 584 Main(sys.argv)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698