Fossil SCM

jchunk integration now shows the LHS line numbers. RHS are still TODO.

stephan 2021-09-09 06:37 diff-js-refactoring
Commit e63ad6ff251de026265233a14d8e223bac155e50f990cce95adf660040e1eb31
--- src/fossil.diff.js
+++ src/fossil.diff.js
@@ -92,19 +92,19 @@
9292
const hash = table.dataset.lefthash;
9393
if(!hash) return;
9494
const isSbs = table.classList.contains('splitdiff')/*else udiff*/;
9595
tr.dataset.xfer = 1 /* sentinel against multiple concurrent ajax requests */;
9696
const lineTo = +tr.dataset.endln;
97
- var lnFrom = +tr.dataset.startln;
97
+ var lineFrom = +tr.dataset.startln;
9898
/* TODO: for the time being, for simplicity, we'll read the whole
9999
[startln, endln] chunk. "Later on" we'll maybe want to read it in
100
- chunks of, say, 20 lines or so, adjusting lnFrom to be 1 if it would
100
+ chunks of, say, 20 lines or so, adjusting lineFrom to be 1 if it would
101101
be less than 1. */
102102
Diff.fetchArtifactChunk({
103103
urlParams:{
104104
name: hash,
105
- from: lnFrom,
105
+ from: lineFrom,
106106
to: lineTo
107107
},
108108
aftersend: function(){
109109
delete tr.dataset.xfer;
110110
Diff.config.chunkFetch.aftersend.apply(
@@ -111,30 +111,48 @@
111111
this, Array.prototype.slice.call(arguments,0)
112112
);
113113
},
114114
onload: function(result){
115115
//console.debug("Chunk result: ",result);
116
+ /* Replace content of tr.diffskip with the fetches result.
117
+ When we refactor this to load in smaller chunks, we'll instead
118
+ need to keep this skipper in place and:
119
+
120
+ - Add a new TR above or above it, as apropriate.
121
+
122
+ - Change the TR.dataset.startln/endln values to account for
123
+ the just-fetched set.
124
+ */
116125
D.clearElement(tr);
117
- const cols = [], pre = [D.pre()];
126
+ const cols = [], preCode = [D.pre()], preLines = [D.pre(), D.pre()];
118127
if(isSbs){
119128
cols.push(D.addClass(D.td(tr), 'diffln', 'difflnl'));
120129
cols.push(D.addClass(D.td(tr), 'difftxt', 'difftxtl'));
121130
cols.push(D.addClass(D.td(tr), 'diffsep'));
122131
cols.push(D.addClass(D.td(tr), 'diffln', 'difflnr'));
123132
cols.push(D.addClass(D.td(tr), 'difftxt', 'difftxtr'));
124
- D.append(cols[1], pre[0]);
125
- pre.push(D.pre());
126
- D.append(cols[4], pre[1]);
133
+ D.append(cols[0], preLines[0]);
134
+ D.append(cols[1], preCode[0]);
135
+ D.append(cols[3], preLines[1]);
136
+ preCode.push(D.pre());
137
+ D.append(cols[4], preCode[1]);
127138
}else{
128139
cols.push(D.addClass(D.td(tr), 'diffln', 'difflnl'));
129140
cols.push(D.addClass(D.td(tr), 'diffln', 'difflnr'));
130141
cols.push(D.addClass(D.td(tr), 'diffsep'));
131142
cols.push(D.addClass(D.td(tr), 'difftxt', 'difftxtu'));
132
- D.append(cols[3], pre[0]);
143
+ D.append(cols[0], preLines[0]);
144
+ D.append(cols[1], preLines[1]);
145
+ D.append(cols[3], preCode[0]);
146
+ }
147
+ let lineno = [], i;
148
+ for( i = lineFrom; i <= lineTo; ++i ){
149
+ lineno.push(i);
133150
}
151
+ preLines[0].append(lineno.join('\n')+'\n');
134152
const code = result.join('\n')+'\n';
135
- pre.forEach((e)=>e.innerText = code);
153
+ preCode.forEach((e)=>e.innerText = code);
136154
//console.debug("Updated TR",tr);
137155
Diff.initTableDiff(table).checkTableWidth(true);
138156
/*
139157
At this point we need to:
140158
141159
--- src/fossil.diff.js
+++ src/fossil.diff.js
@@ -92,19 +92,19 @@
92 const hash = table.dataset.lefthash;
93 if(!hash) return;
94 const isSbs = table.classList.contains('splitdiff')/*else udiff*/;
95 tr.dataset.xfer = 1 /* sentinel against multiple concurrent ajax requests */;
96 const lineTo = +tr.dataset.endln;
97 var lnFrom = +tr.dataset.startln;
98 /* TODO: for the time being, for simplicity, we'll read the whole
99 [startln, endln] chunk. "Later on" we'll maybe want to read it in
100 chunks of, say, 20 lines or so, adjusting lnFrom to be 1 if it would
101 be less than 1. */
102 Diff.fetchArtifactChunk({
103 urlParams:{
104 name: hash,
105 from: lnFrom,
106 to: lineTo
107 },
108 aftersend: function(){
109 delete tr.dataset.xfer;
110 Diff.config.chunkFetch.aftersend.apply(
@@ -111,30 +111,48 @@
111 this, Array.prototype.slice.call(arguments,0)
112 );
113 },
114 onload: function(result){
115 //console.debug("Chunk result: ",result);
 
 
 
 
 
 
 
 
 
116 D.clearElement(tr);
117 const cols = [], pre = [D.pre()];
118 if(isSbs){
119 cols.push(D.addClass(D.td(tr), 'diffln', 'difflnl'));
120 cols.push(D.addClass(D.td(tr), 'difftxt', 'difftxtl'));
121 cols.push(D.addClass(D.td(tr), 'diffsep'));
122 cols.push(D.addClass(D.td(tr), 'diffln', 'difflnr'));
123 cols.push(D.addClass(D.td(tr), 'difftxt', 'difftxtr'));
124 D.append(cols[1], pre[0]);
125 pre.push(D.pre());
126 D.append(cols[4], pre[1]);
 
 
127 }else{
128 cols.push(D.addClass(D.td(tr), 'diffln', 'difflnl'));
129 cols.push(D.addClass(D.td(tr), 'diffln', 'difflnr'));
130 cols.push(D.addClass(D.td(tr), 'diffsep'));
131 cols.push(D.addClass(D.td(tr), 'difftxt', 'difftxtu'));
132 D.append(cols[3], pre[0]);
 
 
 
 
 
 
133 }
 
134 const code = result.join('\n')+'\n';
135 pre.forEach((e)=>e.innerText = code);
136 //console.debug("Updated TR",tr);
137 Diff.initTableDiff(table).checkTableWidth(true);
138 /*
139 At this point we need to:
140
141
--- src/fossil.diff.js
+++ src/fossil.diff.js
@@ -92,19 +92,19 @@
92 const hash = table.dataset.lefthash;
93 if(!hash) return;
94 const isSbs = table.classList.contains('splitdiff')/*else udiff*/;
95 tr.dataset.xfer = 1 /* sentinel against multiple concurrent ajax requests */;
96 const lineTo = +tr.dataset.endln;
97 var lineFrom = +tr.dataset.startln;
98 /* TODO: for the time being, for simplicity, we'll read the whole
99 [startln, endln] chunk. "Later on" we'll maybe want to read it in
100 chunks of, say, 20 lines or so, adjusting lineFrom to be 1 if it would
101 be less than 1. */
102 Diff.fetchArtifactChunk({
103 urlParams:{
104 name: hash,
105 from: lineFrom,
106 to: lineTo
107 },
108 aftersend: function(){
109 delete tr.dataset.xfer;
110 Diff.config.chunkFetch.aftersend.apply(
@@ -111,30 +111,48 @@
111 this, Array.prototype.slice.call(arguments,0)
112 );
113 },
114 onload: function(result){
115 //console.debug("Chunk result: ",result);
116 /* Replace content of tr.diffskip with the fetches result.
117 When we refactor this to load in smaller chunks, we'll instead
118 need to keep this skipper in place and:
119
120 - Add a new TR above or above it, as apropriate.
121
122 - Change the TR.dataset.startln/endln values to account for
123 the just-fetched set.
124 */
125 D.clearElement(tr);
126 const cols = [], preCode = [D.pre()], preLines = [D.pre(), D.pre()];
127 if(isSbs){
128 cols.push(D.addClass(D.td(tr), 'diffln', 'difflnl'));
129 cols.push(D.addClass(D.td(tr), 'difftxt', 'difftxtl'));
130 cols.push(D.addClass(D.td(tr), 'diffsep'));
131 cols.push(D.addClass(D.td(tr), 'diffln', 'difflnr'));
132 cols.push(D.addClass(D.td(tr), 'difftxt', 'difftxtr'));
133 D.append(cols[0], preLines[0]);
134 D.append(cols[1], preCode[0]);
135 D.append(cols[3], preLines[1]);
136 preCode.push(D.pre());
137 D.append(cols[4], preCode[1]);
138 }else{
139 cols.push(D.addClass(D.td(tr), 'diffln', 'difflnl'));
140 cols.push(D.addClass(D.td(tr), 'diffln', 'difflnr'));
141 cols.push(D.addClass(D.td(tr), 'diffsep'));
142 cols.push(D.addClass(D.td(tr), 'difftxt', 'difftxtu'));
143 D.append(cols[0], preLines[0]);
144 D.append(cols[1], preLines[1]);
145 D.append(cols[3], preCode[0]);
146 }
147 let lineno = [], i;
148 for( i = lineFrom; i <= lineTo; ++i ){
149 lineno.push(i);
150 }
151 preLines[0].append(lineno.join('\n')+'\n');
152 const code = result.join('\n')+'\n';
153 preCode.forEach((e)=>e.innerText = code);
154 //console.debug("Updated TR",tr);
155 Diff.initTableDiff(table).checkTableWidth(true);
156 /*
157 At this point we need to:
158
159
--- src/fossil.dom.js
+++ src/fossil.dom.js
@@ -431,11 +431,11 @@
431431
return domAddRemoveClass.apply(this, a);
432432
};
433433
434434
/**
435435
Toggles CSS class c on e (a single element for forEach-capable
436
- collection of elements. Returns its first argument.
436
+ collection of elements). Returns its first argument.
437437
*/
438438
dom.toggleClass = function f(e,c){
439439
if(e.forEach){
440440
e.forEach((x)=>x.classList.toggle(c));
441441
}else{
442442
--- src/fossil.dom.js
+++ src/fossil.dom.js
@@ -431,11 +431,11 @@
431 return domAddRemoveClass.apply(this, a);
432 };
433
434 /**
435 Toggles CSS class c on e (a single element for forEach-capable
436 collection of elements. Returns its first argument.
437 */
438 dom.toggleClass = function f(e,c){
439 if(e.forEach){
440 e.forEach((x)=>x.classList.toggle(c));
441 }else{
442
--- src/fossil.dom.js
+++ src/fossil.dom.js
@@ -431,11 +431,11 @@
431 return domAddRemoveClass.apply(this, a);
432 };
433
434 /**
435 Toggles CSS class c on e (a single element for forEach-capable
436 collection of elements). Returns its first argument.
437 */
438 dom.toggleClass = function f(e,c){
439 if(e.forEach){
440 e.forEach((x)=>x.classList.toggle(c));
441 }else{
442

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button