@@ -608,7 +608,20 @@ def cleanup():
608608 pquery ([git_cmd , 'branch' , '-D' , branch ])
609609
610610 def clone (url , name = None , depth = None , protocol = None ):
611- popen ([git_cmd , 'clone' , formaturl (url , protocol ), name ] + (['--depth' , depth ] if depth else []) + (['-v' ] if very_verbose else ([] if verbose else ['-q' ])))
611+ if depth :
612+ repo_name = url .split ('/' )[- 1 ]
613+ if '.git' in repo_name :
614+ repo_name = repo_name [:- 4 ]
615+
616+ os .mkdir (repo_name )
617+
618+ with cd (repo_name ):
619+ Git .init ()
620+ Git .fetch (url = url , branch = 'latest' , depth = depth )
621+ Git .checkout ('FETCH_HEAD' )
622+ popen ([git_cmd , 'remote' , 'add' , 'origin' , url ])
623+ else :
624+ popen ([git_cmd , 'clone' , formaturl (url , protocol ), name ] + (['-v' ] if very_verbose else ([] if verbose else ['-q' ])))
612625
613626 def add (dest ):
614627 info ("Adding reference " + dest )
@@ -642,9 +655,9 @@ def publish(all_refs=None):
642655 if not branch :
643656 error (err + "Working set is not on a branch." , 1 )
644657
645- def fetch ():
658+ def fetch (url = None , branch = None , depth = None ):
646659 info ("Fetching revisions from remote repository to \" %s\" " % os .path .basename (os .getcwd ()))
647- popen ([git_cmd , 'fetch' , '--all' , '--tags' ] + (['-v' ] if very_verbose else ([] if verbose else ['-q' ])))
660+ popen ([git_cmd , 'fetch' , '--tags' ] + ([ url ] if url else []) + ([ branch ] if branch else [ '-- all']) + ([ '--depth' , depth ] if depth else []) + (['-v' ] if very_verbose else ([] if verbose else ['-q' ])))
648661
649662 def discard (clean_files = False ):
650663 info ("Discarding local changes in \" %s\" " % os .path .basename (os .getcwd ()))
@@ -1724,11 +1737,13 @@ def new(name, scm='git', program=False, library=False, mbedlib=False, create_onl
17241737 p .path = cwd_root
17251738 p .set_root ()
17261739 if not create_only and not p .get_os_dir () and not p .get_mbedlib_dir ():
1727- url = mbed_lib_url if mbedlib else mbed_os_url + '#latest'
1740+ url = mbed_lib_url if mbedlib else mbed_os_url + "#latest"
1741+ print (url )
17281742 d = 'mbed' if mbedlib else 'mbed-os'
17291743 try :
17301744 with cd (d_path ):
17311745 add (url , depth = depth , protocol = protocol , top = False )
1746+
17321747 except Exception as e :
17331748 if os .path .isdir (os .path .join (d_path , d )):
17341749 rmtree_readonly (os .path .join (d_path , d ))
@@ -1784,7 +1799,7 @@ def import_(url, path=None, ignore=False, depth=None, protocol=None, top=True):
17841799 with cd (repo .path ):
17851800 Program (repo .path ).set_root ()
17861801 try :
1787- if repo .rev and repo .getrev () != repo .rev :
1802+ if repo .rev and repo .getrev () != repo .rev and not depth :
17881803 repo .checkout (repo .rev , True )
17891804 except ProcessException as e :
17901805 err = "Unable to update \" %s\" to %s" % (repo .name , repo .revtype (repo .rev , True ))
@@ -1800,17 +1815,19 @@ def import_(url, path=None, ignore=False, depth=None, protocol=None, top=True):
18001815 warning (err )
18011816 else :
18021817 error (err , 1 )
1803-
1804- repo .sync ()
1818+
1819+ action ("Syncing repo." );
1820+ #repo.sync()
18051821
18061822 if top : # This helps sub-commands to display relative paths to the imported program
18071823 cwd_root = repo .path
18081824
1809- with cd (repo .path ):
1810- deploy (ignore = ignore , depth = depth , protocol = protocol , top = False )
1825+ # with cd(repo.path):
1826+ # deploy(ignore=ignore, depth=depth, protocol=protocol, top=False)
18111827
18121828 if top :
1813- Program (repo .path ).post_action ()
1829+ action ("Post action." );
1830+ #Program(repo.path).post_action()
18141831
18151832
18161833# Add library command
@@ -1836,8 +1853,8 @@ def add(url, path=None, ignore=False, depth=None, protocol=None, top=True):
18361853 lib .write ()
18371854 repo .add (lib .lib )
18381855
1839- if top :
1840- Program (repo .path ).post_action ()
1856+ # if top:
1857+ # Program(repo.path).post_action()
18411858
18421859
18431860# Remove library
0 commit comments