hgk: Display branch name for each head (issue 740)
authorMichael Sommerville <msommerville@gmail.com>
Mon, 15 Sep 2008 23:39:11 +0100
changeset 7039 aafe12bd7174
parent 7034 0d513661d6c2
child 7040 f29b674cc221
hgk: Display branch name for each head (issue 740) In the graphical view, each head is decorated with an additonal tag containing the branch name, if that head is not on the default branch.
contrib/hgk
--- a/contrib/hgk	Sat Sep 13 10:46:47 2008 -0500
+++ b/contrib/hgk	Mon Sep 15 23:39:11 2008 +0100
@@ -370,6 +370,25 @@
 	lappend tagids($direct) $tag
 	lappend idtags($tag) $direct
     }
+
+    set status [catch {exec $env(HG) --config ui.report_untrusted=false heads} heads]
+    if { $status != 0 } {
+        puts $::errorInfo
+        if { ![string equal $::errorCode NONE] } {
+            exit 2
+        }
+    }
+    regsub -all "\r\n" $heads "\n" heads
+
+    set lines [split $heads "\n"]
+    foreach f $lines {
+        set match ""
+        regexp {changeset:\s+(\S+):(\S+)$} $f match id sha
+        if {$match != ""} {
+        lappend idheads($sha) $id
+        }
+    }
+
 }
 
 proc readotherrefs {base dname excl} {
@@ -1045,7 +1064,7 @@
 }
 
 proc drawtags {id x xt y1} {
-    global idtags idheads idotherrefs
+    global idtags idheads idotherrefs commitinfo
     global linespc lthickness
     global canv mainfont idline rowtextx
 
@@ -1057,8 +1076,11 @@
 	set ntags [llength $marks]
     }
     if {[info exists idheads($id)]} {
-	set marks [concat $marks $idheads($id)]
-	set nheads [llength $idheads($id)]
+	set headmark [lindex $commitinfo($id) 7]
+	if {$headmark ne "default"} {
+	    lappend marks $headmark
+	    set nheads 1
+	}
     }
     if {[info exists idotherrefs($id)]} {
 	set marks [concat $marks $idotherrefs($id)]