]> source.dussan.org Git - gitblit.git/commitdiff
Improve non-visible parent lane rendering for BranchGraphServlet
authorJames Moger <james.moger@gitblit.com>
Wed, 18 Sep 2013 17:00:39 +0000 (13:00 -0400)
committerJames Moger <james.moger@gitblit.com>
Wed, 18 Sep 2013 17:00:39 +0000 (13:00 -0400)
src/main/java/com/gitblit/BranchGraphServlet.java

index 95be61322bddcad59a7610f57f2a5c1ef2ab14ce..f46b8e6f2dde9ce1915331ffc7ffeaa806439d28 100644 (file)
@@ -32,6 +32,8 @@ import java.io.Serializable;
 import java.util.ArrayList;\r
 import java.util.LinkedList;\r
 import java.util.List;\r
+import java.util.Set;\r
+import java.util.TreeSet;\r
 \r
 import javax.imageio.ImageIO;\r
 import javax.servlet.ServletException;\r
@@ -153,11 +155,31 @@ public class BranchGraphServlet extends HttpServlet {
 \r
                        // determine the appropriate width for the image\r
                        int numLanes = 0;\r
-                       int numCommits = Math.min(requestedCommits, commitList.size());                 \r
-                       for (int i = 0; i < numCommits; i++) {\r
+                       int numCommits = Math.min(requestedCommits, commitList.size());\r
+                       Set<String> parents = new TreeSet<String>();\r
+                       for (int i = 0; i < commitList.size(); i++) {\r
                                PlotCommit<Lane> commit = commitList.get(i);\r
-                               int pos = commit.getLane().getPosition();\r
-                               numLanes = Math.max(numLanes, pos + 1);\r
+                               boolean checkLane = false;\r
+                               \r
+                               if (i < numCommits) {\r
+                                       // commit in visible list\r
+                                       checkLane = true;\r
+                                       \r
+                                       // remember parents\r
+                                       for (RevCommit p : commit.getParents()) {\r
+                                               parents.add(p.getName());\r
+                                       }\r
+                               } else if (parents.contains(commit.getName())) {\r
+                                       // commit outside visible list, but it is a parent of a\r
+                                       // commit in the visible list so we need to know it's lane\r
+                                       // assignment\r
+                                       checkLane = true;\r
+                               }\r
+                               \r
+                               if (checkLane) {\r
+                                       int pos = commit.getLane().getPosition();\r
+                                       numLanes = Math.max(numLanes, pos + 1);\r
+                               }\r
                        }\r
 \r
                        int graphWidth = numLanes * LANE_WIDTH + RIGHT_PAD;\r
@@ -170,7 +192,7 @@ public class BranchGraphServlet extends HttpServlet {
                                g = image.createGraphics();\r
                                g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);\r
                                LanesRenderer renderer = new LanesRenderer();\r
-                               for (int i = 0; i < numCommits; i++) {\r
+                               for (int i = 0; i < commitList.size(); i++) {\r
                                        PlotCommit<Lane> commit = commitList.get(i);\r
                                        Graphics row = g.create(0, i*rowHeight, graphWidth, rowHeight);\r
                                        try {\r