Commit f5e001bd8cc76fb104a2e7c6e1ac4f6d0c2e8bf0
1 parent
26606aa2
Exists in
master
and in
4 other branches
Using arrowed line only if it connects to not first parent.
It is easy to see which branch is merged.
Showing
1 changed file
with
44 additions
and
43 deletions
Show diff stats
app/assets/javascripts/branch-graph.js.coffee
| @@ -191,57 +191,58 @@ class BranchGraph | @@ -191,57 +191,58 @@ class BranchGraph | ||
| 191 | 191 | ||
| 192 | drawLines: (x, y, commit) -> | 192 | drawLines: (x, y, commit) -> |
| 193 | r = @r | 193 | r = @r |
| 194 | - for parent in commit.parents | 194 | + for parent, i in commit.parents |
| 195 | parentCommit = @preparedCommits[parent[0]] | 195 | parentCommit = @preparedCommits[parent[0]] |
| 196 | parentY = @offsetY + @unitTime * parentCommit.time | 196 | parentY = @offsetY + @unitTime * parentCommit.time |
| 197 | parentX1 = @offsetX + @unitSpace * (@mspace - parentCommit.space) | 197 | parentX1 = @offsetX + @unitSpace * (@mspace - parentCommit.space) |
| 198 | parentX2 = @offsetX + @unitSpace * (@mspace - parent[1]) | 198 | parentX2 = @offsetX + @unitSpace * (@mspace - parent[1]) |
| 199 | 199 | ||
| 200 | - if parentCommit.space is commit.space and parentCommit.space is parent[1] | ||
| 201 | - r.path(["M", x, y, "L", parentX1, parentY]).attr( | ||
| 202 | - stroke: @colors[parentCommit.space] | ||
| 203 | - "stroke-width": 2 | ||
| 204 | - ) | 200 | + # Set line color |
| 201 | + if parentCommit.space <= commit.space | ||
| 202 | + color = @colors[commit.space] | ||
| 203 | + | ||
| 204 | + else | ||
| 205 | + color = @colors[parentCommit.space] | ||
| 206 | + | ||
| 207 | + # Build line shape | ||
| 208 | + if parent[1] is commit.space | ||
| 209 | + d1 = [0, 5] | ||
| 210 | + d2 = [0, 10] | ||
| 211 | + arrow = "l-2,5,4,0,-2,-5" | ||
| 205 | 212 | ||
| 206 | - else if parentCommit.space < commit.space | ||
| 207 | - if x is parentX2 | ||
| 208 | - r | ||
| 209 | - .path([ | ||
| 210 | - "M", x, y + 5, | ||
| 211 | - "l-2,5,4,0,-2,-5", | ||
| 212 | - "L", x, y + 10, | ||
| 213 | - "L", parentX2, y + 10, | ||
| 214 | - "L", parentX2, parentY - 5, | ||
| 215 | - "L", parentX1, parentY]) | ||
| 216 | - .attr( | ||
| 217 | - stroke: @colors[commit.space] | ||
| 218 | - "stroke-width": 2) | ||
| 219 | - | ||
| 220 | - else | ||
| 221 | - r | ||
| 222 | - .path([ | ||
| 223 | - "M", x + 3, y + 3, | ||
| 224 | - "l5,0,-2,4,-3,-4", | ||
| 225 | - "L", x + 7, y + 5, | ||
| 226 | - "L", parentX2, y + 10, | ||
| 227 | - "L", parentX2, parentY - 5, | ||
| 228 | - "L", parentX1, parentY]) | ||
| 229 | - .attr( | ||
| 230 | - stroke: @colors[commit.space] | ||
| 231 | - "stroke-width": 2) | 213 | + else if parent[1] < commit.space |
| 214 | + d1 = [3, 3] | ||
| 215 | + d2 = [7, 5] | ||
| 216 | + arrow = "l5,0,-2,4,-3,-4" | ||
| 232 | 217 | ||
| 233 | else | 218 | else |
| 234 | - r | ||
| 235 | - .path([ | ||
| 236 | - "M", x - 3, y + 3, | ||
| 237 | - "l-5,0,2,4,3,-4", | ||
| 238 | - "L", x - 7, y + 5, | ||
| 239 | - "L", parentX2, y + 10, | ||
| 240 | - "L", parentX2, parentY - 5, | ||
| 241 | - "L", parentX1, parentY]) | ||
| 242 | - .attr( | ||
| 243 | - stroke: @colors[parentCommit.space] | ||
| 244 | - "stroke-width": 2) | 219 | + d1 = [-3, 3] |
| 220 | + d2 = [-7, 5] | ||
| 221 | + arrow = "l-5,0,2,4,3,-4" | ||
| 222 | + | ||
| 223 | + # Start point | ||
| 224 | + route = ["M", x + d1[0], y + d1[1]] | ||
| 225 | + | ||
| 226 | + # Add arrow if not first parent | ||
| 227 | + if i > 0 | ||
| 228 | + route.push(arrow) | ||
| 229 | + | ||
| 230 | + # Circumvent if overlap | ||
| 231 | + if commit.space isnt parentCommit.space or commit.space isnt parent[1] | ||
| 232 | + route.push( | ||
| 233 | + "L", x + d2[0], y + d2[1], | ||
| 234 | + "L", parentX2, y + 10, | ||
| 235 | + "L", parentX2, parentY - 5, | ||
| 236 | + ) | ||
| 237 | + | ||
| 238 | + # End point | ||
| 239 | + route.push("L", parentX1, parentY) | ||
| 240 | + | ||
| 241 | + r | ||
| 242 | + .path(route) | ||
| 243 | + .attr( | ||
| 244 | + stroke: color | ||
| 245 | + "stroke-width": 2) | ||
| 245 | 246 | ||
| 246 | markCommit: (x, y, commit, graphHeight) -> | 247 | markCommit: (x, y, commit, graphHeight) -> |
| 247 | if commit.id is @options.commit_id | 248 | if commit.id is @options.commit_id |