Posted to tcl by hypnotoad at Thu Dec 03 15:53:52 GMT 2015view pretty

proc fossil_dbfile {module} {
  if {[info exists ::fossil_dbfile($module)]} {
     return $::fossil_dbfile($module)
  }
  set ::fossil_dbfile($module) $file
  return $file
}

set scriptfile  [file join [pwd] [info script]]
set tclsrcroot [file dirname [file dirname $scriptfile]]
set fossilRepoPath [file join $tclsrcroot .. fossil]


foreach line [split [exec fossil all list] \n] {
   set module [file rootname [file tail $file]]
   set fossil_dbfile($module) $line
}

foreach {module url branch} {
  thread http://core.tcl.tk/thread trunk
} {
   set fossdb [fossil_dbfile $module]
   if {![file exists $fossdb]} {
     fossil clone $url $fossdb
   }
   set srcpath [file join $tclsourceroot pkgs $module]]
   if {![file exists $srcpath]} {
      file mkdir $srcpath
      cd $srcpath
      exec fossil open $fossdb $branch
   } else {
      exec fossil update $branch
   }
}