diff mercurial/templates/static/mercurial.js @ 16130:33f702e52906

graph: in hgrc specify line color for main branch You can specify color to visually distinguish main branch (trunk) on hgweb's graph page. If color specified, all branch heads will share same color. Settings format is branch_name.color = value, where color is six hexadecimal digits e.g.: [graph] default.color = FF0000
author Constantine Linnick <theaspect@gmail.com>
date Sun, 22 Jan 2012 19:47:03 +0700
parents 5e50982c633c
children 8fd18eb8aab7
line wrap: on
line diff
--- a/mercurial/templates/static/mercurial.js	Sun Jan 22 19:35:26 2012 +0700
+++ b/mercurial/templates/static/mercurial.js	Sun Jan 22 19:47:03 2012 +0700
@@ -58,19 +58,25 @@
 		
 		// Set the colour.
 		//
-		// Picks a distinct colour based on an internal wheel; the bg
+		// If color is hex string "FFFFFF" then append sharp and apply as is 
+		// If color is number
+		// picks a distinct colour based on an internal wheel; the bg
 		// parameter provides the value that should be assigned to the 'zero'
 		// colours and the fg parameter provides the multiplier that should be
 		// applied to the foreground colours.
-		
-		color %= colors.length;
-		var red = (colors[color][0] * fg) || bg;
-		var green = (colors[color][1] * fg) || bg;
-		var blue = (colors[color][2] * fg) || bg;
-		red = Math.round(red * 255);
-		green = Math.round(green * 255);
-		blue = Math.round(blue * 255);
-		var s = 'rgb(' + red + ', ' + green + ', ' + blue + ')';
+		var s;
+		if(typeof color == "string"){
+			s = "#"+color;
+		}else{ //typeof color == "number"
+			color %= colors.length;
+			var red = (colors[color][0] * fg) || bg;
+			var green = (colors[color][1] * fg) || bg;
+			var blue = (colors[color][2] * fg) || bg;
+			red = Math.round(red * 255);
+			green = Math.round(green * 255);
+			blue = Math.round(blue * 255);
+			s = 'rgb(' + red + ', ' + green + ', ' + blue + ')';
+		}
 		this.ctx.strokeStyle = s;
 		this.ctx.fillStyle = s;
 		return s;
@@ -116,6 +122,10 @@
 				if(line[3] && line[3]['width']){
 					this.ctx.lineWidth = line[3]['width'];
 				}
+				// Color if exists
+				if(line[3] && line[3]['color']){
+					color = line[3]['color'];
+				}
 				this.edge(x0, y0, x1, y1, color);
 				this.ctx.lineWidth = 1;
 			}