[PATCH] hgk: Display branch name for each head (issue 740)

Michael Sommerville msommerville at gmail.com
Mon Sep 15 17:45:49 CDT 2008


# HG changeset patch
# User Michael Sommerville <msommerville at gmail.com>
# Date 1221518351 -3600
# Node ID aafe12bd7174141f0c4c04cfb3ec146249cdbbd4
# Parent  0d513661d6c280fae68a96aea16231702959bfb6
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.

diff -r 0d513661d6c2 -r aafe12bd7174 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)]


More information about the Mercurial-devel mailing list