Project

General

Profile

Patch #42762 » v1_01_fix_revision_graph.patch

Leonid Murin, 2025-05-22 13:06

View differences:

app/helpers/repositories_helper.rb
300 300
    heads.sort_by!(&:to_s)
301 301
    space = nil
302 302
    heads.each do |head|
303
      if commits_by_scmid.include? head.scmid
303
      if commits_by_scmid.include?(head.scmid) && commits_by_scmid[head.scmid][:space].nil?
304 304
        space = index_head((space || -1) + 1, head, commits_by_scmid)
305 305
      end
306 306
    end
307
- 
app/helpers/repositories_helper.rb
298 298
      }
299 299
    end
300 300
    heads.sort_by!(&:to_s)
301
    space = nil
301
    # Process commits starting from the latest
302
    space = index_head(0, commits.first, commits_by_scmid)
303
    # Process commits from heads
302 304
    heads.each do |head|
303 305
      if commits_by_scmid.include?(head.scmid) && commits_by_scmid[head.scmid][:space].nil?
304
        space = index_head((space || -1) + 1, head, commits_by_scmid)
306
        space = index_head(space + 1, head, commits_by_scmid)
305 307
      end
306 308
    end
307
    # when no head matched anything use first commit
308
    space ||= index_head(0, commits.first, commits_by_scmid)
309
    # Process orphan commits
310
    while (commit = commits.find { |commit| commits_by_scmid[commit.scmid][:space].nil? })
311
      space = index_head(space + 1, commit, commits_by_scmid)
312
    end
309 313
    return commits_by_scmid, space
310 314
  end
311 315

  
312
- 
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

  
316
- 
(10-10/10)