Fossil SCM
Removed about a hundred lines of dead code from the diff context loading bits. Reported by Florian B. in the forum.
Commit
47438b71376128c177027ad01829ae231aae8d49dd930eaa05e7765f15843dec
Parent
cae7036bb7f07c1…
1 file changed
-99
-99
| --- src/fossil.diff.js | ||
| +++ src/fossil.diff.js | ||
| @@ -106,109 +106,10 @@ | ||
| 106 | 106 | getLHS ? 1 : (isSplit ? 4 : 2) |
| 107 | 107 | )+')'); |
| 108 | 108 | const m = f.rx[getStart ? 'start' : 'end'].exec(td.innerText); |
| 109 | 109 | return m ? +m[1] : undefined/*"shouldn't happen"*/; |
| 110 | 110 | }; |
| 111 | - | |
| 112 | - /** | |
| 113 | - Fetches /jchunk for the given TR element then replaces the TR's | |
| 114 | - contents with data from the result of that request. | |
| 115 | - */ | |
| 116 | - const fetchTrChunk = function(tr){ | |
| 117 | - if(tr.dataset.xfer /* already being fetched */) return; | |
| 118 | - const table = tr.parentElement.parentElement; | |
| 119 | - const hash = table.dataset.lefthash; | |
| 120 | - if(!hash) return; | |
| 121 | - const isSbs = table.classList.contains('splitdiff')/*else udiff*/; | |
| 122 | - tr.dataset.xfer = 1 /* sentinel against multiple concurrent ajax requests */; | |
| 123 | - const lineTo = +tr.dataset.endln; | |
| 124 | - var lineFrom = +tr.dataset.startln; | |
| 125 | - /* TODO: for the time being, for simplicity, we'll read the whole | |
| 126 | - [startln, endln] chunk. "Later on" we'll maybe want to read it in | |
| 127 | - chunks of, say, 20 lines or so, adjusting lineFrom to be 1 if it would | |
| 128 | - be less than 1. */ | |
| 129 | - Diff.fetchArtifactChunk({ | |
| 130 | - urlParams:{ | |
| 131 | - name: hash, | |
| 132 | - from: lineFrom, | |
| 133 | - to: lineTo | |
| 134 | - }, | |
| 135 | - aftersend: function(){ | |
| 136 | - delete tr.dataset.xfer; | |
| 137 | - Diff.config.chunkFetch.aftersend.apply( | |
| 138 | - this, Array.prototype.slice.call(arguments,0) | |
| 139 | - ); | |
| 140 | - }, | |
| 141 | - onload: function(result){ | |
| 142 | - //console.debug("Chunk result: ",result); | |
| 143 | - /* Replace content of tr.diffskip with the fetches result. | |
| 144 | - When we refactor this to load in smaller chunks, we'll instead | |
| 145 | - need to keep this skipper in place and: | |
| 146 | - | |
| 147 | - - Add a new TR above or above it, as apropriate. | |
| 148 | - | |
| 149 | - - Change the TR.dataset.startln/endln values to account for | |
| 150 | - the just-fetched set. | |
| 151 | - */ | |
| 152 | - D.clearElement(tr); | |
| 153 | - const cols = [], preCode = [D.pre()], preLines = [D.pre(), D.pre()]; | |
| 154 | - if(isSbs){ | |
| 155 | - cols.push(D.addClass(D.td(tr), 'diffln', 'difflnl')); | |
| 156 | - cols.push(D.addClass(D.td(tr), 'difftxt', 'difftxtl')); | |
| 157 | - cols.push(D.addClass(D.td(tr), 'diffsep')); | |
| 158 | - cols.push(D.addClass(D.td(tr), 'diffln', 'difflnr')); | |
| 159 | - cols.push(D.addClass(D.td(tr), 'difftxt', 'difftxtr')); | |
| 160 | - D.append(cols[0], preLines[0]); | |
| 161 | - D.append(cols[1], preCode[0]); | |
| 162 | - D.append(cols[3], preLines[1]); | |
| 163 | - preCode.push(D.pre()); | |
| 164 | - D.append(cols[4], preCode[1]); | |
| 165 | - }else{ | |
| 166 | - cols.push(D.addClass(D.td(tr), 'diffln', 'difflnl')); | |
| 167 | - cols.push(D.addClass(D.td(tr), 'diffln', 'difflnr')); | |
| 168 | - cols.push(D.addClass(D.td(tr), 'diffsep')); | |
| 169 | - cols.push(D.addClass(D.td(tr), 'difftxt', 'difftxtu')); | |
| 170 | - D.append(cols[0], preLines[0]); | |
| 171 | - D.append(cols[1], preLines[1]); | |
| 172 | - D.append(cols[3], preCode[0]); | |
| 173 | - } | |
| 174 | - let lineno = [], i; | |
| 175 | - for( i = lineFrom; i <= lineTo; ++i ){ | |
| 176 | - lineno.push(i); | |
| 177 | - } | |
| 178 | - preLines[0].append(lineno.join('\n')+'\n'); | |
| 179 | - if(1){ | |
| 180 | - const code = result.join('\n')+'\n'; | |
| 181 | - preCode.forEach((e)=>e.innerText = code); | |
| 182 | - } | |
| 183 | - //console.debug("Updated TR",tr); | |
| 184 | - Diff.initTableDiff(table).checkTableWidth(true); | |
| 185 | - /* | |
| 186 | - Reminders to self during development: | |
| 187 | - | |
| 188 | - SBS diff col layout: | |
| 189 | - <td.diffln.difflnl><pre>...LHS line numbers...</pre></td> | |
| 190 | - <td.difftxt.difftxtl><pre>...code lines...</pre></td> | |
| 191 | - <td.diffsep>empty for this case (common lines)</td> | |
| 192 | - <td.diffln.difflnr><pre>...RHS line numbers...</pre></td> | |
| 193 | - <td.difftxt.difftxtr><pre>...dupe of col 2</pre></td> | |
| 194 | - | |
| 195 | - Unified diff col layout: | |
| 196 | - <td.diffln.difflnl><pre>LHS line numbers</pre></td> | |
| 197 | - <td.diffln.difflnr><pre>RHS line numbers</pre></td> | |
| 198 | - <td.diffsep>empty in this case (common lines)</td> | |
| 199 | - <td.difftxt.difftxtu><pre>code line</pre></td> | |
| 200 | - | |
| 201 | - C-side TODOs: | |
| 202 | - | |
| 203 | - - If we have that data readily available, it would be a big | |
| 204 | - help (simplify our line calculations) if we stored the line | |
| 205 | - number ranges in all elements which have that state handy. | |
| 206 | - */ | |
| 207 | - } | |
| 208 | - }); | |
| 209 | - }; | |
| 210 | 111 | |
| 211 | 112 | /** |
| 212 | 113 | Installs chunk-loading controls into TR.diffskip element tr. |
| 213 | 114 | Each instance corresponds to a single TR.diffskip element. |
| 214 | 115 | |
| 215 | 116 |
| --- src/fossil.diff.js | |
| +++ src/fossil.diff.js | |
| @@ -106,109 +106,10 @@ | |
| 106 | getLHS ? 1 : (isSplit ? 4 : 2) |
| 107 | )+')'); |
| 108 | const m = f.rx[getStart ? 'start' : 'end'].exec(td.innerText); |
| 109 | return m ? +m[1] : undefined/*"shouldn't happen"*/; |
| 110 | }; |
| 111 | |
| 112 | /** |
| 113 | Fetches /jchunk for the given TR element then replaces the TR's |
| 114 | contents with data from the result of that request. |
| 115 | */ |
| 116 | const fetchTrChunk = function(tr){ |
| 117 | if(tr.dataset.xfer /* already being fetched */) return; |
| 118 | const table = tr.parentElement.parentElement; |
| 119 | const hash = table.dataset.lefthash; |
| 120 | if(!hash) return; |
| 121 | const isSbs = table.classList.contains('splitdiff')/*else udiff*/; |
| 122 | tr.dataset.xfer = 1 /* sentinel against multiple concurrent ajax requests */; |
| 123 | const lineTo = +tr.dataset.endln; |
| 124 | var lineFrom = +tr.dataset.startln; |
| 125 | /* TODO: for the time being, for simplicity, we'll read the whole |
| 126 | [startln, endln] chunk. "Later on" we'll maybe want to read it in |
| 127 | chunks of, say, 20 lines or so, adjusting lineFrom to be 1 if it would |
| 128 | be less than 1. */ |
| 129 | Diff.fetchArtifactChunk({ |
| 130 | urlParams:{ |
| 131 | name: hash, |
| 132 | from: lineFrom, |
| 133 | to: lineTo |
| 134 | }, |
| 135 | aftersend: function(){ |
| 136 | delete tr.dataset.xfer; |
| 137 | Diff.config.chunkFetch.aftersend.apply( |
| 138 | this, Array.prototype.slice.call(arguments,0) |
| 139 | ); |
| 140 | }, |
| 141 | onload: function(result){ |
| 142 | //console.debug("Chunk result: ",result); |
| 143 | /* Replace content of tr.diffskip with the fetches result. |
| 144 | When we refactor this to load in smaller chunks, we'll instead |
| 145 | need to keep this skipper in place and: |
| 146 | |
| 147 | - Add a new TR above or above it, as apropriate. |
| 148 | |
| 149 | - Change the TR.dataset.startln/endln values to account for |
| 150 | the just-fetched set. |
| 151 | */ |
| 152 | D.clearElement(tr); |
| 153 | const cols = [], preCode = [D.pre()], preLines = [D.pre(), D.pre()]; |
| 154 | if(isSbs){ |
| 155 | cols.push(D.addClass(D.td(tr), 'diffln', 'difflnl')); |
| 156 | cols.push(D.addClass(D.td(tr), 'difftxt', 'difftxtl')); |
| 157 | cols.push(D.addClass(D.td(tr), 'diffsep')); |
| 158 | cols.push(D.addClass(D.td(tr), 'diffln', 'difflnr')); |
| 159 | cols.push(D.addClass(D.td(tr), 'difftxt', 'difftxtr')); |
| 160 | D.append(cols[0], preLines[0]); |
| 161 | D.append(cols[1], preCode[0]); |
| 162 | D.append(cols[3], preLines[1]); |
| 163 | preCode.push(D.pre()); |
| 164 | D.append(cols[4], preCode[1]); |
| 165 | }else{ |
| 166 | cols.push(D.addClass(D.td(tr), 'diffln', 'difflnl')); |
| 167 | cols.push(D.addClass(D.td(tr), 'diffln', 'difflnr')); |
| 168 | cols.push(D.addClass(D.td(tr), 'diffsep')); |
| 169 | cols.push(D.addClass(D.td(tr), 'difftxt', 'difftxtu')); |
| 170 | D.append(cols[0], preLines[0]); |
| 171 | D.append(cols[1], preLines[1]); |
| 172 | D.append(cols[3], preCode[0]); |
| 173 | } |
| 174 | let lineno = [], i; |
| 175 | for( i = lineFrom; i <= lineTo; ++i ){ |
| 176 | lineno.push(i); |
| 177 | } |
| 178 | preLines[0].append(lineno.join('\n')+'\n'); |
| 179 | if(1){ |
| 180 | const code = result.join('\n')+'\n'; |
| 181 | preCode.forEach((e)=>e.innerText = code); |
| 182 | } |
| 183 | //console.debug("Updated TR",tr); |
| 184 | Diff.initTableDiff(table).checkTableWidth(true); |
| 185 | /* |
| 186 | Reminders to self during development: |
| 187 | |
| 188 | SBS diff col layout: |
| 189 | <td.diffln.difflnl><pre>...LHS line numbers...</pre></td> |
| 190 | <td.difftxt.difftxtl><pre>...code lines...</pre></td> |
| 191 | <td.diffsep>empty for this case (common lines)</td> |
| 192 | <td.diffln.difflnr><pre>...RHS line numbers...</pre></td> |
| 193 | <td.difftxt.difftxtr><pre>...dupe of col 2</pre></td> |
| 194 | |
| 195 | Unified diff col layout: |
| 196 | <td.diffln.difflnl><pre>LHS line numbers</pre></td> |
| 197 | <td.diffln.difflnr><pre>RHS line numbers</pre></td> |
| 198 | <td.diffsep>empty in this case (common lines)</td> |
| 199 | <td.difftxt.difftxtu><pre>code line</pre></td> |
| 200 | |
| 201 | C-side TODOs: |
| 202 | |
| 203 | - If we have that data readily available, it would be a big |
| 204 | help (simplify our line calculations) if we stored the line |
| 205 | number ranges in all elements which have that state handy. |
| 206 | */ |
| 207 | } |
| 208 | }); |
| 209 | }; |
| 210 | |
| 211 | /** |
| 212 | Installs chunk-loading controls into TR.diffskip element tr. |
| 213 | Each instance corresponds to a single TR.diffskip element. |
| 214 | |
| 215 |
| --- src/fossil.diff.js | |
| +++ src/fossil.diff.js | |
| @@ -106,109 +106,10 @@ | |
| 106 | getLHS ? 1 : (isSplit ? 4 : 2) |
| 107 | )+')'); |
| 108 | const m = f.rx[getStart ? 'start' : 'end'].exec(td.innerText); |
| 109 | return m ? +m[1] : undefined/*"shouldn't happen"*/; |
| 110 | }; |
| 111 | |
| 112 | /** |
| 113 | Installs chunk-loading controls into TR.diffskip element tr. |
| 114 | Each instance corresponds to a single TR.diffskip element. |
| 115 | |
| 116 |