Ticket #29093: portfetch.tcl.3.diff

File portfetch.tcl.3.diff, 2.5 KB (added by ci42, 14 years ago)

use command_exec for git.fetch and hg.fetch

  • portfetch.tcl

    old new  
    6161commands bzr
    6262commands cvs
    6363commands svn
     64commands git
     65commands hg
    6466
    6567# Defaults
    6668default extract.suffix .tar.gz
     
    9799
    98100default git.cmd {[findBinary git $portutil::autoconf::git_path]}
    99101default git.dir {${workpath}}
    100 default git.branch {}
     102default git.branch {HEAD}
     103default git.pre_args ""
     104default git.args ""
     105default git.post_args {"${git.url} ${distname}"}
    101106
    102107default hg.cmd {[findBinary hg $portutil::autoconf::hg_path]}
    103108default hg.dir {${workpath}}
    104109default hg.tag {tip}
     110default hg.args {"clone --rev ${hg.tag} ${hg.url} ${workpath}/${distname}"}
    105111
    106112# Set distfiles
    107113default distfiles {[portfetch::suffix $distname]}
     
    369375
    370376# Perform a git fetch
    371377proc portfetch::gitfetch {args} {
    372     global worksrcpath
    373     global git.url git.branch git.sha1 git.cmd
     378    global distname
     379    global git.dir git.args git.post_args git.branch
    374380
    375     set options "-q"
    376     if {[string length ${git.branch}] == 0} {
    377         # if we're just using HEAD, we can make a shallow repo
    378         set options "$options --depth=1"
    379     }
    380     set cmdstring "${git.cmd} clone $options ${git.url} ${worksrcpath} 2>&1"
    381     ui_debug "Executing: $cmdstring"
    382     if {[catch {system $cmdstring} result]} {
     381    set git.args "clone -q -n"
     382    if {[catch {command_exec git "" "2>&1"} result]} {
    383383        return -code error [msgcat::mc "Git clone failed"]
    384384    }
    385385
    386     if {[string length ${git.branch}] > 0} {
    387         set env "GIT_DIR=${worksrcpath}/.git GIT_WORK_TREE=${worksrcpath}"
    388         set cmdstring "$env ${git.cmd} checkout -q ${git.branch} 2>&1"
    389         ui_debug "Executing $cmdstring"
    390         if {[catch {system $cmdstring} result]} {
    391             return -code error [msgcat::mc "Git checkout failed"]
    392         }
     386    set git.dir ${git.dir}/${distname}
     387    set git.args "checkout -q -b ${git.branch}"
     388    set git.post_args ""
     389    if {[catch {command_exec git "" "2>&1"} result]} {
     390        return -code error [msgcat::mc "Git checkout failed"]
    393391    }
    394392
    395393    if {[info exists patchfiles]} {
     
    401399
    402400# Perform a mercurial fetch.
    403401proc portfetch::hgfetch {args} {
    404     global worksrcpath prefix_frozen
    405     global hg.url hg.tag hg.cmd
    406 
    407     set cmdstring "${hg.cmd} clone --rev ${hg.tag} ${hg.url} ${worksrcpath} 2>&1"
    408     ui_debug "Executing: $cmdstring"
    409     if {[catch {system $cmdstring} result]} {
     402    if {[catch {command_exec hg "" "2>&1"} result]} {
    410403        return -code error [msgcat::mc "Mercurial clone failed"]
    411404    }
    412405