@ -3,11 +3,12 @@
# Use of this source code is governed by a BSD-style license that can be
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# found in the LICENSE file.
import collections
import datetime
import datetime
import json
import optparse
import optparse
import os
import os
import re
import re
import string
import sys
import sys
import urllib2
import urllib2
import urlparse
import urlparse
@ -375,60 +376,50 @@ def getAllFilesInRevision(files_info):
def getBranchForMilestone ( milestone ) :
def getBranchForMilestone ( milestone ) :
""" Queries omahaproxy.appspot.com for the branch number given |milestone|.
""" Queries omahaproxy.appspot.com for the branch number given |milestone|.
"""
"""
OMAHA_PROXY_URL = " http://omahaproxy.appspot.com/all?csv=1 "
OMAHA_PROXY_URL = " https://omahaproxy.appspot.com/all?json=1 "
request = urllib2 . Request ( OMAHA_PROXY_URL )
try :
try :
response = urllib2 . urlopen ( request )
response = urllib2 . urlopen ( OMAHA_PROXY_URL )
except urllib2 . HTTPError , e :
except urllib2 . HTTPError , e :
print " Failed to query %s : %d " % ( OMAHA_PROXY_URL , e . code )
print " Failed to query %s : %d " % ( OMAHA_PROXY_URL , e . code )
return None
return None
# Dictionary of [branch: major]. When searching for the appropriate branch
# Response is in the form of:
# matching |milestone|, all major versions that match are added to the
# [{ os: "os_name", versions: [{ channel: "canary", true_branch: "1490" }] }]
# dictionary. If all of the branches are the same, this branch value is
os_versions = json . load ( response )
# returned; otherwise, the user is prompted to accept the largest branch
# value.
branches = collections . defaultdict ( list )
branch_dict = { }
for os_version in os_versions :
for version in os_version [ ' versions ' ] :
# Slice the first line since it's column information text.
if not version [ ' true_branch ' ] or not version [ ' version ' ] :
for line in response . readlines ( ) [ 1 : ] :
continue
# Version data is CSV.
branch = version [ ' true_branch ' ]
parameters = string . split ( line , ' , ' )
mstone = version [ ' version ' ] . split ( ' . ' )
if not branch [ 0 ] . isdigit ( ) or mstone [ 0 ] != str ( milestone ) :
# Version is the third parameter and consists of a quad of numbers separated
continue
# by periods.
branches [ branch ] + = [ os_version [ ' os ' ] ]
version = string . split ( parameters [ 2 ] , ' . ' )
major = int ( version [ 0 ] , 10 )
if not branches :
if major != milestone :
continue
# Branch number is the third value in the quad.
branch_dict [ version [ 2 ] ] = major
if not branch_dict :
# |milestone| not found.
print " Milestone provided is invalid "
return None
return None
# The following returns a sorted list of the keys of |branch_dict|.
if len ( branches ) == 1 :
sorted_branches = sorted ( branch_dict )
return branches . keys ( ) [ 0 ]
branch = sorted_branches [ - 1 ]
# If all keys match, the branch is the same for all platforms given
choices = ( ' -( %s ): %s ' % ( b , ' , ' . join ( o ) ) for b , o in branches . iteritems ( ) )
# |milestone|. This is the safe case, so return the branch.
print >> sys . stderr , ( " \n Not all platforms have same branch number for M %d . \n "
if len ( sorted_branches ) == 1 :
" \n Here ' s a list of platforms on each branch: \n "
return branch
" %s " ) % ( milestone , ' \n ' . join ( choices ) )
# Not all of the platforms have the same branch. Prompt the user and return
errors = 0
# the greatest (by value) branch on success.
while errors < 3 :
if prompt ( " Not all platforms have the same branch number, "
user_input = raw_input ( " Which branch? ( ' q ' to cancel) " ) . strip ( ) . lower ( )
" continue with branch %s ? " % branch ) :
if user_input in branches :
return branch
return user_input
if user_input . startswith ( ' q ' ) :
break
errors + = 1
# User cancelled.
return None
return None
def getSVNAuthInfo ( folder = None ) :
def getSVNAuthInfo ( folder = None ) :
""" Fetches SVN authorization information in the subversion auth folder and
""" Fetches SVN authorization information in the subversion auth folder and
returns it as a dictionary of dictionaries . """
returns it as a dictionary of dictionaries . """