Fossil SCM
jchunk integration now shows the LHS line numbers. RHS are still TODO.
Commit
e63ad6ff251de026265233a14d8e223bac155e50f990cce95adf660040e1eb31
Parent
c7f3d04244c3782…
2 files changed
+27
-9
+1
-1
+27
-9
| --- src/fossil.diff.js | ||
| +++ src/fossil.diff.js | ||
| @@ -92,19 +92,19 @@ | ||
| 92 | 92 | const hash = table.dataset.lefthash; |
| 93 | 93 | if(!hash) return; |
| 94 | 94 | const isSbs = table.classList.contains('splitdiff')/*else udiff*/; |
| 95 | 95 | tr.dataset.xfer = 1 /* sentinel against multiple concurrent ajax requests */; |
| 96 | 96 | const lineTo = +tr.dataset.endln; |
| 97 | - var lnFrom = +tr.dataset.startln; | |
| 97 | + var lineFrom = +tr.dataset.startln; | |
| 98 | 98 | /* TODO: for the time being, for simplicity, we'll read the whole |
| 99 | 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 | |
| 100 | + chunks of, say, 20 lines or so, adjusting lineFrom to be 1 if it would | |
| 101 | 101 | be less than 1. */ |
| 102 | 102 | Diff.fetchArtifactChunk({ |
| 103 | 103 | urlParams:{ |
| 104 | 104 | name: hash, |
| 105 | - from: lnFrom, | |
| 105 | + from: lineFrom, | |
| 106 | 106 | to: lineTo |
| 107 | 107 | }, |
| 108 | 108 | aftersend: function(){ |
| 109 | 109 | delete tr.dataset.xfer; |
| 110 | 110 | Diff.config.chunkFetch.aftersend.apply( |
| @@ -111,30 +111,48 @@ | ||
| 111 | 111 | this, Array.prototype.slice.call(arguments,0) |
| 112 | 112 | ); |
| 113 | 113 | }, |
| 114 | 114 | onload: function(result){ |
| 115 | 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 | + */ | |
| 116 | 125 | D.clearElement(tr); |
| 117 | - const cols = [], pre = [D.pre()]; | |
| 126 | + const cols = [], preCode = [D.pre()], preLines = [D.pre(), D.pre()]; | |
| 118 | 127 | if(isSbs){ |
| 119 | 128 | cols.push(D.addClass(D.td(tr), 'diffln', 'difflnl')); |
| 120 | 129 | cols.push(D.addClass(D.td(tr), 'difftxt', 'difftxtl')); |
| 121 | 130 | cols.push(D.addClass(D.td(tr), 'diffsep')); |
| 122 | 131 | cols.push(D.addClass(D.td(tr), 'diffln', 'difflnr')); |
| 123 | 132 | 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]); | |
| 127 | 138 | }else{ |
| 128 | 139 | cols.push(D.addClass(D.td(tr), 'diffln', 'difflnl')); |
| 129 | 140 | cols.push(D.addClass(D.td(tr), 'diffln', 'difflnr')); |
| 130 | 141 | cols.push(D.addClass(D.td(tr), 'diffsep')); |
| 131 | 142 | 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); | |
| 133 | 150 | } |
| 151 | + preLines[0].append(lineno.join('\n')+'\n'); | |
| 134 | 152 | const code = result.join('\n')+'\n'; |
| 135 | - pre.forEach((e)=>e.innerText = code); | |
| 153 | + preCode.forEach((e)=>e.innerText = code); | |
| 136 | 154 | //console.debug("Updated TR",tr); |
| 137 | 155 | Diff.initTableDiff(table).checkTableWidth(true); |
| 138 | 156 | /* |
| 139 | 157 | At this point we need to: |
| 140 | 158 | |
| 141 | 159 |
| --- 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 |
+1
-1
| --- src/fossil.dom.js | ||
| +++ src/fossil.dom.js | ||
| @@ -431,11 +431,11 @@ | ||
| 431 | 431 | return domAddRemoveClass.apply(this, a); |
| 432 | 432 | }; |
| 433 | 433 | |
| 434 | 434 | /** |
| 435 | 435 | 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. | |
| 437 | 437 | */ |
| 438 | 438 | dom.toggleClass = function f(e,c){ |
| 439 | 439 | if(e.forEach){ |
| 440 | 440 | e.forEach((x)=>x.classList.toggle(c)); |
| 441 | 441 | }else{ |
| 442 | 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 |
| --- 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 |