Browse Source

better support for gnu vs bsdutils tar on windows. fossil help stripansi

master
Julian Noble 2 months ago
parent
commit
7b7c9322f9
  1. 39
      src/modules/punk/mix/base-0.1.tm
  2. 34
      src/modules/punk/repo-999999.0a1.0.tm

39
src/modules/punk/mix/base-0.1.tm

@ -677,7 +677,7 @@ namespace eval punk::mix::base {
if {$opt_use_tar != 0} {
set target [file tail $path]
set tmplocation [punk::mix::util::tmpdir]
set archivename $tmplocation/[punk::mix::util::tmpfile].tar
set archivename $tmplocation/[punk::mix::util::tmpfile].tar ;#generates a unique filename - does not create the file.
cd $base ;#cd is process-wide.. keep cd in effect for as small a scope as possible. (review for thread issues)
@ -687,14 +687,38 @@ namespace eval punk::mix::base {
set tsstart [clock millis]
if {[set tarpath [auto_execok tar]] ne ""} {
#using an external binary is *significantly* faster than tar::create - but comes with some risks
#review - need to check behaviour/flag variances across platforms
set versioninfo [exec {*}$tarpath --version]
#look for "bsdtar" vs "GNU"
#GNU tar is more common on linux - but also available on windows via gnuutils or msys
#<system32>/tar.exe on windows is likely to be bsdtar.
#GNU tar on windows will commonly fail with 'cannot connect to C: resolve failed' - may need --force-local flag
#review - need to further check behaviour/flag variances across platforms
#don't use -z flag. On at least some tar versions the zipped file will contain a timestamped subfolder of filename.tar - which ruins the checksum
#also - tar is generally faster without the compression (although this may vary depending on file size and disk speed?)
exec {*}$tarpath -cf $archivename $target ;#{*} needed in case spaces in tarpath
set tsend [clock millis]
set ms [expr {$tsend - $tsstart}]
puts stdout " tar -cf done ($ms ms)"
} else {
if {[string match "*GNU*" $versioninfo]} {
set flags "--force-local"
} else {
#presumably bsdtar - which is more likely to be present on windows - and doesn't seem to have the same issue with drive letters in paths
set flags ""
}
if {[catch {
#{*}$tarpath needed in case spaces in tarpath
exec {*}$tarpath -cf {*}$flags $archivename $target
} errMsg]} {
set tsend [clock millis]
set ms [expr {$tsend - $tsstart}]
puts stdout " 'tar -cf $flags' ERROR ($ms ms) - falling back to tar::create\n error info: $errMsg"
} else {
set tsend [clock millis]
set ms [expr {$tsend - $tsstart}]
puts stdout " 'tar -cf $flags' done ($ms ms)"
}
}
if {![file exists $archivename]} {
#fallback to tar library approach if external tar failed to create the archive.
set tsstart [clock millis] ;#don't include auto_exec search time for tar::create
tar::create $archivename $target
set tsend [clock millis]
@ -703,6 +727,7 @@ namespace eval punk::mix::base {
puts stdout " NOTE: install tar executable for potentially *much* faster directory checksum processing"
}
if {$ftype eq "file"} {
set sizeinfo "(size [punk::lib::format_number [file size $target]] bytes)"
} else {

34
src/modules/punk/repo-999999.0a1.0.tm

@ -83,34 +83,38 @@ namespace eval punk::repo {
proc get_fossil_usage {} {
set allcmds [runout -n fossil help -a]
set allcmds [punk::ansi::ansistrip $allcmds]
set mainhelp [runout -n fossil help]
set mainhelp [punk::ansi::ansistrip $mainhelp]
set maincommands [list]
#only start parsing for TOPICS after a line such as "Other comman values for TOPIC:"
set parsing_topics 0
foreach ln [split $mainhelp \n] {
set ln [string trim $ln]
if {$ln eq ""} {
continue
}
if {[string match "*values for TOPIC*" $ln]} {
set parsing_topics 1
if {$ln eq ""} {
continue
}
if {[string match "*values for TOPIC*" $ln]} {
set parsing_topics 1
continue
}
if {$parsing_topics} {
#lines starting with uppercase are topic headers - we want to ignore these and any blank lines
if {[regexp {^[A-Z]+} $ln]} {
continue
}
if {$parsing_topics} {
#lines starting with uppercase are topic headers - we want to ignore these and any blank lines
if {[regexp {^[A-Z]+} $ln]} {
continue
}
lappend maincommands {*}$ln
}
lappend maincommands {*}$ln
}
}
#fossil output was ordered in columns, but we loaded list in row-wise, messing up the order
set maincommands [lsort $maincommands]
set allcmds [lsort $allcmds]
set othercmds [punk::lib::ldiff $allcmds $maincommands]
set fossil_setting_names [lsort [runout -n fossil help -s]]
set setting_info [runout -n fossil help -s]
set setting_info [punk::ansi::ansistrip $setting_info]
set fossil_setting_names [lsort $setting_info]
set result "@leaders -min 0\n"
@ -186,6 +190,8 @@ namespace eval punk::repo {
foreach ln $basic_opt_lines {
set ln [string trim $ln]
#fossil sometimes emits cursor control sequences e.g CSI 3 q
set ln [punk::ansi::ansistrip $ln]
if {$ln eq ""} {
continue
}
@ -250,6 +256,7 @@ namespace eval punk::repo {
${[punk::repo::get_fossil_subcommand_usage add]}
@form -form "raw" -synopsis "exec fossil add \[OPTIONS\] FILE1 \[FILE2\]..."
#fossil help may have ansi - review
@formdisplay -header "fossil help add" -body {${[runout -n fossil help add]}}
} ""]
@ -264,6 +271,7 @@ namespace eval punk::repo {
${[punk::repo::get_fossil_subcommand_usage diff]}
@form -form "raw" -synopsis "exec fossil diff \[OPTIONS\] FILE1 \[FILE2\]..."
#fossil help may have ansi - review
@formdisplay -header "fossil help diff" -body {${[runout -n fossil help diff]}}
} ""]

Loading…
Cancel
Save