[PATCH 2 of 6] graph: draw edges to obsolete changesets as dashed

Andrew Shadura andrew at shadura.me
Tue Jul 28 11:02:38 UTC 2015


# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1404932959 18000
#      Wed Jul 09 14:09:19 2014 -0500
# Node ID 1d08fb9cd850269f7f771e54f3e9496d49fcb102
# Parent  011e77e80ae34ba9a19b8591c78959feee5934b9
graph: draw edges to obsolete changesets as dashed

diff --git a/kallithea/lib/graphmod.py b/kallithea/lib/graphmod.py
--- a/kallithea/lib/graphmod.py
+++ b/kallithea/lib/graphmod.py
@@ -103,6 +103,7 @@ def _colored(repo, dag):
 
     row = []
     colors = {}
+    obs = {}
     newcolor = 1
 
     for (rev, dagparents) in dag:
@@ -111,6 +112,7 @@ def _colored(repo, dag):
         if rev not in row:
             row.append(rev)  # new head
             colors[rev] = newcolor
+            obs[rev] = int(repo[rev].obsolete)
             newcolor += 1
 
         col = row.index(rev)
@@ -126,12 +128,14 @@ def _colored(repo, dag):
                 nextrow.append(r)
             else:
                 colors.pop(r)
+                obs.pop(r)
 
         # Set colors for the parents
         color = colors.pop(rev)
         if addparents:
             b = branch(rev)
             for p in reversed(addparents):
+                obs[p] = int(repo[p].obsolete)
                 if b and branch(abs(p)) == b:
                     colors[p] = color
                     b = None
@@ -143,10 +147,10 @@ def _colored(repo, dag):
         edges = []
         for ecol, ep in enumerate(row):
             if ep in nextrow:
-                edges.append((ecol, nextrow.index(ep), colors[ep]))
+                edges.append((ecol, nextrow.index(ep), colors[ep], obs[ep]))
             elif ep == rev:
                 for p in dagparents:
-                    edges.append((ecol, nextrow.index(p), colors[p]))
+                    edges.append((ecol, nextrow.index(p), colors[p], obs[p]))
 
         # Yield and move on
         closing = int(repo[rev].closesbranch)
diff --git a/kallithea/public/js/graph.js b/kallithea/public/js/graph.js
--- a/kallithea/public/js/graph.js
+++ b/kallithea/public/js/graph.js
@@ -115,6 +115,7 @@ function BranchRenderer(canvas_id, conte
 				start = line[0];
 				end = line[1];
 				color = line[2];
+				obsolete_line = line[3];
 				
 				x = Math.floor(base_x - box_size * start);
 
@@ -159,6 +160,11 @@ function BranchRenderer(canvas_id, conte
 				
 				this.ctx.lineWidth=this.line_width;
 				this.ctx.beginPath();
+				if (obsolete_line)
+				{
+					this.ctx.setLineDash([5]);
+				}
+				this.ctx.beginPath();
 				this.ctx.moveTo(x, rowY);
 				if (start == end)
 				{
@@ -168,9 +174,14 @@ function BranchRenderer(canvas_id, conte
 				{
 					var x2 = Math.floor(base_x - box_size * end);
 					var ymid = (rowY+nextY) / 2;
+					if (obsolete_node)
+					{
+						this.ctx.setLineDash([5]);
+					}
 					this.ctx.bezierCurveTo (x,ymid,x2,ymid,x2,nextY);
 				}
 				this.ctx.stroke();
+				this.ctx.setLineDash([]); // reset the dashed line, if any
 			}
 			
 			column = node[0];


More information about the kallithea-general mailing list