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

Side by Side Diff: tools/utils.py

Issue 1166743005: Remove GetSVNRevision from tools/utils.py (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address comments Created 5 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
« no previous file with comments | « tools/dartium/buildbot_annotated_steps.py ('k') | 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 datetime 9 import datetime
10 import json 10 import json
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 return ('%s.%s.%s.%s.%s' % ( 287 return ('%s.%s.%s.%s.%s' % (
288 version.major, version.minor, version.patch, version.prerelease, 288 version.major, version.minor, version.patch, version.prerelease,
289 version.prerelease_patch)) 289 version.prerelease_patch))
290 290
291 def GetSemanticSDKVersion(ignore_svn_revision=False): 291 def GetSemanticSDKVersion(ignore_svn_revision=False):
292 version = ReadVersionFile() 292 version = ReadVersionFile()
293 if not version: 293 if not version:
294 return None 294 return None
295 295
296 if version.channel == 'be': 296 if version.channel == 'be':
297 postfix = '-edge' if ignore_svn_revision else '-edge.%s' % GetSVNRevision() 297 postfix = '-edge' if ignore_svn_revision else '-edge.%s' % GetGitRevision()
298 elif version.channel == 'dev': 298 elif version.channel == 'dev':
299 postfix = '-dev.%s.%s' % (version.prerelease, version.prerelease_patch) 299 postfix = '-dev.%s.%s' % (version.prerelease, version.prerelease_patch)
300 else: 300 else:
301 assert version.channel == 'stable' 301 assert version.channel == 'stable'
302 postfix = '' 302 postfix = ''
303 303
304 return '%s.%s.%s%s' % (version.major, version.minor, version.patch, postfix) 304 return '%s.%s.%s%s' % (version.major, version.minor, version.patch, postfix)
305 305
306 def GetEclipseVersionQualifier():
307 def pad(number, num_digits):
308 number_str = str(number)
309 return '0' * max(0, num_digits - len(number_str)) + number_str
310
311 version = ReadVersionFile()
312 if version.channel == 'be':
313 return 'edge_%s' % pad(GetSVNRevision(), 6)
314 elif version.channel == 'dev':
315 return 'dev_%s_%s' % (pad(version.prerelease, 2),
316 pad(version.prerelease_patch, 2))
317 else:
318 return 'release'
319
320 def GetVersion(): 306 def GetVersion():
321 return GetSemanticSDKVersion() 307 return GetSemanticSDKVersion()
322 308
323
324 # The editor used to produce the VERSION file put on gcs. We now produce this 309 # The editor used to produce the VERSION file put on gcs. We now produce this
325 # in the bots archiving the sdk. 310 # in the bots archiving the sdk.
326 # The content looks like this: 311 # The content looks like this:
327 #{ 312 #{
328 # "date": "2015-05-28", 313 # "date": "2015-05-28",
329 # "version": "1.11.0-edge.131653", 314 # "version": "1.11.0-edge.131653",
330 # "revision": "535394c2657ede445142d8a92486d3899bbf49b5" 315 # "revision": "535394c2657ede445142d8a92486d3899bbf49b5"
331 #} 316 #}
332 def GetVersionFileContent(): 317 def GetVersionFileContent():
333 result = {"date": str(datetime.date.today()), 318 result = {"date": str(datetime.date.today()),
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 prerelease = match_against('^PRERELEASE (\d+)$', content) 353 prerelease = match_against('^PRERELEASE (\d+)$', content)
369 prerelease_patch = match_against('^PRERELEASE_PATCH (\d+)$', content) 354 prerelease_patch = match_against('^PRERELEASE_PATCH (\d+)$', content)
370 355
371 if channel and major and minor and prerelease and prerelease_patch: 356 if channel and major and minor and prerelease and prerelease_patch:
372 return Version( 357 return Version(
373 channel, major, minor, patch, prerelease, prerelease_patch) 358 channel, major, minor, patch, prerelease, prerelease_patch)
374 else: 359 else:
375 print "Warning: VERSION file (%s) has wrong format" % version_file 360 print "Warning: VERSION file (%s) has wrong format" % version_file
376 return None 361 return None
377 362
378 def GetSVNRevision():
379 # When building from tarball use tools/SVN_REVISION
380 svn_revision_file = os.path.join(DART_DIR, 'tools', 'SVN_REVISION')
381 try:
382 with open(svn_revision_file) as fd:
383 return fd.read()
384 except:
385 pass
386
387 # TODO(ricow): Remove all calls to GetSVNRevision.
388 # For now, simply forward call to GetArchiveVersion
389 return GetArchiveVersion();
390 363
391 # Our schema for releases and archiving is based on an increasing 364 # Our schema for releases and archiving is based on an increasing
392 # sequence of numbers. In the svn world this was simply the revision of a 365 # sequence of numbers. In the svn world this was simply the revision of a
393 # commit, which would always give us a one to one mapping between the number 366 # commit, which would always give us a one to one mapping between the number
394 # and the commit. This was true across branches as well, so a number used 367 # and the commit. This was true across branches as well, so a number used
395 # to archive a build was always unique and unambiguous. 368 # to archive a build was always unique and unambiguous.
396 # In git there is no such global number, so we loosen the requirement a bit. 369 # In git there is no such global number, so we loosen the requirement a bit.
397 # We only use numbers on the master branch (bleeding edge). On branches 370 # We only use numbers on the master branch (bleeding edge). On branches
398 # we use the version number instead for archiving purposes. 371 # we use the version number instead for archiving purposes.
399 # The number on master is the count of commits on the master branch. 372 # The number on master is the count of commits on the master branch.
400 def GetArchiveVersion(): 373 def GetArchiveVersion():
401 version = ReadVersionFile() 374 version = ReadVersionFile()
402 if not version: 375 if not version:
403 raise 'Could not get the archive version, parsing the version file failed' 376 raise 'Could not get the archive version, parsing the version file failed'
404 if version.channel == 'be': 377 if version.channel == 'be':
405 return GetGitNumber() 378 return GetGitNumber()
406 return GetSemanticSDKVersion() 379 return GetSemanticSDKVersion()
407 380
408 381
409 def GetGitRevision(): 382 def GetGitRevision():
383 # When building from tarball use tools/GIT_REVISION
384 git_revision_file = os.path.join(DART_DIR, 'tools', 'GIT_REVISION')
385 try:
386 with open(git_revision_file) as fd:
387 return fd.read()
388 except:
389 pass
390
410 p = subprocess.Popen(['git', 'log', '-n', '1', '--pretty=format:%H'], 391 p = subprocess.Popen(['git', 'log', '-n', '1', '--pretty=format:%H'],
411 stdout = subprocess.PIPE, 392 stdout = subprocess.PIPE,
412 stderr = subprocess.STDOUT, shell=IsWindows(), 393 stderr = subprocess.STDOUT, shell=IsWindows(),
413 cwd = DART_DIR) 394 cwd = DART_DIR)
414 output, _ = p.communicate() 395 output, _ = p.communicate()
415 # We expect a full git hash 396 # We expect a full git hash
416 if len(output) != 40: 397 if len(output) != 40:
417 print "Warning: could not parse git commit, output was %s" % output 398 print "Warning: could not parse git commit, output was %s" % output
418 return None 399 return None
419 return output 400 return output
420 401
421 # To eliminate clashing with older archived builds on bleding edge we add 402 # To eliminate clashing with older archived builds on bleeding edge we add
422 # a base number bigger the largest svn revision (this also gives us an easy 403 # a base number bigger the largest svn revision (this also gives us an easy
423 # way of seeing if an archive comes from git based or svn based commits). 404 # way of seeing if an archive comes from git based or svn based commits).
424 GIT_NUMBER_BASE = 100000 405 GIT_NUMBER_BASE = 100000
425 def GetGitNumber(): 406 def GetGitNumber():
426 p = subprocess.Popen(['git', 'rev-list', 'HEAD', '--count'], 407 p = subprocess.Popen(['git', 'rev-list', 'HEAD', '--count'],
427 stdout = subprocess.PIPE, 408 stdout = subprocess.PIPE,
428 stderr = subprocess.STDOUT, shell=IsWindows(), 409 stderr = subprocess.STDOUT, shell=IsWindows(),
429 cwd = DART_DIR) 410 cwd = DART_DIR)
430 output, _ = p.communicate() 411 output, _ = p.communicate()
431 try: 412 try:
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 os.chdir(self._working_directory) 613 os.chdir(self._working_directory)
633 614
634 def __exit__(self, *_): 615 def __exit__(self, *_):
635 print "Enter directory = ", self._old_cwd 616 print "Enter directory = ", self._old_cwd
636 os.chdir(self._old_cwd) 617 os.chdir(self._old_cwd)
637 618
638 619
639 if __name__ == "__main__": 620 if __name__ == "__main__":
640 import sys 621 import sys
641 Main() 622 Main()
OLDNEW
« no previous file with comments | « tools/dartium/buildbot_annotated_steps.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698