@ -86,7 +86,16 @@ def determine_scm(root):
return None
return None
def only_int ( val ) :
if val . isdigit ( ) :
return int ( val )
else :
return 0
class GIT ( object ) :
class GIT ( object ) :
current_version = None
@staticmethod
@staticmethod
def Capture ( args , * * kwargs ) :
def Capture ( args , * * kwargs ) :
return subprocess2 . check_output (
return subprocess2 . check_output (
@ -370,23 +379,19 @@ class GIT(object):
root = GIT . Capture ( [ ' rev-parse ' , ' --show-cdup ' ] , cwd = cwd ) . strip ( )
root = GIT . Capture ( [ ' rev-parse ' , ' --show-cdup ' ] , cwd = cwd ) . strip ( )
return os . path . abspath ( os . path . join ( cwd , root ) )
return os . path . abspath ( os . path . join ( cwd , root ) )
@ static method
@ class method
def AssertVersion ( min_version ) :
def AssertVersion ( cls , min_version ) :
""" Asserts git ' s version is at least min_version. """
""" Asserts git ' s version is at least min_version. """
def only_int ( val ) :
if cls . current_version is None :
if val . isdigit ( ) :
cls . current_version = cls . Capture ( [ ' --version ' ] ) . split ( ) [ - 1 ]
return int ( val )
current_version_list = map ( only_int , cls . current_version . split ( ' . ' ) )
else :
return 0
current_version = GIT . Capture ( [ ' --version ' ] ) . split ( ) [ - 1 ]
current_version_list = map ( only_int , current_version . split ( ' . ' ) )
for min_ver in map ( int , min_version . split ( ' . ' ) ) :
for min_ver in map ( int , min_version . split ( ' . ' ) ) :
ver = current_version_list . pop ( 0 )
ver = current_version_list . pop ( 0 )
if ver < min_ver :
if ver < min_ver :
return ( False , current_version )
return ( False , cls . current_version )
elif ver > min_ver :
elif ver > min_ver :
return ( True , current_version )
return ( True , cls . current_version )
return ( True , current_version )
return ( True , cls . current_version )
class SVN ( object ) :
class SVN ( object ) :
@ -924,24 +929,19 @@ class SVN(object):
directory = parent
directory = parent
return GetCasedPath ( directory )
return GetCasedPath ( directory )
@ static method
@ class method
def AssertVersion ( min_version ) :
def AssertVersion ( cls , min_version ) :
""" Asserts svn ' s version is at least min_version. """
""" Asserts svn ' s version is at least min_version. """
def only_int ( val ) :
if cls . current_version is None :
if val . isdigit ( ) :
cls . current_version = cls . Capture ( [ ' --version ' ] ) . split ( ) [ 2 ]
return int ( val )
current_version_list = map ( only_int , cls . current_version . split ( ' . ' ) )
else :
return 0
if not SVN . current_version :
SVN . current_version = SVN . Capture ( [ ' --version ' ] ) . split ( ) [ 2 ]
current_version_list = map ( only_int , SVN . current_version . split ( ' . ' ) )
for min_ver in map ( int , min_version . split ( ' . ' ) ) :
for min_ver in map ( int , min_version . split ( ' . ' ) ) :
ver = current_version_list . pop ( 0 )
ver = current_version_list . pop ( 0 )
if ver < min_ver :
if ver < min_ver :
return ( False , SVN . current_version )
return ( False , cls . current_version )
elif ver > min_ver :
elif ver > min_ver :
return ( True , SVN . current_version )
return ( True , cls . current_version )
return ( True , SVN . current_version )
return ( True , cls . current_version )
@staticmethod
@staticmethod
def Revert ( repo_root , callback = None , ignore_externals = False ) :
def Revert ( repo_root , callback = None , ignore_externals = False ) :