comparison contrib/hgk @ 4740:e1d1b22bab57

Use "--config ui.report_untrusted=false" for hg calls in hgk, fixes issue523. tcl's exec yields an error if output to stderr happens and isn't redirected to a file, so the warnings about untrusted .hg/hgrc caused problems in hgk. The warning is still printed when executing 'hg view', so the user can see it when using it from the shell.
author Thomas Arendsen Hein <thomas@intevation.de>
date Sun, 01 Jul 2007 15:22:49 +0200
parents 39001f4b7d99
children 4a84f7421692
comparison
equal deleted inserted replaced
4739:1da35d1e7ef9 4740:e1d1b22bab57
41 lappend revargs $opt 41 lappend revargs $opt
42 } 42 }
43 } 43 }
44 if [catch { 44 if [catch {
45 set parse_args [concat --default HEAD $revargs] 45 set parse_args [concat --default HEAD $revargs]
46 set parse_temp [eval exec {$env(HG)} debug-rev-parse $parse_args] 46 set parse_temp [eval exec {$env(HG)} --config ui.report_untrusted=false debug-rev-parse $parse_args]
47 regsub -all "\r\n" $parse_temp "\n" parse_temp 47 regsub -all "\r\n" $parse_temp "\n" parse_temp
48 set parsed_args [split $parse_temp "\n"] 48 set parsed_args [split $parse_temp "\n"]
49 } err] { 49 } err] {
50 # if git-rev-parse failed for some reason... 50 # if git-rev-parse failed for some reason...
51 if {$rargs == {}} { 51 if {$rargs == {}} {
55 } 55 }
56 if {$limit > 0} { 56 if {$limit > 0} {
57 set parsed_args [concat -n $limit $parsed_args] 57 set parsed_args [concat -n $limit $parsed_args]
58 } 58 }
59 if [catch { 59 if [catch {
60 set commfd [open "|{$env(HG)} debug-rev-list --header --topo-order --parents $parsed_args" r] 60 set commfd [open "|{$env(HG)} --config ui.report_untrusted=false debug-rev-list --header --topo-order --parents $parsed_args" r]
61 } err] { 61 } err] {
62 puts stderr "Error executing hg debug-rev-list: $err" 62 puts stderr "Error executing hg debug-rev-list: $err"
63 exit 1 63 exit 1
64 } 64 }
65 set leftover {} 65 set leftover {}
178 } 178 }
179 } 179 }
180 180
181 proc readcommit {id} { 181 proc readcommit {id} {
182 global env 182 global env
183 if [catch {set contents [exec $env(HG) debug-cat-file commit $id]}] return 183 if [catch {set contents [exec $env(HG) --config ui.report_untrusted=false debug-cat-file commit $id]}] return
184 parsecommit $id $contents 0 {} 184 parsecommit $id $contents 0 {}
185 } 185 }
186 186
187 proc parsecommit {id contents listed olds} { 187 proc parsecommit {id contents listed olds} {
188 global commitinfo children nchildren parents nparents cdate ncleft 188 global commitinfo children nchildren parents nparents cdate ncleft
259 } 259 }
260 260
261 proc readrefs {} { 261 proc readrefs {} {
262 global tagids idtags headids idheads tagcontents env 262 global tagids idtags headids idheads tagcontents env
263 263
264 set tags [exec $env(HG) tags] 264 set tags [exec $env(HG) --config ui.report_untrusted=false tags]
265 regsub -all "\r\n" $tags "\n" tags 265 regsub -all "\r\n" $tags "\n" tags
266 set lines [split $tags "\n"] 266 set lines [split $tags "\n"]
267 foreach f $lines { 267 foreach f $lines {
268 regexp {(\S+)$} $f full 268 regexp {(\S+)$} $f full
269 regsub {\s+(\S+)$} $f "" direct 269 regsub {\s+(\S+)$} $f "" direct
1732 } 1732 }
1733 append inputids $lineid($l) "\n" 1733 append inputids $lineid($l) "\n"
1734 } 1734 }
1735 1735
1736 if {[catch { 1736 if {[catch {
1737 set f [open [list | $env(HG) debug-diff-tree --stdin -s -r -S$findstring \ 1737 set f [open [list | $env(HG) --config ui.report_untrusted=false debug-diff-tree --stdin -s -r -S$findstring << $inputids] r]
1738 << $inputids] r]
1739 } err]} { 1738 } err]} {
1740 error_popup "Error starting search process: $err" 1739 error_popup "Error starting search process: $err"
1741 return 1740 return
1742 } 1741 }
1743 1742
1836 } 1835 }
1837 1836
1838 # start off a git-diff-tree process if needed 1837 # start off a git-diff-tree process if needed
1839 if {$diffsneeded ne {}} { 1838 if {$diffsneeded ne {}} {
1840 if {[catch { 1839 if {[catch {
1841 set df [open [list | $env(HG) debug-diff-tree -r --stdin << $diffsneeded] r] 1840 set df [open [list | $env(HG) --config ui.report_untrusted=false debug-diff-tree -r --stdin << $diffsneeded] r]
1842 } err ]} { 1841 } err ]} {
1843 error_popup "Error starting search process: $err" 1842 error_popup "Error starting search process: $err"
1844 return 1843 return
1845 } 1844 }
1846 catch {unset fdiffids} 1845 catch {unset fdiffids}
2260 foreach id $ids { 2259 foreach id $ids {
2261 if {$gca eq {}} { 2260 if {$gca eq {}} {
2262 set gca $id 2261 set gca $id
2263 } else { 2262 } else {
2264 if {[catch { 2263 if {[catch {
2265 set gca [exec $env(HG) debug-merge-base $gca $id] 2264 set gca [exec $env(HG) --config ui.report_untrusted=false debug-merge-base $gca $id]
2266 } err]} { 2265 } err]} {
2267 return {} 2266 return {}
2268 } 2267 }
2269 } 2268 }
2270 } 2269 }
2349 catch {unset filelines} 2348 catch {unset filelines}
2350 catch {unset groupfilenum} 2349 catch {unset groupfilenum}
2351 catch {unset grouphunks} 2350 catch {unset grouphunks}
2352 set groupfilelast -1 2351 set groupfilelast -1
2353 foreach p $parents($diffmergeid) { 2352 foreach p $parents($diffmergeid) {
2354 set cmd [list | $env(HG) debug-diff-tree -p $p $diffmergeid] 2353 set cmd [list | $env(HG) --config ui.report_untrusted=false debug-diff-tree -p $p $diffmergeid]
2355 set cmd [concat $cmd $mergefilelist($diffmergeid)] 2354 set cmd [concat $cmd $mergefilelist($diffmergeid)]
2356 if {[catch {set f [open $cmd r]} err]} { 2355 if {[catch {set f [open $cmd r]} err]} {
2357 error_popup "Error getting diffs: $err" 2356 error_popup "Error getting diffs: $err"
2358 foreach f $flist { 2357 foreach f $flist {
2359 catch {close $f} 2358 catch {close $f}
2793 global treediff parents treepending env 2792 global treediff parents treepending env
2794 set treepending $ids 2793 set treepending $ids
2795 set treediff {} 2794 set treediff {}
2796 set id [lindex $ids 0] 2795 set id [lindex $ids 0]
2797 set p [lindex $ids 1] 2796 set p [lindex $ids 1]
2798 if [catch {set gdtf [open "|{$env(HG)} debug-diff-tree -r $p $id" r]}] return 2797 if [catch {set gdtf [open "|{$env(HG)} --config ui.report_untrusted=false debug-diff-tree -r $p $id" r]}] return
2799 fconfigure $gdtf -blocking 0 2798 fconfigure $gdtf -blocking 0
2800 fileevent $gdtf readable [list gettreediffline $gdtf $ids] 2799 fileevent $gdtf readable [list gettreediffline $gdtf $ids]
2801 } 2800 }
2802 2801
2803 proc gettreediffline {gdtf ids} { 2802 proc gettreediffline {gdtf ids} {
2829 global difffilestart nextupdate diffinhdr treediffs 2828 global difffilestart nextupdate diffinhdr treediffs
2830 2829
2831 set id [lindex $ids 0] 2830 set id [lindex $ids 0]
2832 set p [lindex $ids 1] 2831 set p [lindex $ids 1]
2833 set env(GIT_DIFF_OPTS) $diffopts 2832 set env(GIT_DIFF_OPTS) $diffopts
2834 set cmd [list | $env(HG) debug-diff-tree -r -p -C $p $id] 2833 set cmd [list | $env(HG) --config ui.report_untrusted=false debug-diff-tree -r -p -C $p $id]
2835 if {[catch {set bdf [open $cmd r]} err]} { 2834 if {[catch {set bdf [open $cmd r]} err]} {
2836 puts "error getting diffs: $err" 2835 puts "error getting diffs: $err"
2837 return 2836 return
2838 } 2837 }
2839 set diffinhdr 0 2838 set diffinhdr 0
3417 global patchtop env 3416 global patchtop env
3418 3417
3419 set oldid [$patchtop.fromsha1 get] 3418 set oldid [$patchtop.fromsha1 get]
3420 set newid [$patchtop.tosha1 get] 3419 set newid [$patchtop.tosha1 get]
3421 set fname [$patchtop.fname get] 3420 set fname [$patchtop.fname get]
3422 if {[catch {exec $env(HG) debug-diff-tree -p $oldid $newid >$fname &} err]} { 3421 if {[catch {exec $env(HG) --config ui.report_untrusted=false debug-diff-tree -p $oldid $newid >$fname &} err]} {
3423 error_popup "Error creating patch: $err" 3422 error_popup "Error creating patch: $err"
3424 } 3423 }
3425 catch {destroy $patchtop} 3424 catch {destroy $patchtop}
3426 unset patchtop 3425 unset patchtop
3427 } 3426 }
3476 if {[info exists tagids($tag)]} { 3475 if {[info exists tagids($tag)]} {
3477 error_popup "Tag \"$tag\" already exists" 3476 error_popup "Tag \"$tag\" already exists"
3478 return 3477 return
3479 } 3478 }
3480 if {[catch { 3479 if {[catch {
3481 set out [exec $env(HG) tag -r $id $tag] 3480 set out [exec $env(HG) --config ui.report_untrusted=false tag -r $id $tag]
3482 } err]} { 3481 } err]} {
3483 error_popup "Error creating tag: $err" 3482 error_popup "Error creating tag: $err"
3484 return 3483 return
3485 } 3484 }
3486 3485
3638 3637
3639 # defaults... 3638 # defaults...
3640 set datemode 0 3639 set datemode 0
3641 set boldnames 0 3640 set boldnames 0
3642 set diffopts "-U 5 -p" 3641 set diffopts "-U 5 -p"
3643 set wrcomcmd "\"\$HG\" debug-diff-tree --stdin -p --pretty" 3642 set wrcomcmd "\"\$HG\" --config ui.report_untrusted=false debug-diff-tree --stdin -p --pretty"
3644 3643
3645 set mainfont {Helvetica 9} 3644 set mainfont {Helvetica 9}
3646 set textfont {Courier 9} 3645 set textfont {Courier 9}
3647 set findmergefiles 0 3646 set findmergefiles 0
3648 set gaudydiff 0 3647 set gaudydiff 0