Fossil SCM
Display Unversioned Files info in dbstat command (like on /stat page)
Commit
349e9f2ff3d1ba3b94a74d086aafae85f052e23e8117bc87b3522398dafd36b5
Parent
cca8cc15f233157…
2 files changed
+16
-12
+25
+16
-12
| --- src/stat.c | ||
| +++ src/stat.c | ||
| @@ -205,29 +205,22 @@ | ||
| 205 | 205 | a = t/fsize; |
| 206 | 206 | } |
| 207 | 207 | @ %d(a):%d(b) |
| 208 | 208 | @ </td></tr> |
| 209 | 209 | } |
| 210 | - if( db_table_exists("repository","unversioned") ){ | |
| 211 | - Stmt q; | |
| 212 | - char zStored[100]; | |
| 213 | - db_prepare(&q, | |
| 214 | - "SELECT count(*), sum(sz), sum(octet_length(content))" | |
| 215 | - " FROM unversioned" | |
| 216 | - " WHERE length(hash)>1" | |
| 217 | - ); | |
| 218 | - if( db_step(&q)==SQLITE_ROW && (n = db_column_int(&q,0))>0 ){ | |
| 219 | - sqlite3_int64 iStored, pct; | |
| 220 | - iStored = db_column_int64(&q,2); | |
| 210 | + { /* Unversioned Files stat (if any) */ | |
| 211 | + sqlite3_int64 iStored = unversioned_stat(&n); | |
| 212 | + if( n>0 ){ | |
| 213 | + sqlite3_int64 pct; | |
| 214 | + char zStored[100]; | |
| 221 | 215 | pct = (iStored*100 + fsize/2)/fsize; |
| 222 | 216 | approxSizeName(sizeof(zStored), zStored, iStored); |
| 223 | 217 | @ <tr><th>Unversioned Files:</th><td> |
| 224 | 218 | @ %z(href("%R/uvlist"))%d(n) files</a>, |
| 225 | 219 | @ %s(zStored) compressed, %d(pct)%% of total repository space |
| 226 | 220 | @ </td></tr> |
| 227 | 221 | } |
| 228 | - db_finalize(&q); | |
| 229 | 222 | } |
| 230 | 223 | @ <tr><th>Number Of Check-ins:</th><td> |
| 231 | 224 | n = db_int(0, "SELECT count(*) FROM event WHERE type='ci' /*scan*/"); |
| 232 | 225 | @ %,d(n) |
| 233 | 226 | @ </td></tr> |
| @@ -410,10 +403,21 @@ | ||
| 410 | 403 | }else{ |
| 411 | 404 | b = 1; |
| 412 | 405 | } |
| 413 | 406 | a = t/fsize; |
| 414 | 407 | fossil_print("%*s%d:%d\n", colWidth, "compression-ratio:", a, b); |
| 408 | + } | |
| 409 | + { /* Unversioned Files stat (if any) */ | |
| 410 | + sqlite3_int64 iStored = unversioned_stat(&n); | |
| 411 | + if( n>0 ){ | |
| 412 | + sqlite3_int64 pct; | |
| 413 | + char zStored[100]; | |
| 414 | + pct = (iStored*100 + fsize/2)/fsize; | |
| 415 | + approxSizeName(sizeof(zStored), zStored, iStored); | |
| 416 | + fossil_print("%*s%d files, %s compressed, %d%% of total repository space\n", | |
| 417 | + colWidth, "unversioned-files:", n, zStored, pct); | |
| 418 | + } | |
| 415 | 419 | } |
| 416 | 420 | n = db_int(0, "SELECT COUNT(*) FROM event e WHERE e.type='ci'"); |
| 417 | 421 | fossil_print("%*s%,d\n", colWidth, "check-ins:", n); |
| 418 | 422 | n = db_int(0, "SELECT count(*) FROM filename /*scan*/"); |
| 419 | 423 | fossil_print("%*s%,d across all branches\n", colWidth, "files:", n); |
| 420 | 424 |
| --- src/stat.c | |
| +++ src/stat.c | |
| @@ -205,29 +205,22 @@ | |
| 205 | a = t/fsize; |
| 206 | } |
| 207 | @ %d(a):%d(b) |
| 208 | @ </td></tr> |
| 209 | } |
| 210 | if( db_table_exists("repository","unversioned") ){ |
| 211 | Stmt q; |
| 212 | char zStored[100]; |
| 213 | db_prepare(&q, |
| 214 | "SELECT count(*), sum(sz), sum(octet_length(content))" |
| 215 | " FROM unversioned" |
| 216 | " WHERE length(hash)>1" |
| 217 | ); |
| 218 | if( db_step(&q)==SQLITE_ROW && (n = db_column_int(&q,0))>0 ){ |
| 219 | sqlite3_int64 iStored, pct; |
| 220 | iStored = db_column_int64(&q,2); |
| 221 | pct = (iStored*100 + fsize/2)/fsize; |
| 222 | approxSizeName(sizeof(zStored), zStored, iStored); |
| 223 | @ <tr><th>Unversioned Files:</th><td> |
| 224 | @ %z(href("%R/uvlist"))%d(n) files</a>, |
| 225 | @ %s(zStored) compressed, %d(pct)%% of total repository space |
| 226 | @ </td></tr> |
| 227 | } |
| 228 | db_finalize(&q); |
| 229 | } |
| 230 | @ <tr><th>Number Of Check-ins:</th><td> |
| 231 | n = db_int(0, "SELECT count(*) FROM event WHERE type='ci' /*scan*/"); |
| 232 | @ %,d(n) |
| 233 | @ </td></tr> |
| @@ -410,10 +403,21 @@ | |
| 410 | }else{ |
| 411 | b = 1; |
| 412 | } |
| 413 | a = t/fsize; |
| 414 | fossil_print("%*s%d:%d\n", colWidth, "compression-ratio:", a, b); |
| 415 | } |
| 416 | n = db_int(0, "SELECT COUNT(*) FROM event e WHERE e.type='ci'"); |
| 417 | fossil_print("%*s%,d\n", colWidth, "check-ins:", n); |
| 418 | n = db_int(0, "SELECT count(*) FROM filename /*scan*/"); |
| 419 | fossil_print("%*s%,d across all branches\n", colWidth, "files:", n); |
| 420 |
| --- src/stat.c | |
| +++ src/stat.c | |
| @@ -205,29 +205,22 @@ | |
| 205 | a = t/fsize; |
| 206 | } |
| 207 | @ %d(a):%d(b) |
| 208 | @ </td></tr> |
| 209 | } |
| 210 | { /* Unversioned Files stat (if any) */ |
| 211 | sqlite3_int64 iStored = unversioned_stat(&n); |
| 212 | if( n>0 ){ |
| 213 | sqlite3_int64 pct; |
| 214 | char zStored[100]; |
| 215 | pct = (iStored*100 + fsize/2)/fsize; |
| 216 | approxSizeName(sizeof(zStored), zStored, iStored); |
| 217 | @ <tr><th>Unversioned Files:</th><td> |
| 218 | @ %z(href("%R/uvlist"))%d(n) files</a>, |
| 219 | @ %s(zStored) compressed, %d(pct)%% of total repository space |
| 220 | @ </td></tr> |
| 221 | } |
| 222 | } |
| 223 | @ <tr><th>Number Of Check-ins:</th><td> |
| 224 | n = db_int(0, "SELECT count(*) FROM event WHERE type='ci' /*scan*/"); |
| 225 | @ %,d(n) |
| 226 | @ </td></tr> |
| @@ -410,10 +403,21 @@ | |
| 403 | }else{ |
| 404 | b = 1; |
| 405 | } |
| 406 | a = t/fsize; |
| 407 | fossil_print("%*s%d:%d\n", colWidth, "compression-ratio:", a, b); |
| 408 | } |
| 409 | { /* Unversioned Files stat (if any) */ |
| 410 | sqlite3_int64 iStored = unversioned_stat(&n); |
| 411 | if( n>0 ){ |
| 412 | sqlite3_int64 pct; |
| 413 | char zStored[100]; |
| 414 | pct = (iStored*100 + fsize/2)/fsize; |
| 415 | approxSizeName(sizeof(zStored), zStored, iStored); |
| 416 | fossil_print("%*s%d files, %s compressed, %d%% of total repository space\n", |
| 417 | colWidth, "unversioned-files:", n, zStored, pct); |
| 418 | } |
| 419 | } |
| 420 | n = db_int(0, "SELECT COUNT(*) FROM event e WHERE e.type='ci'"); |
| 421 | fossil_print("%*s%,d\n", colWidth, "check-ins:", n); |
| 422 | n = db_int(0, "SELECT count(*) FROM filename /*scan*/"); |
| 423 | fossil_print("%*s%,d across all branches\n", colWidth, "files:", n); |
| 424 |
+25
| --- src/unversioned.c | ||
| +++ src/unversioned.c | ||
| @@ -768,5 +768,30 @@ | ||
| 768 | 768 | } |
| 769 | 769 | db_finalize(&q); |
| 770 | 770 | blob_appendf(&json,"]\n"); |
| 771 | 771 | cgi_set_content(&json); |
| 772 | 772 | } |
| 773 | + | |
| 774 | + | |
| 775 | +/* | |
| 776 | +** Get the file count and total size of unversioned files in bytes. | |
| 777 | +** - Return total size in bytes. | |
| 778 | +** - Optionally udpate filecount pointer if non-null pointer is given. | |
| 779 | +*/ | |
| 780 | +sqlite3_int64 unversioned_stat(int *filecount){ | |
| 781 | + sqlite3_int64 iStored=0; | |
| 782 | + int n=0; | |
| 783 | + if( db_table_exists("repository","unversioned") ){ | |
| 784 | + Stmt q; | |
| 785 | + db_prepare(&q, | |
| 786 | + "SELECT count(*), sum(sz), sum(octet_length(content))" | |
| 787 | + " FROM unversioned" | |
| 788 | + " WHERE length(hash)>1" | |
| 789 | + ); | |
| 790 | + if( db_step(&q)==SQLITE_ROW && (n = db_column_int(&q,0))>0 ){ | |
| 791 | + iStored = db_column_int64(&q,2); | |
| 792 | + } | |
| 793 | + db_finalize(&q); | |
| 794 | + } | |
| 795 | + if( filecount ) *filecount=n; | |
| 796 | + return iStored; | |
| 797 | +} | |
| 773 | 798 |
| --- src/unversioned.c | |
| +++ src/unversioned.c | |
| @@ -768,5 +768,30 @@ | |
| 768 | } |
| 769 | db_finalize(&q); |
| 770 | blob_appendf(&json,"]\n"); |
| 771 | cgi_set_content(&json); |
| 772 | } |
| 773 |
| --- src/unversioned.c | |
| +++ src/unversioned.c | |
| @@ -768,5 +768,30 @@ | |
| 768 | } |
| 769 | db_finalize(&q); |
| 770 | blob_appendf(&json,"]\n"); |
| 771 | cgi_set_content(&json); |
| 772 | } |
| 773 | |
| 774 | |
| 775 | /* |
| 776 | ** Get the file count and total size of unversioned files in bytes. |
| 777 | ** - Return total size in bytes. |
| 778 | ** - Optionally udpate filecount pointer if non-null pointer is given. |
| 779 | */ |
| 780 | sqlite3_int64 unversioned_stat(int *filecount){ |
| 781 | sqlite3_int64 iStored=0; |
| 782 | int n=0; |
| 783 | if( db_table_exists("repository","unversioned") ){ |
| 784 | Stmt q; |
| 785 | db_prepare(&q, |
| 786 | "SELECT count(*), sum(sz), sum(octet_length(content))" |
| 787 | " FROM unversioned" |
| 788 | " WHERE length(hash)>1" |
| 789 | ); |
| 790 | if( db_step(&q)==SQLITE_ROW && (n = db_column_int(&q,0))>0 ){ |
| 791 | iStored = db_column_int64(&q,2); |
| 792 | } |
| 793 | db_finalize(&q); |
| 794 | } |
| 795 | if( filecount ) *filecount=n; |
| 796 | return iStored; |
| 797 | } |
| 798 |