Project

General

Profile

Patch #42762 » 0003-Change-the-shape-of-curves-connecting-commits-across.patch

Go MAEDA, 2025-12-25 11:13

View differences:

app/assets/javascripts/revision_graph.js
63 63
                fill: colors[commit.space],
64 64
                stroke: 'none'
65 65
            }).toFront();
66
        // paths to parents
67
        $.each(commit.parent_scmids, function(index, parent_scmid) {
68
            parent_commit = commits_by_scmid[parent_scmid];
66

  
67
        // check for parents in the same column
68
        let noVerticalParents = true;
69
        $.each(commit.parent_scmids, function (index, parentScmid) {
70
            parent_commit = commits_by_scmid[parentScmid];
69 71
            if (parent_commit) {
70 72
                if (!parent_commit.hasOwnProperty("space"))
71 73
                    parent_commit.space = 0;
72 74

  
75
                // has parent in the same column on this page
76
                if (parent_commit.space === commit.space)
77
                    noVerticalParents = false;
78
            } else {
79
                // has parent in the same column on the other page
80
                noVerticalParents = false;
81
            }
82
        });
83

  
84
        // paths to parents
85
        $.each(commit.parent_scmids, function(index, parent_scmid) {
86
            parent_commit = commits_by_scmid[parent_scmid];
87
            if (parent_commit) {
73 88
                parent_y = yForRow(max_rdmid - parent_commit.rdmid);
74 89
                parent_x = graph_x_offset + XSTEP / 2 + XSTEP * parent_commit.space;
75
                if (parent_commit.space == commit.space) {
90
                const controlPointDelta = (parent_y - y) / 8;
91

  
92
                if (parent_commit.space === commit.space) {
76 93
                    // vertical path
77 94
                    path = revisionGraph.path([
78 95
                        'M', x, y,
79 96
                        'V', parent_y]);
97
                } else if (noVerticalParents) {
98
                    // branch start (Bezier curve)
99
                    path = revisionGraph.path([
100
                        'M', x, y,
101
                        'C', x, y + controlPointDelta, x, parent_y - controlPointDelta, parent_x, parent_y]);
102
                } else if (!parent_commit.hasOwnProperty('vertical_children')) {
103
                    // branch end (Bezier curve)
104
                    path = revisionGraph.path([
105
                        'M', x, y,
106
                        'C', parent_x, y + controlPointDelta, parent_x, parent_y, parent_x, parent_y]);
80 107
                } else {
81 108
                    // path to a commit in a different branch (Bezier curve)
82 109
                    path = revisionGraph.path([
83 110
                        'M', x, y,
84
                        'C', x, y, x, y + (parent_y - y) / 2, x + (parent_x - x) / 2, y + (parent_y - y) / 2,
85
                        'C', x + (parent_x - x) / 2, y + (parent_y - y) / 2, parent_x, parent_y-(parent_y-y)/2, parent_x, parent_y]);
111
                        'C', parent_x, y, x, parent_y, parent_x, parent_y]);
86 112
                }
87 113
            } else {
88 114
                // vertical path ending at the bottom of the revisionGraph
app/helpers/repositories_helper.rb
310 310
    while (commit = commits.find { |commit| commits_by_scmid[commit.scmid][:space].nil? })
311 311
      space = index_head(space + 1, commit, commits_by_scmid)
312 312
    end
313
    # Set vertical_children flag for commits that have children in the same column
314
    # for S-style connections between commits
315
    commits_by_scmid.each_value do |commit|
316
      commit[:parent_scmids].each do |scmid|
317
        if (parent = commits_by_scmid[scmid]) && parent[:space] == commit[:space]
318
          parent[:vertical_children] = true
319
        end
320
      end
321
    end
313 322
    return commits_by_scmid, space
314 323
  end
315 324

  
(14-14/18)