Fossil SCM
Propagate the default value of diff_context_lines() through to window.fossil.config.diffContextLines for use by the jchunk UI. Per /chat discussion, jchunk will load 3x that many lines of context per button click.
Commit
8f84424fff2a9aef7042145bf753cee404336eb0e2d82824b0ec32ddb705da3e
Parent
4f6b56d2536f6f6…
3 files changed
+2
+11
-4
+5
-3
+2
| --- src/builtin.c | ||
| +++ src/builtin.c | ||
| @@ -623,10 +623,12 @@ | ||
| 623 | 623 | CX("projectCode: %!j,\n", zName); |
| 624 | 624 | fossil_free(zName); |
| 625 | 625 | CX("/* Length of UUID hashes for display purposes. */"); |
| 626 | 626 | CX("hashDigits: %d, hashDigitsUrl: %d,\n", |
| 627 | 627 | hash_digits(0), hash_digits(1)); |
| 628 | + CX("diffContextLines: %d,\n", | |
| 629 | + diff_context_lines(0)); | |
| 628 | 630 | CX("editStateMarkers: {" |
| 629 | 631 | "/*Symbolic markers to denote certain edit states.*/" |
| 630 | 632 | "isNew:'[+]', isModified:'[*]', isDeleted:'[-]'},\n"); |
| 631 | 633 | CX("confirmerButtonTicks: 3 " |
| 632 | 634 | "/*default fossil.confirmer tick count.*/,\n"); |
| 633 | 635 |
| --- src/builtin.c | |
| +++ src/builtin.c | |
| @@ -623,10 +623,12 @@ | |
| 623 | CX("projectCode: %!j,\n", zName); |
| 624 | fossil_free(zName); |
| 625 | CX("/* Length of UUID hashes for display purposes. */"); |
| 626 | CX("hashDigits: %d, hashDigitsUrl: %d,\n", |
| 627 | hash_digits(0), hash_digits(1)); |
| 628 | CX("editStateMarkers: {" |
| 629 | "/*Symbolic markers to denote certain edit states.*/" |
| 630 | "isNew:'[+]', isModified:'[*]', isDeleted:'[-]'},\n"); |
| 631 | CX("confirmerButtonTicks: 3 " |
| 632 | "/*default fossil.confirmer tick count.*/,\n"); |
| 633 |
| --- src/builtin.c | |
| +++ src/builtin.c | |
| @@ -623,10 +623,12 @@ | |
| 623 | CX("projectCode: %!j,\n", zName); |
| 624 | fossil_free(zName); |
| 625 | CX("/* Length of UUID hashes for display purposes. */"); |
| 626 | CX("hashDigits: %d, hashDigitsUrl: %d,\n", |
| 627 | hash_digits(0), hash_digits(1)); |
| 628 | CX("diffContextLines: %d,\n", |
| 629 | diff_context_lines(0)); |
| 630 | CX("editStateMarkers: {" |
| 631 | "/*Symbolic markers to denote certain edit states.*/" |
| 632 | "isNew:'[+]', isModified:'[*]', isDeleted:'[-]'},\n"); |
| 633 | CX("confirmerButtonTicks: 3 " |
| 634 | "/*default fossil.confirmer tick count.*/,\n"); |
| 635 |
+11
-4
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -2577,16 +2577,23 @@ | ||
| 2577 | 2577 | } |
| 2578 | 2578 | } |
| 2579 | 2579 | |
| 2580 | 2580 | /* |
| 2581 | 2581 | ** Extract the number of lines of context from diffFlags. Supply an |
| 2582 | -** appropriate default if no context width is specified. | |
| 2582 | +** appropriate default if no context width is specified. If pCfg is | |
| 2583 | +** NULL then the compile-time default is used (which gets propagated | |
| 2584 | +** to JS-side state by certain pages). | |
| 2583 | 2585 | */ |
| 2584 | 2586 | int diff_context_lines(DiffConfig *pCfg){ |
| 2585 | - int n = pCfg->nContext; | |
| 2586 | - if( n<=0 && (pCfg->diffFlags & DIFF_CONTEXT_EX)==0 ) n = 5; | |
| 2587 | - return n; | |
| 2587 | + const int dflt = 5; | |
| 2588 | + if(pCfg!=0){ | |
| 2589 | + int n = pCfg->nContext; | |
| 2590 | + if( n<=0 && (pCfg->diffFlags & DIFF_CONTEXT_EX)==0 ) n = dflt; | |
| 2591 | + return n; | |
| 2592 | + }else{ | |
| 2593 | + return dflt; | |
| 2594 | + } | |
| 2588 | 2595 | } |
| 2589 | 2596 | |
| 2590 | 2597 | /* |
| 2591 | 2598 | ** Extract the width of columns for side-by-side diff. Supply an |
| 2592 | 2599 | ** appropriate default if no width is given. |
| 2593 | 2600 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -2577,16 +2577,23 @@ | |
| 2577 | } |
| 2578 | } |
| 2579 | |
| 2580 | /* |
| 2581 | ** Extract the number of lines of context from diffFlags. Supply an |
| 2582 | ** appropriate default if no context width is specified. |
| 2583 | */ |
| 2584 | int diff_context_lines(DiffConfig *pCfg){ |
| 2585 | int n = pCfg->nContext; |
| 2586 | if( n<=0 && (pCfg->diffFlags & DIFF_CONTEXT_EX)==0 ) n = 5; |
| 2587 | return n; |
| 2588 | } |
| 2589 | |
| 2590 | /* |
| 2591 | ** Extract the width of columns for side-by-side diff. Supply an |
| 2592 | ** appropriate default if no width is given. |
| 2593 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -2577,16 +2577,23 @@ | |
| 2577 | } |
| 2578 | } |
| 2579 | |
| 2580 | /* |
| 2581 | ** Extract the number of lines of context from diffFlags. Supply an |
| 2582 | ** appropriate default if no context width is specified. If pCfg is |
| 2583 | ** NULL then the compile-time default is used (which gets propagated |
| 2584 | ** to JS-side state by certain pages). |
| 2585 | */ |
| 2586 | int diff_context_lines(DiffConfig *pCfg){ |
| 2587 | const int dflt = 5; |
| 2588 | if(pCfg!=0){ |
| 2589 | int n = pCfg->nContext; |
| 2590 | if( n<=0 && (pCfg->diffFlags & DIFF_CONTEXT_EX)==0 ) n = dflt; |
| 2591 | return n; |
| 2592 | }else{ |
| 2593 | return dflt; |
| 2594 | } |
| 2595 | } |
| 2596 | |
| 2597 | /* |
| 2598 | ** Extract the width of columns for side-by-side diff. Supply an |
| 2599 | ** appropriate default if no width is given. |
| 2600 |
+5
-3
| --- src/fossil.diff.js | ||
| +++ src/fossil.diff.js | ||
| @@ -23,11 +23,14 @@ | ||
| 23 | 23 | window.fossil.onPageLoad(function(){ |
| 24 | 24 | const F = window.fossil, D = F.dom; |
| 25 | 25 | const Diff = F.diff = { |
| 26 | 26 | e:{/*certain cached DOM elements*/}, |
| 27 | 27 | config: { |
| 28 | - chunkLoadLines: 30 /* TODO: 3x default context diff value */, | |
| 28 | + chunkLoadLines: ( | |
| 29 | + F.config.diffContextLines * 3 | |
| 30 | + /*per /chat discussion*/ | |
| 31 | + ) || 20, | |
| 29 | 32 | chunkFetch: { |
| 30 | 33 | /* Default callack handlers for Diff.fetchArtifactChunk(), |
| 31 | 34 | unless overridden by options passeed to that function. */ |
| 32 | 35 | beforesend: function(){}, |
| 33 | 36 | aftersend: function(){}, |
| @@ -418,12 +421,11 @@ | ||
| 418 | 421 | } |
| 419 | 422 | e.innerHTML = content.join(''); |
| 420 | 423 | }); |
| 421 | 424 | } |
| 422 | 425 | |
| 423 | - if(1){ | |
| 424 | - // Add blank lines in (.diffsep>pre) | |
| 426 | + if(1){// Add blank lines in (.diffsep>pre) | |
| 425 | 427 | const selector = '.diffsep > pre'; |
| 426 | 428 | td = tr.querySelector(selector); |
| 427 | 429 | for(i = 0; i < lineno.length; ++i) lineno[i] = ''; |
| 428 | 430 | const blanks = lineno.join('\n')+'\n'; |
| 429 | 431 | const content = [td.innerHTML]; |
| 430 | 432 |
| --- src/fossil.diff.js | |
| +++ src/fossil.diff.js | |
| @@ -23,11 +23,14 @@ | |
| 23 | window.fossil.onPageLoad(function(){ |
| 24 | const F = window.fossil, D = F.dom; |
| 25 | const Diff = F.diff = { |
| 26 | e:{/*certain cached DOM elements*/}, |
| 27 | config: { |
| 28 | chunkLoadLines: 30 /* TODO: 3x default context diff value */, |
| 29 | chunkFetch: { |
| 30 | /* Default callack handlers for Diff.fetchArtifactChunk(), |
| 31 | unless overridden by options passeed to that function. */ |
| 32 | beforesend: function(){}, |
| 33 | aftersend: function(){}, |
| @@ -418,12 +421,11 @@ | |
| 418 | } |
| 419 | e.innerHTML = content.join(''); |
| 420 | }); |
| 421 | } |
| 422 | |
| 423 | if(1){ |
| 424 | // Add blank lines in (.diffsep>pre) |
| 425 | const selector = '.diffsep > pre'; |
| 426 | td = tr.querySelector(selector); |
| 427 | for(i = 0; i < lineno.length; ++i) lineno[i] = ''; |
| 428 | const blanks = lineno.join('\n')+'\n'; |
| 429 | const content = [td.innerHTML]; |
| 430 |
| --- src/fossil.diff.js | |
| +++ src/fossil.diff.js | |
| @@ -23,11 +23,14 @@ | |
| 23 | window.fossil.onPageLoad(function(){ |
| 24 | const F = window.fossil, D = F.dom; |
| 25 | const Diff = F.diff = { |
| 26 | e:{/*certain cached DOM elements*/}, |
| 27 | config: { |
| 28 | chunkLoadLines: ( |
| 29 | F.config.diffContextLines * 3 |
| 30 | /*per /chat discussion*/ |
| 31 | ) || 20, |
| 32 | chunkFetch: { |
| 33 | /* Default callack handlers for Diff.fetchArtifactChunk(), |
| 34 | unless overridden by options passeed to that function. */ |
| 35 | beforesend: function(){}, |
| 36 | aftersend: function(){}, |
| @@ -418,12 +421,11 @@ | |
| 421 | } |
| 422 | e.innerHTML = content.join(''); |
| 423 | }); |
| 424 | } |
| 425 | |
| 426 | if(1){// Add blank lines in (.diffsep>pre) |
| 427 | const selector = '.diffsep > pre'; |
| 428 | td = tr.querySelector(selector); |
| 429 | for(i = 0; i < lineno.length; ++i) lineno[i] = ''; |
| 430 | const blanks = lineno.join('\n')+'\n'; |
| 431 | const content = [td.innerHTML]; |
| 432 |