Fossil SCM
Show numstat-style statistics in the 'Changes' section of /info and friends.
Commit
25e156c9b77726d552c7665f8088b66c22df58ae9ee8621aa08e3c2313f9b34e
Parent
062bb67c03f25c4…
2 files changed
+15
-9
+9
-1
+15
-9
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -3085,10 +3085,11 @@ | ||
| 3085 | 3085 | Blob *pOut, /* Write diff here if not NULL */ |
| 3086 | 3086 | DiffConfig *pCfg /* Configuration options */ |
| 3087 | 3087 | ){ |
| 3088 | 3088 | int ignoreWs; /* Ignore whitespace */ |
| 3089 | 3089 | DContext c; |
| 3090 | + int nDel = 0, nIns = 0; | |
| 3090 | 3091 | |
| 3091 | 3092 | if( pCfg->diffFlags & DIFF_INVERT ){ |
| 3092 | 3093 | Blob *pTemp = pA_Blob; |
| 3093 | 3094 | pA_Blob = pB_Blob; |
| 3094 | 3095 | pB_Blob = pTemp; |
| @@ -3163,22 +3164,27 @@ | ||
| 3163 | 3164 | c.aEdit[i+1] = sum; |
| 3164 | 3165 | for(k=0, sum=0; k<c.aEdit[i+2]; k++) sum += c.aTo[iB++].n; |
| 3165 | 3166 | c.aEdit[i+2] = sum; |
| 3166 | 3167 | } |
| 3167 | 3168 | } |
| 3169 | + | |
| 3170 | + if( pCfg->diffFlags & DIFF_NUMSTAT ){ | |
| 3171 | + int i; | |
| 3172 | + for(i=0; c.aEdit[i] || c.aEdit[i+1] || c.aEdit[i+2]; i+=3){ | |
| 3173 | + nDel += c.aEdit[i+1]; | |
| 3174 | + nIns += c.aEdit[i+2]; | |
| 3175 | + } | |
| 3176 | + g.diffCnt[1] += nIns; | |
| 3177 | + g.diffCnt[2] += nDel; | |
| 3178 | + if( nIns+nDel ){ | |
| 3179 | + g.diffCnt[0]++; | |
| 3180 | + } | |
| 3181 | + } | |
| 3168 | 3182 | |
| 3169 | 3183 | if( pOut ){ |
| 3170 | - if( pCfg->diffFlags & DIFF_NUMSTAT ){ | |
| 3171 | - int nDel = 0, nIns = 0, i; | |
| 3172 | - for(i=0; c.aEdit[i] || c.aEdit[i+1] || c.aEdit[i+2]; i+=3){ | |
| 3173 | - nDel += c.aEdit[i+1]; | |
| 3174 | - nIns += c.aEdit[i+2]; | |
| 3175 | - } | |
| 3176 | - g.diffCnt[1] += nIns; | |
| 3177 | - g.diffCnt[2] += nDel; | |
| 3184 | + if( pCfg->diffFlags & DIFF_NUMSTAT && !(pCfg->diffFlags & DIFF_HTML)){ | |
| 3178 | 3185 | if( nIns+nDel ){ |
| 3179 | - g.diffCnt[0]++; | |
| 3180 | 3186 | if( !(pCfg->diffFlags & DIFF_BRIEF) ){ |
| 3181 | 3187 | blob_appendf(pOut, "%10d %10d", nIns, nDel); |
| 3182 | 3188 | } |
| 3183 | 3189 | } |
| 3184 | 3190 | }else if( pCfg->diffFlags & (DIFF_RAW|DIFF_BY_TOKEN) ){ |
| 3185 | 3191 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -3085,10 +3085,11 @@ | |
| 3085 | Blob *pOut, /* Write diff here if not NULL */ |
| 3086 | DiffConfig *pCfg /* Configuration options */ |
| 3087 | ){ |
| 3088 | int ignoreWs; /* Ignore whitespace */ |
| 3089 | DContext c; |
| 3090 | |
| 3091 | if( pCfg->diffFlags & DIFF_INVERT ){ |
| 3092 | Blob *pTemp = pA_Blob; |
| 3093 | pA_Blob = pB_Blob; |
| 3094 | pB_Blob = pTemp; |
| @@ -3163,22 +3164,27 @@ | |
| 3163 | c.aEdit[i+1] = sum; |
| 3164 | for(k=0, sum=0; k<c.aEdit[i+2]; k++) sum += c.aTo[iB++].n; |
| 3165 | c.aEdit[i+2] = sum; |
| 3166 | } |
| 3167 | } |
| 3168 | |
| 3169 | if( pOut ){ |
| 3170 | if( pCfg->diffFlags & DIFF_NUMSTAT ){ |
| 3171 | int nDel = 0, nIns = 0, i; |
| 3172 | for(i=0; c.aEdit[i] || c.aEdit[i+1] || c.aEdit[i+2]; i+=3){ |
| 3173 | nDel += c.aEdit[i+1]; |
| 3174 | nIns += c.aEdit[i+2]; |
| 3175 | } |
| 3176 | g.diffCnt[1] += nIns; |
| 3177 | g.diffCnt[2] += nDel; |
| 3178 | if( nIns+nDel ){ |
| 3179 | g.diffCnt[0]++; |
| 3180 | if( !(pCfg->diffFlags & DIFF_BRIEF) ){ |
| 3181 | blob_appendf(pOut, "%10d %10d", nIns, nDel); |
| 3182 | } |
| 3183 | } |
| 3184 | }else if( pCfg->diffFlags & (DIFF_RAW|DIFF_BY_TOKEN) ){ |
| 3185 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -3085,10 +3085,11 @@ | |
| 3085 | Blob *pOut, /* Write diff here if not NULL */ |
| 3086 | DiffConfig *pCfg /* Configuration options */ |
| 3087 | ){ |
| 3088 | int ignoreWs; /* Ignore whitespace */ |
| 3089 | DContext c; |
| 3090 | int nDel = 0, nIns = 0; |
| 3091 | |
| 3092 | if( pCfg->diffFlags & DIFF_INVERT ){ |
| 3093 | Blob *pTemp = pA_Blob; |
| 3094 | pA_Blob = pB_Blob; |
| 3095 | pB_Blob = pTemp; |
| @@ -3163,22 +3164,27 @@ | |
| 3164 | c.aEdit[i+1] = sum; |
| 3165 | for(k=0, sum=0; k<c.aEdit[i+2]; k++) sum += c.aTo[iB++].n; |
| 3166 | c.aEdit[i+2] = sum; |
| 3167 | } |
| 3168 | } |
| 3169 | |
| 3170 | if( pCfg->diffFlags & DIFF_NUMSTAT ){ |
| 3171 | int i; |
| 3172 | for(i=0; c.aEdit[i] || c.aEdit[i+1] || c.aEdit[i+2]; i+=3){ |
| 3173 | nDel += c.aEdit[i+1]; |
| 3174 | nIns += c.aEdit[i+2]; |
| 3175 | } |
| 3176 | g.diffCnt[1] += nIns; |
| 3177 | g.diffCnt[2] += nDel; |
| 3178 | if( nIns+nDel ){ |
| 3179 | g.diffCnt[0]++; |
| 3180 | } |
| 3181 | } |
| 3182 | |
| 3183 | if( pOut ){ |
| 3184 | if( pCfg->diffFlags & DIFF_NUMSTAT && !(pCfg->diffFlags & DIFF_HTML)){ |
| 3185 | if( nIns+nDel ){ |
| 3186 | if( !(pCfg->diffFlags & DIFF_BRIEF) ){ |
| 3187 | blob_appendf(pOut, "%10d %10d", nIns, nDel); |
| 3188 | } |
| 3189 | } |
| 3190 | }else if( pCfg->diffFlags & (DIFF_RAW|DIFF_BY_TOKEN) ){ |
| 3191 |
+9
-1
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -1167,15 +1167,16 @@ | ||
| 1167 | 1167 | } |
| 1168 | 1168 | render_backlink_graph(zUuid, |
| 1169 | 1169 | "<div class=\"section accordion\">References</div>\n"); |
| 1170 | 1170 | @ <div class="section accordion">Context</div><div class="accordion_panel"> |
| 1171 | 1171 | render_checkin_context(rid, 0, 0, 0); |
| 1172 | - @ </div><div class="section accordion">Changes</div> | |
| 1172 | + @ </div><div class="section accordion" id="changes_section">Changes</div> | |
| 1173 | 1173 | @ <div class="accordion_panel"> |
| 1174 | 1174 | @ <div class="sectionmenu info-changes-menu"> |
| 1175 | 1175 | /* ^^^ .info-changes-menu is used by diff scroll sync */ |
| 1176 | 1176 | pCfg = construct_diff_flags(diffType, &DCfg); |
| 1177 | + DCfg.diffFlags |= DIFF_NUMSTAT; /* Show stats in the 'Changes' section */ | |
| 1177 | 1178 | DCfg.pRe = pRe; |
| 1178 | 1179 | zW = (DCfg.diffFlags&DIFF_IGNORE_ALLWS)?"&w":""; |
| 1179 | 1180 | if( diffType!=1 ){ |
| 1180 | 1181 | @ %z(chref("button","%R/%s/%T?diff=1%s",zPage,zName,zW))\ |
| 1181 | 1182 | @ Unified Diff</a> |
| @@ -1227,10 +1228,17 @@ | ||
| 1227 | 1228 | append_file_change_line(zUuid, zName, zOld, zNew, zOldName, |
| 1228 | 1229 | pCfg,mperm); |
| 1229 | 1230 | } |
| 1230 | 1231 | db_finalize(&q3); |
| 1231 | 1232 | @ </div> |
| 1233 | + @ <script nonce='%h(style_nonce())'>;/* info.c:%d(__LINE__) */ | |
| 1234 | + @ function plu(n) {return (n===1 ? '' : 's')} | |
| 1235 | + @ document.getElementById('changes_section').textContent = 'Changes ' + | |
| 1236 | + @ '(%d(g.diffCnt[0]) file' + plu(%d(g.diffCnt[0])) + ': ' + | |
| 1237 | + @ '%d(g.diffCnt[1]) addition' + plu(%d(g.diffCnt[1])) + ', ' + | |
| 1238 | + @ '%d(g.diffCnt[2]) deletion' + plu(%d(g.diffCnt[2])) + ')' | |
| 1239 | + @ </script> | |
| 1232 | 1240 | append_diff_javascript(diffType); |
| 1233 | 1241 | style_finish_page(); |
| 1234 | 1242 | } |
| 1235 | 1243 | |
| 1236 | 1244 | /* |
| 1237 | 1245 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -1167,15 +1167,16 @@ | |
| 1167 | } |
| 1168 | render_backlink_graph(zUuid, |
| 1169 | "<div class=\"section accordion\">References</div>\n"); |
| 1170 | @ <div class="section accordion">Context</div><div class="accordion_panel"> |
| 1171 | render_checkin_context(rid, 0, 0, 0); |
| 1172 | @ </div><div class="section accordion">Changes</div> |
| 1173 | @ <div class="accordion_panel"> |
| 1174 | @ <div class="sectionmenu info-changes-menu"> |
| 1175 | /* ^^^ .info-changes-menu is used by diff scroll sync */ |
| 1176 | pCfg = construct_diff_flags(diffType, &DCfg); |
| 1177 | DCfg.pRe = pRe; |
| 1178 | zW = (DCfg.diffFlags&DIFF_IGNORE_ALLWS)?"&w":""; |
| 1179 | if( diffType!=1 ){ |
| 1180 | @ %z(chref("button","%R/%s/%T?diff=1%s",zPage,zName,zW))\ |
| 1181 | @ Unified Diff</a> |
| @@ -1227,10 +1228,17 @@ | |
| 1227 | append_file_change_line(zUuid, zName, zOld, zNew, zOldName, |
| 1228 | pCfg,mperm); |
| 1229 | } |
| 1230 | db_finalize(&q3); |
| 1231 | @ </div> |
| 1232 | append_diff_javascript(diffType); |
| 1233 | style_finish_page(); |
| 1234 | } |
| 1235 | |
| 1236 | /* |
| 1237 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -1167,15 +1167,16 @@ | |
| 1167 | } |
| 1168 | render_backlink_graph(zUuid, |
| 1169 | "<div class=\"section accordion\">References</div>\n"); |
| 1170 | @ <div class="section accordion">Context</div><div class="accordion_panel"> |
| 1171 | render_checkin_context(rid, 0, 0, 0); |
| 1172 | @ </div><div class="section accordion" id="changes_section">Changes</div> |
| 1173 | @ <div class="accordion_panel"> |
| 1174 | @ <div class="sectionmenu info-changes-menu"> |
| 1175 | /* ^^^ .info-changes-menu is used by diff scroll sync */ |
| 1176 | pCfg = construct_diff_flags(diffType, &DCfg); |
| 1177 | DCfg.diffFlags |= DIFF_NUMSTAT; /* Show stats in the 'Changes' section */ |
| 1178 | DCfg.pRe = pRe; |
| 1179 | zW = (DCfg.diffFlags&DIFF_IGNORE_ALLWS)?"&w":""; |
| 1180 | if( diffType!=1 ){ |
| 1181 | @ %z(chref("button","%R/%s/%T?diff=1%s",zPage,zName,zW))\ |
| 1182 | @ Unified Diff</a> |
| @@ -1227,10 +1228,17 @@ | |
| 1228 | append_file_change_line(zUuid, zName, zOld, zNew, zOldName, |
| 1229 | pCfg,mperm); |
| 1230 | } |
| 1231 | db_finalize(&q3); |
| 1232 | @ </div> |
| 1233 | @ <script nonce='%h(style_nonce())'>;/* info.c:%d(__LINE__) */ |
| 1234 | @ function plu(n) {return (n===1 ? '' : 's')} |
| 1235 | @ document.getElementById('changes_section').textContent = 'Changes ' + |
| 1236 | @ '(%d(g.diffCnt[0]) file' + plu(%d(g.diffCnt[0])) + ': ' + |
| 1237 | @ '%d(g.diffCnt[1]) addition' + plu(%d(g.diffCnt[1])) + ', ' + |
| 1238 | @ '%d(g.diffCnt[2]) deletion' + plu(%d(g.diffCnt[2])) + ')' |
| 1239 | @ </script> |
| 1240 | append_diff_javascript(diffType); |
| 1241 | style_finish_page(); |
| 1242 | } |
| 1243 | |
| 1244 | /* |
| 1245 |