Fossil SCM
Add a page (admin access only) to show the repository schema. Fix a bug in the "Last Rebuilt" display.
Commit
3ea94847d19c078df177de8de9813116f5fb2463
Parent
0830c352ff3ddde…
2 files changed
-5
+27
-2
M
src/db.c
-5
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1805,15 +1805,10 @@ | ||
| 1805 | 1805 | char *db_get_mtime(const char *zName, char *zFormat, char *zDefault){ |
| 1806 | 1806 | char *z = 0; |
| 1807 | 1807 | if( g.repositoryOpen ){ |
| 1808 | 1808 | z = db_text(0, "SELECT mtime FROM config WHERE name=%Q", zName); |
| 1809 | 1809 | } |
| 1810 | - if( z==0 && g.zConfigDbName ){ | |
| 1811 | - db_swap_connections(); | |
| 1812 | - z = db_text(0, "SELECT mtime FROM global_config WHERE name=%Q", zName); | |
| 1813 | - db_swap_connections(); | |
| 1814 | - } | |
| 1815 | 1810 | if( z==0 ){ |
| 1816 | 1811 | z = zDefault; |
| 1817 | 1812 | }else if( zFormat!=0 ){ |
| 1818 | 1813 | z = db_text(0, "SELECT strftime(%Q,%Q,'unixepoch');", zFormat, z); |
| 1819 | 1814 | } |
| 1820 | 1815 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1805,15 +1805,10 @@ | |
| 1805 | char *db_get_mtime(const char *zName, char *zFormat, char *zDefault){ |
| 1806 | char *z = 0; |
| 1807 | if( g.repositoryOpen ){ |
| 1808 | z = db_text(0, "SELECT mtime FROM config WHERE name=%Q", zName); |
| 1809 | } |
| 1810 | if( z==0 && g.zConfigDbName ){ |
| 1811 | db_swap_connections(); |
| 1812 | z = db_text(0, "SELECT mtime FROM global_config WHERE name=%Q", zName); |
| 1813 | db_swap_connections(); |
| 1814 | } |
| 1815 | if( z==0 ){ |
| 1816 | z = zDefault; |
| 1817 | }else if( zFormat!=0 ){ |
| 1818 | z = db_text(0, "SELECT strftime(%Q,%Q,'unixepoch');", zFormat, z); |
| 1819 | } |
| 1820 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1805,15 +1805,10 @@ | |
| 1805 | char *db_get_mtime(const char *zName, char *zFormat, char *zDefault){ |
| 1806 | char *z = 0; |
| 1807 | if( g.repositoryOpen ){ |
| 1808 | z = db_text(0, "SELECT mtime FROM config WHERE name=%Q", zName); |
| 1809 | } |
| 1810 | if( z==0 ){ |
| 1811 | z = zDefault; |
| 1812 | }else if( zFormat!=0 ){ |
| 1813 | z = db_text(0, "SELECT strftime(%Q,%Q,'unixepoch');", zFormat, z); |
| 1814 | } |
| 1815 |
+27
-2
| --- src/stat.c | ||
| +++ src/stat.c | ||
| @@ -55,10 +55,11 @@ | ||
| 55 | 55 | if( !g.perm.Read ){ login_needed(); return; } |
| 56 | 56 | brief = P("brief")!=0; |
| 57 | 57 | style_header("Repository Statistics"); |
| 58 | 58 | if( g.perm.Admin ){ |
| 59 | 59 | style_submenu_element("URLs", "URLs and Checkouts", "urllist"); |
| 60 | + style_submenu_element("Schema", "Repository Schema", "repo_schema"); | |
| 60 | 61 | } |
| 61 | 62 | @ <table class="label-value"> |
| 62 | 63 | @ <tr><th>Repository Size:</th><td> |
| 63 | 64 | fsize = file_size(g.zRepositoryName); |
| 64 | 65 | bigSizeName(sizeof(zBuf), zBuf, fsize); |
| @@ -237,12 +238,10 @@ | ||
| 237 | 238 | db_text(0, "PRAGMA %s.encoding", zDb), |
| 238 | 239 | db_text(0, "PRAGMA %s.journal_mode", zDb)); |
| 239 | 240 | |
| 240 | 241 | } |
| 241 | 242 | |
| 242 | - | |
| 243 | - | |
| 244 | 243 | /* |
| 245 | 244 | ** WEBPAGE: urllist |
| 246 | 245 | ** |
| 247 | 246 | ** Show ways in which this repository has been accessed |
| 248 | 247 | */ |
| @@ -252,10 +251,11 @@ | ||
| 252 | 251 | login_check_credentials(); |
| 253 | 252 | if( !g.perm.Admin ){ login_needed(); return; } |
| 254 | 253 | |
| 255 | 254 | style_header("URLs and Checkouts"); |
| 256 | 255 | style_submenu_element("Stat", "Repository Stats", "stat"); |
| 256 | + style_submenu_element("Schema", "Repository Schema", "repo_schema"); | |
| 257 | 257 | @ <div class="section">URLs</div> |
| 258 | 258 | @ <table border="0" width='100%%'> |
| 259 | 259 | db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch')" |
| 260 | 260 | " FROM config WHERE name GLOB 'baseurl:*' ORDER BY 2 DESC"); |
| 261 | 261 | cnt = 0; |
| @@ -284,5 +284,30 @@ | ||
| 284 | 284 | @ <tr><td>(none)</td> |
| 285 | 285 | } |
| 286 | 286 | @ </table> |
| 287 | 287 | style_footer(); |
| 288 | 288 | } |
| 289 | + | |
| 290 | +/* | |
| 291 | +** WEBPAGE: repo_schema | |
| 292 | +** | |
| 293 | +** Show the repository schema | |
| 294 | +*/ | |
| 295 | +void repo_schema_page(void){ | |
| 296 | + Stmt q; | |
| 297 | + int cnt; | |
| 298 | + login_check_credentials(); | |
| 299 | + if( !g.perm.Admin ){ login_needed(); return; } | |
| 300 | + | |
| 301 | + style_header("Repository Schema"); | |
| 302 | + style_submenu_element("Stat", "Repository Stats", "stat"); | |
| 303 | + style_submenu_element("URLs", "URLs and Checkouts", "urllist"); | |
| 304 | + db_prepare(&q, "SELECT sql FROM %s.sqlite_master WHERE sql IS NOT NULL", | |
| 305 | + db_name("repository")); | |
| 306 | + @ <pre> | |
| 307 | + while( db_step(&q)==SQLITE_ROW ){ | |
| 308 | + @ %h(db_column_text(&q, 0)); | |
| 309 | + } | |
| 310 | + @ </pre> | |
| 311 | + db_finalize(&q); | |
| 312 | + style_footer(); | |
| 313 | +} | |
| 289 | 314 |
| --- src/stat.c | |
| +++ src/stat.c | |
| @@ -55,10 +55,11 @@ | |
| 55 | if( !g.perm.Read ){ login_needed(); return; } |
| 56 | brief = P("brief")!=0; |
| 57 | style_header("Repository Statistics"); |
| 58 | if( g.perm.Admin ){ |
| 59 | style_submenu_element("URLs", "URLs and Checkouts", "urllist"); |
| 60 | } |
| 61 | @ <table class="label-value"> |
| 62 | @ <tr><th>Repository Size:</th><td> |
| 63 | fsize = file_size(g.zRepositoryName); |
| 64 | bigSizeName(sizeof(zBuf), zBuf, fsize); |
| @@ -237,12 +238,10 @@ | |
| 237 | db_text(0, "PRAGMA %s.encoding", zDb), |
| 238 | db_text(0, "PRAGMA %s.journal_mode", zDb)); |
| 239 | |
| 240 | } |
| 241 | |
| 242 | |
| 243 | |
| 244 | /* |
| 245 | ** WEBPAGE: urllist |
| 246 | ** |
| 247 | ** Show ways in which this repository has been accessed |
| 248 | */ |
| @@ -252,10 +251,11 @@ | |
| 252 | login_check_credentials(); |
| 253 | if( !g.perm.Admin ){ login_needed(); return; } |
| 254 | |
| 255 | style_header("URLs and Checkouts"); |
| 256 | style_submenu_element("Stat", "Repository Stats", "stat"); |
| 257 | @ <div class="section">URLs</div> |
| 258 | @ <table border="0" width='100%%'> |
| 259 | db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch')" |
| 260 | " FROM config WHERE name GLOB 'baseurl:*' ORDER BY 2 DESC"); |
| 261 | cnt = 0; |
| @@ -284,5 +284,30 @@ | |
| 284 | @ <tr><td>(none)</td> |
| 285 | } |
| 286 | @ </table> |
| 287 | style_footer(); |
| 288 | } |
| 289 |
| --- src/stat.c | |
| +++ src/stat.c | |
| @@ -55,10 +55,11 @@ | |
| 55 | if( !g.perm.Read ){ login_needed(); return; } |
| 56 | brief = P("brief")!=0; |
| 57 | style_header("Repository Statistics"); |
| 58 | if( g.perm.Admin ){ |
| 59 | style_submenu_element("URLs", "URLs and Checkouts", "urllist"); |
| 60 | style_submenu_element("Schema", "Repository Schema", "repo_schema"); |
| 61 | } |
| 62 | @ <table class="label-value"> |
| 63 | @ <tr><th>Repository Size:</th><td> |
| 64 | fsize = file_size(g.zRepositoryName); |
| 65 | bigSizeName(sizeof(zBuf), zBuf, fsize); |
| @@ -237,12 +238,10 @@ | |
| 238 | db_text(0, "PRAGMA %s.encoding", zDb), |
| 239 | db_text(0, "PRAGMA %s.journal_mode", zDb)); |
| 240 | |
| 241 | } |
| 242 | |
| 243 | /* |
| 244 | ** WEBPAGE: urllist |
| 245 | ** |
| 246 | ** Show ways in which this repository has been accessed |
| 247 | */ |
| @@ -252,10 +251,11 @@ | |
| 251 | login_check_credentials(); |
| 252 | if( !g.perm.Admin ){ login_needed(); return; } |
| 253 | |
| 254 | style_header("URLs and Checkouts"); |
| 255 | style_submenu_element("Stat", "Repository Stats", "stat"); |
| 256 | style_submenu_element("Schema", "Repository Schema", "repo_schema"); |
| 257 | @ <div class="section">URLs</div> |
| 258 | @ <table border="0" width='100%%'> |
| 259 | db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch')" |
| 260 | " FROM config WHERE name GLOB 'baseurl:*' ORDER BY 2 DESC"); |
| 261 | cnt = 0; |
| @@ -284,5 +284,30 @@ | |
| 284 | @ <tr><td>(none)</td> |
| 285 | } |
| 286 | @ </table> |
| 287 | style_footer(); |
| 288 | } |
| 289 | |
| 290 | /* |
| 291 | ** WEBPAGE: repo_schema |
| 292 | ** |
| 293 | ** Show the repository schema |
| 294 | */ |
| 295 | void repo_schema_page(void){ |
| 296 | Stmt q; |
| 297 | int cnt; |
| 298 | login_check_credentials(); |
| 299 | if( !g.perm.Admin ){ login_needed(); return; } |
| 300 | |
| 301 | style_header("Repository Schema"); |
| 302 | style_submenu_element("Stat", "Repository Stats", "stat"); |
| 303 | style_submenu_element("URLs", "URLs and Checkouts", "urllist"); |
| 304 | db_prepare(&q, "SELECT sql FROM %s.sqlite_master WHERE sql IS NOT NULL", |
| 305 | db_name("repository")); |
| 306 | @ <pre> |
| 307 | while( db_step(&q)==SQLITE_ROW ){ |
| 308 | @ %h(db_column_text(&q, 0)); |
| 309 | } |
| 310 | @ </pre> |
| 311 | db_finalize(&q); |
| 312 | style_footer(); |
| 313 | } |
| 314 |