1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-02-01 03:57:15 +00:00

Change the way commits are indexed for revision graph (#42762).

The original curve design made it difficult to identify which commits were connected, when several commits existed between the connected ones on the branches.

Now, connections between commits on different branches are more easily recognizable in typical scenarios.
The new curves connect from the left or right side to commit that already have vertical connections, and from the top or bottom to the last or first commit on a branch, respectively.

<pre>
|   |    | |    |
* /-*    * *    *-\
| | |    | |    | |
*-/ *    *-/    * *
|   |    |      | |
</pre>

Patch by Leonid Murin (user:murin).


git-svn-id: https://svn.redmine.org/redmine/trunk@24258 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA 2026-01-05 03:52:14 +00:00
parent fc9d1145be
commit 29bad5d405
2 changed files with 41 additions and 6 deletions

View File

@ -63,26 +63,52 @@ function drawRevisionGraph(holder, commits_hash, graph_space) {
fill: colors[commit.space],
stroke: 'none'
}).toFront();
// paths to parents
$.each(commit.parent_scmids, function(index, parent_scmid) {
parent_commit = commits_by_scmid[parent_scmid];
// check for parents in the same column
let noVerticalParents = true;
$.each(commit.parent_scmids, function (index, parentScmid) {
parent_commit = commits_by_scmid[parentScmid];
if (parent_commit) {
if (!parent_commit.hasOwnProperty("space"))
parent_commit.space = 0;
// has parent in the same column on this page
if (parent_commit.space === commit.space)
noVerticalParents = false;
} else {
// has parent in the same column on the other page
noVerticalParents = false;
}
});
// paths to parents
$.each(commit.parent_scmids, function(index, parent_scmid) {
parent_commit = commits_by_scmid[parent_scmid];
if (parent_commit) {
parent_y = yForRow(max_rdmid - parent_commit.rdmid);
parent_x = graph_x_offset + XSTEP / 2 + XSTEP * parent_commit.space;
if (parent_commit.space == commit.space) {
const controlPointDelta = (parent_y - y) / 8;
if (parent_commit.space === commit.space) {
// vertical path
path = revisionGraph.path([
'M', x, y,
'V', parent_y]);
} else if (noVerticalParents) {
// branch start (Bezier curve)
path = revisionGraph.path([
'M', x, y,
'C', x, y + controlPointDelta, x, parent_y - controlPointDelta, parent_x, parent_y]);
} else if (!parent_commit.hasOwnProperty('vertical_children')) {
// branch end (Bezier curve)
path = revisionGraph.path([
'M', x, y,
'C', parent_x, y + controlPointDelta, parent_x, parent_y, parent_x, parent_y]);
} else {
// path to a commit in a different branch (Bezier curve)
path = revisionGraph.path([
'M', x, y,
'C', x, y, x, y + (parent_y - y) / 2, x + (parent_x - x) / 2, y + (parent_y - y) / 2,
'C', x + (parent_x - x) / 2, y + (parent_y - y) / 2, parent_x, parent_y-(parent_y-y)/2, parent_x, parent_y]);
'C', parent_x, y, x, parent_y, parent_x, parent_y]);
}
} else {
// vertical path ending at the bottom of the revisionGraph

View File

@ -310,6 +310,15 @@ module RepositoriesHelper
while (commit = commits.find { |commit| commits_by_scmid[commit.scmid][:space].nil? })
space = index_head(space + 1, commit, commits_by_scmid)
end
# Set vertical_children flag for commits that have children in the same column
# for S-style connections between commits
commits_by_scmid.each_value do |commit|
commit[:parent_scmids].each do |scmid|
if (parent = commits_by_scmid[scmid]) && parent[:space] == commit[:space]
parent[:vertical_children] = true
end
end
end
return commits_by_scmid, space
end