comparison contrib/hgk @ 13461:81af2040b586 stable

hgk: read bookmarks
author David Soria Parra <dsp@php.net>
date Wed, 23 Feb 2011 00:24:21 +0100
parents d11405848abd
children 8641cb094c81
comparison
equal deleted inserted replaced
13460:64bb8e586a92 13461:81af2040b586
274 set audate {} 274 set audate {}
275 set comname {} 275 set comname {}
276 set comdate {} 276 set comdate {}
277 set rev {} 277 set rev {}
278 set branch {} 278 set branch {}
279 set bookmark {}
279 if {![info exists nchildren($id)]} { 280 if {![info exists nchildren($id)]} {
280 set children($id) {} 281 set children($id) {}
281 set nchildren($id) 0 282 set nchildren($id) 0
282 set ncleft($id) 0 283 set ncleft($id) 0
283 } 284 }
312 set comname [join [lrange $line 1 [expr {$x - 1}]]] 313 set comname [join [lrange $line 1 [expr {$x - 1}]]]
313 } elseif {$tag == "revision"} { 314 } elseif {$tag == "revision"} {
314 set rev [lindex $line 1] 315 set rev [lindex $line 1]
315 } elseif {$tag == "branch"} { 316 } elseif {$tag == "branch"} {
316 set branch [join [lrange $line 1 end]] 317 set branch [join [lrange $line 1 end]]
317 } 318 } elseif {$tag == "bookmark"} {
319 set bookmark [join [lrange $line 1 end]]
320 }
318 } 321 }
319 } else { 322 } else {
320 if {$comment == {}} { 323 if {$comment == {}} {
321 set headline [string trim $line] 324 set headline [string trim $line]
322 } else { 325 } else {
336 if {$comdate != {}} { 339 if {$comdate != {}} {
337 set cdate($id) $comdate 340 set cdate($id) $comdate
338 set comdate [clock format $comdate -format "%Y-%m-%d %H:%M:%S"] 341 set comdate [clock format $comdate -format "%Y-%m-%d %H:%M:%S"]
339 } 342 }
340 set commitinfo($id) [list $headline $auname $audate \ 343 set commitinfo($id) [list $headline $auname $audate \
341 $comname $comdate $comment $rev $branch] 344 $comname $comdate $comment $rev $branch $bookmark]
342 345
343 if {[info exists firstparents]} { 346 if {[info exists firstparents]} {
344 set i [lsearch $firstparents $id] 347 set i [lsearch $firstparents $id]
345 if {$i != -1} { 348 if {$i != -1} {
346 # remove the parent from firstparents, possible building 349 # remove the parent from firstparents, possible building
367 } 370 }
368 } 371 }
369 } 372 }
370 373
371 proc readrefs {} { 374 proc readrefs {} {
372 global tagids idtags headids idheads tagcontents env curid 375 global bookmarkcurrent bookmarkids tagids idtags idbookmarks headids idheads tagcontents env curid
373 376
374 set status [catch {exec $env(HG) --config ui.report_untrusted=false id} curid] 377 set status [catch {exec $env(HG) --config ui.report_untrusted=false id} curid]
375 if { $status != 0 } { 378 if { $status != 0 } {
376 puts $::errorInfo 379 puts $::errorInfo
377 if { ![string equal $::errorCode NONE] } { 380 if { ![string equal $::errorCode NONE] } {
415 if {$match != ""} { 418 if {$match != ""} {
416 lappend idheads($sha) $id 419 lappend idheads($sha) $id
417 } 420 }
418 } 421 }
419 422
423 set status [catch {exec $env(HG) --config ui.report_untrusted=false bookmarks} bookmarks]
424 if { $status != 0 } {
425 puts $::errorInfo
426 if { ![string equal $::errorCode NONE] } {
427 exit 2
428 }
429 }
430 set lines [split $bookmarks "\n"]
431 set bookmarkcurrent 0
432 foreach f $lines {
433 regexp {(\S+)$} $f full
434 regsub {\s+(\S+)$} $f "" direct
435 set sha [split $full ':']
436 set bookmark [lindex $sha 1]
437 set current [string first " * " $direct)]
438 regsub {^\s(\*|\s)\s} $direct "" direct
439 lappend bookmarkids($direct) $bookmark
440 lappend idbookmarks($bookmark) $direct
441 if {$current >= 0} {
442 set bookmarkcurrent $direct
443 }
444 }
420 } 445 }
421 446
422 proc readotherrefs {base dname excl} { 447 proc readotherrefs {base dname excl} {
423 global otherrefids idotherrefs 448 global otherrefids idotherrefs
424 449
1040 proc drawcommitline {level} { 1065 proc drawcommitline {level} {
1041 global parents children nparents displist 1066 global parents children nparents displist
1042 global canv canv2 canv3 mainfont namefont canvy linespc 1067 global canv canv2 canv3 mainfont namefont canvy linespc
1043 global lineid linehtag linentag linedtag commitinfo 1068 global lineid linehtag linentag linedtag commitinfo
1044 global colormap numcommits currentparents dupparents 1069 global colormap numcommits currentparents dupparents
1045 global idtags idline idheads idotherrefs 1070 global idtags idline idheads idotherrefs idbookmarks
1046 global lineno lthickness mainline mainlinearrow sidelines 1071 global lineno lthickness mainline mainlinearrow sidelines
1047 global commitlisted rowtextx idpos lastuse displist 1072 global commitlisted rowtextx idpos lastuse displist
1048 global oldnlines olddlevel olddisplist 1073 global oldnlines olddlevel olddisplist
1049 global aucolormap curid curidfont 1074 global aucolormap curid curidfont
1050 1075
1098 set xt [expr {$xt + ([llength $currentparents] - 2) * $linespc}] 1123 set xt [expr {$xt + ([llength $currentparents] - 2) * $linespc}]
1099 } 1124 }
1100 set rowtextx($lineno) $xt 1125 set rowtextx($lineno) $xt
1101 set idpos($id) [list $x $xt $y1] 1126 set idpos($id) [list $x $xt $y1]
1102 if {[info exists idtags($id)] || [info exists idheads($id)] 1127 if {[info exists idtags($id)] || [info exists idheads($id)]
1103 || [info exists idotherrefs($id)]} { 1128 || [info exists idotherrefs($id)] || [info exists idbookmarks($id)]} {
1104 set xt [drawtags $id $x $xt $y1] 1129 set xt [drawtags $id $x $xt $y1]
1105 } 1130 }
1106 set headline [lindex $commitinfo($id) 0] 1131 set headline [lindex $commitinfo($id) 0]
1107 set name [lindex $commitinfo($id) 1] 1132 set name [lindex $commitinfo($id) 1]
1108 assignauthorcolor $name 1133 assignauthorcolor $name
3838 catch {destroy $wrcomtop} 3863 catch {destroy $wrcomtop}
3839 unset wrcomtop 3864 unset wrcomtop
3840 } 3865 }
3841 3866
3842 proc listrefs {id} { 3867 proc listrefs {id} {
3843 global idtags idheads idotherrefs 3868 global idtags idheads idotherrefs idbookmarks
3844 3869
3870 set w {}
3871 if {[info exists idbookmarks($id)]} {
3872 set w $idbookmarks($id)
3873 }
3845 set x {} 3874 set x {}
3846 if {[info exists idtags($id)]} { 3875 if {[info exists idtags($id)]} {
3847 set x $idtags($id) 3876 set x $idtags($id)
3848 } 3877 }
3849 set y {} 3878 set y {}
3852 } 3881 }
3853 set z {} 3882 set z {}
3854 if {[info exists idotherrefs($id)]} { 3883 if {[info exists idotherrefs($id)]} {
3855 set z $idotherrefs($id) 3884 set z $idotherrefs($id)
3856 } 3885 }
3857 return [list $x $y $z] 3886 return [list $w $x $y $z]
3858 } 3887 }
3859 3888
3860 proc rereadrefs {} { 3889 proc rereadrefs {} {
3861 global idtags idheads idotherrefs 3890 global idbookmarks idtags idheads idotherrefs
3862 global tagids headids otherrefids 3891 global bookmarkids tagids headids otherrefids
3863 3892
3864 set refids [concat [array names idtags] \ 3893 set refids [concat [array names idtags] \
3865 [array names idheads] [array names idotherrefs]] 3894 [array names idheads] [array names idotherrefs] \
3895 [array names idbookmarks]]
3866 foreach id $refids { 3896 foreach id $refids {
3867 if {![info exists ref($id)]} { 3897 if {![info exists ref($id)]} {
3868 set ref($id) [listrefs $id] 3898 set ref($id) [listrefs $id]
3869 } 3899 }
3870 } 3900 }
3871 foreach v {tagids idtags headids idheads otherrefids idotherrefs} { 3901 foreach v {tagids idtags headids idheads otherrefids idotherrefs \
3902 bookmarkids idbookmarks} {
3872 catch {unset $v} 3903 catch {unset $v}
3873 } 3904 }
3874 readrefs 3905 readrefs
3875 set refids [lsort -unique [concat $refids [array names idtags] \ 3906 set refids [lsort -unique [concat $refids [array names idtags] \
3876 [array names idheads] [array names idotherrefs]]] 3907 [array names idheads] [array names idotherrefs] \
3908 [array names idbookmarks]]]
3877 foreach id $refids { 3909 foreach id $refids {
3878 set v [listrefs $id] 3910 set v [listrefs $id]
3879 if {![info exists ref($id)] || $ref($id) != $v} { 3911 if {![info exists ref($id)] || $ref($id) != $v} {
3880 redrawtags $id 3912 redrawtags $id
3881 } 3913 }