@@ -952,21 +952,17 @@ def clone(self, url, path, depth=None, protocol=None, **kwargs):
952
952
cache = self .get_cache (url )
953
953
954
954
# Try to clone with cache ref first
955
- if cache :
955
+ if cache and not os .path .isdir (path ):
956
+ log ("Trying to use cached repository in \" %s\" for \" %s\" " % (cache , path ))
956
957
try :
957
- if not os .path .isdir (path ):
958
- if not os .path .isdir (os .path .split (path )[0 ]):
959
- os .makedirs (os .path .split (path )[0 ])
960
- shutil .copytree (cache , path )
961
-
962
- try :
963
- with cd (path ):
964
- scm .update (None , True )
965
- main = False
966
- except ProcessException :
967
- if os .path .exists (path ):
968
- rmtree_readonly (path )
969
- except ProcessException , e :
958
+ if os .path .split (path )[0 ] and not os .path .isdir (os .path .split (path )[0 ]):
959
+ os .makedirs (os .path .split (path )[0 ])
960
+ shutil .copytree (cache , path )
961
+
962
+ with cd (path ):
963
+ scm .update (None , True )
964
+ main = False
965
+ except (ProcessException , IOError ):
970
966
if os .path .isdir (path ):
971
967
rmtree_readonly (path )
972
968
@@ -1208,11 +1204,12 @@ def add_tools(self, path):
1208
1204
if not os .path .exists (tools_dir ):
1209
1205
try :
1210
1206
action ("Couldn't find build tools in your program. Downloading the mbed SDK tools..." )
1211
- Hg .clone (mbed_sdk_tools_url , tools_dir )
1207
+ repo = Repo .fromurl (mbed_sdk_tools_url )
1208
+ repo .clone (mbed_sdk_tools_url , tools_dir )
1212
1209
except :
1213
1210
if os .path .exists (tools_dir ):
1214
1211
rmtree_readonly (tools_dir )
1215
- raise Exception ( 128 , "An error occurred while cloning the mbed SDK tools from \" %s\" " % mbed_sdk_tools_url )
1212
+ error ( "An error occurred while cloning the mbed SDK tools from \" %s\" " % mbed_sdk_tools_url )
1216
1213
1217
1214
def get_tools (self ):
1218
1215
mbed_tools_path = self .get_tools_dir ()
0 commit comments