Fossil SCM

Display Unversioned Files info in dbstat command (like on /stat page)

mgagnon 2026-04-15 17:16 UTC trunk
Commit 349e9f2ff3d1ba3b94a74d086aafae85f052e23e8117bc87b3522398dafd36b5
2 files changed +16 -12 +25
+16 -12
--- src/stat.c
+++ src/stat.c
@@ -205,29 +205,22 @@
205205
a = t/fsize;
206206
}
207207
@ %d(a):%d(b)
208208
@ </td></tr>
209209
}
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];
221215
pct = (iStored*100 + fsize/2)/fsize;
222216
approxSizeName(sizeof(zStored), zStored, iStored);
223217
@ <tr><th>Unversioned&nbsp;Files:</th><td>
224218
@ %z(href("%R/uvlist"))%d(n) files</a>,
225219
@ %s(zStored) compressed, %d(pct)%% of total repository space
226220
@ </td></tr>
227221
}
228
- db_finalize(&q);
229222
}
230223
@ <tr><th>Number&nbsp;Of&nbsp;Check-ins:</th><td>
231224
n = db_int(0, "SELECT count(*) FROM event WHERE type='ci' /*scan*/");
232225
@ %,d(n)
233226
@ </td></tr>
@@ -410,10 +403,21 @@
410403
}else{
411404
b = 1;
412405
}
413406
a = t/fsize;
414407
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
+ }
415419
}
416420
n = db_int(0, "SELECT COUNT(*) FROM event e WHERE e.type='ci'");
417421
fossil_print("%*s%,d\n", colWidth, "check-ins:", n);
418422
n = db_int(0, "SELECT count(*) FROM filename /*scan*/");
419423
fossil_print("%*s%,d across all branches\n", colWidth, "files:", n);
420424
--- 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&nbsp;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&nbsp;Of&nbsp;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&nbsp;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&nbsp;Of&nbsp;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
--- src/unversioned.c
+++ src/unversioned.c
@@ -768,5 +768,30 @@
768768
}
769769
db_finalize(&q);
770770
blob_appendf(&json,"]\n");
771771
cgi_set_content(&json);
772772
}
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
+}
773798
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button