@@ -607,21 +607,24 @@ def cleanup():
607
607
for branch in branches : # delete all local branches so the new repo clone is not poluted
608
608
pquery ([git_cmd , 'branch' , '-D' , branch ])
609
609
610
- def clone (url , name = None , depth = None , protocol = None ):
611
- if depth :
610
+ def clone (url , path , rev = None , depth = None , protocol = None , name = None ):
611
+ result = pquery ([git_cmd , "ls-remote" , url , (rev if rev else "HEAD" )])
612
+
613
+ if result :
612
614
repo_name = url .split ('/' )[- 1 ]
613
615
if '.git' in repo_name :
614
616
repo_name = repo_name [:- 4 ]
615
617
616
618
os .mkdir (repo_name )
617
-
619
+
618
620
with cd (repo_name ):
619
621
Git .init ()
620
- Git .fetch (url = url , branch = 'latest' , depth = depth )
622
+ Git .fetch (url = url , rev = rev , depth = depth )
621
623
Git .checkout ('FETCH_HEAD' )
622
624
popen ([git_cmd , 'remote' , 'add' , 'origin' , url ])
625
+
623
626
else :
624
- popen ([git_cmd , 'clone' , formaturl (url , protocol ), name ] + (['-v' ] if very_verbose else ([] if verbose else ['-q' ])))
627
+ popen ([git_cmd , 'clone' , formaturl (url , protocol ), path ] + (['-v' ] if very_verbose else ([] if verbose else ['-q' ])))
625
628
626
629
def add (dest ):
627
630
info ("Adding reference " + dest )
@@ -655,9 +658,9 @@ def publish(all_refs=None):
655
658
if not branch :
656
659
error (err + "Working set is not on a branch." , 1 )
657
660
658
- def fetch (url = None , branch = None , depth = None ):
661
+ def fetch (url = None , rev = None , depth = None ):
659
662
info ("Fetching revisions from remote repository to \" %s\" " % os .path .basename (os .getcwd ()))
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' ])))
663
+ popen ([git_cmd , 'fetch' , '--tags' ] + ([url ] if url else []) + ([rev ] if rev else ['--all' ]) + (['--depth' , depth ] if depth else []) + (['-v' ] if very_verbose else ([] if verbose else ['-q' ])))
661
664
662
665
def discard (clean_files = False ):
663
666
info ("Discarding local changes in \" %s\" " % os .path .basename (os .getcwd ()))
@@ -1111,7 +1114,7 @@ def clone(self, url, path, rev=None, depth=None, protocol=None, **kwargs):
1111
1114
# Main clone routine if the clone with cache ref failed (might occur if cache ref is dirty)
1112
1115
if main :
1113
1116
try :
1114
- scm .clone (url , path , depth = depth , protocol = protocol , ** kwargs )
1117
+ scm .clone (url , path , rev = rev , depth = depth , protocol = protocol , ** kwargs )
1115
1118
except ProcessException :
1116
1119
if os .path .isdir (path ):
1117
1120
rmtree_readonly (path )
@@ -1816,18 +1819,17 @@ def import_(url, path=None, ignore=False, depth=None, protocol=None, top=True):
1816
1819
else :
1817
1820
error (err , 1 )
1818
1821
1819
- action ("Syncing repo." );
1820
- #repo.sync()
1822
+ repo .sync ()
1821
1823
1822
1824
if top : # This helps sub-commands to display relative paths to the imported program
1823
1825
cwd_root = repo .path
1824
1826
1825
- # with cd(repo.path):
1826
- # deploy(ignore=ignore, depth=depth, protocol=protocol, top=False)
1827
+ with cd (repo .path ):
1828
+ deploy (ignore = ignore , depth = depth , protocol = protocol , top = False )
1827
1829
1828
1830
if top :
1829
1831
action ("Post action." );
1830
- # Program(repo.path).post_action()
1832
+ Program (repo .path ).post_action ()
1831
1833
1832
1834
1833
1835
# Add library command
0 commit comments