Mercurial > hg-stable
changeset 13461:81af2040b586 stable
hgk: read bookmarks
author | David Soria Parra <dsp@php.net> |
---|---|
date | Wed, 23 Feb 2011 00:24:21 +0100 |
parents | 64bb8e586a92 |
children | 8641cb094c81 |
files | contrib/hgk |
diffstat | 1 files changed, 45 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/hgk Tue Feb 22 15:11:10 2011 -0500 +++ b/contrib/hgk Wed Feb 23 00:24:21 2011 +0100 @@ -276,6 +276,7 @@ set comdate {} set rev {} set branch {} + set bookmark {} if {![info exists nchildren($id)]} { set children($id) {} set nchildren($id) 0 @@ -314,7 +315,9 @@ set rev [lindex $line 1] } elseif {$tag == "branch"} { set branch [join [lrange $line 1 end]] - } + } elseif {$tag == "bookmark"} { + set bookmark [join [lrange $line 1 end]] + } } } else { if {$comment == {}} { @@ -338,7 +341,7 @@ set comdate [clock format $comdate -format "%Y-%m-%d %H:%M:%S"] } set commitinfo($id) [list $headline $auname $audate \ - $comname $comdate $comment $rev $branch] + $comname $comdate $comment $rev $branch $bookmark] if {[info exists firstparents]} { set i [lsearch $firstparents $id] @@ -369,7 +372,7 @@ } proc readrefs {} { - global tagids idtags headids idheads tagcontents env curid + global bookmarkcurrent bookmarkids tagids idtags idbookmarks headids idheads tagcontents env curid set status [catch {exec $env(HG) --config ui.report_untrusted=false id} curid] if { $status != 0 } { @@ -417,6 +420,28 @@ } } + set status [catch {exec $env(HG) --config ui.report_untrusted=false bookmarks} bookmarks] + if { $status != 0 } { + puts $::errorInfo + if { ![string equal $::errorCode NONE] } { + exit 2 + } + } + set lines [split $bookmarks "\n"] + set bookmarkcurrent 0 + foreach f $lines { + regexp {(\S+)$} $f full + regsub {\s+(\S+)$} $f "" direct + set sha [split $full ':'] + set bookmark [lindex $sha 1] + set current [string first " * " $direct)] + regsub {^\s(\*|\s)\s} $direct "" direct + lappend bookmarkids($direct) $bookmark + lappend idbookmarks($bookmark) $direct + if {$current >= 0} { + set bookmarkcurrent $direct + } + } } proc readotherrefs {base dname excl} { @@ -1042,7 +1067,7 @@ global canv canv2 canv3 mainfont namefont canvy linespc global lineid linehtag linentag linedtag commitinfo global colormap numcommits currentparents dupparents - global idtags idline idheads idotherrefs + global idtags idline idheads idotherrefs idbookmarks global lineno lthickness mainline mainlinearrow sidelines global commitlisted rowtextx idpos lastuse displist global oldnlines olddlevel olddisplist @@ -1100,7 +1125,7 @@ set rowtextx($lineno) $xt set idpos($id) [list $x $xt $y1] if {[info exists idtags($id)] || [info exists idheads($id)] - || [info exists idotherrefs($id)]} { + || [info exists idotherrefs($id)] || [info exists idbookmarks($id)]} { set xt [drawtags $id $x $xt $y1] } set headline [lindex $commitinfo($id) 0] @@ -3840,8 +3865,12 @@ } proc listrefs {id} { - global idtags idheads idotherrefs - + global idtags idheads idotherrefs idbookmarks + + set w {} + if {[info exists idbookmarks($id)]} { + set w $idbookmarks($id) + } set x {} if {[info exists idtags($id)]} { set x $idtags($id) @@ -3854,26 +3883,29 @@ if {[info exists idotherrefs($id)]} { set z $idotherrefs($id) } - return [list $x $y $z] + return [list $w $x $y $z] } proc rereadrefs {} { - global idtags idheads idotherrefs - global tagids headids otherrefids + global idbookmarks idtags idheads idotherrefs + global bookmarkids tagids headids otherrefids set refids [concat [array names idtags] \ - [array names idheads] [array names idotherrefs]] + [array names idheads] [array names idotherrefs] \ + [array names idbookmarks]] foreach id $refids { if {![info exists ref($id)]} { set ref($id) [listrefs $id] } } - foreach v {tagids idtags headids idheads otherrefids idotherrefs} { + foreach v {tagids idtags headids idheads otherrefids idotherrefs \ + bookmarkids idbookmarks} { catch {unset $v} } readrefs set refids [lsort -unique [concat $refids [array names idtags] \ - [array names idheads] [array names idotherrefs]]] + [array names idheads] [array names idotherrefs] \ + [array names idbookmarks]]] foreach id $refids { set v [listrefs $id] if {![info exists ref($id)] || $ref($id) != $v} {