Fossil SCM

Improve the /urllist page so that it shows all servers with which the repository has synced.

drh 2021-08-15 00:43 trunk
Commit 89e5c03a326933dd5ba93cdcf1ef4c29a00b1dc3243cd96b359659fd14f575f1
2 files changed +24 -17 +11
+24 -17
--- src/stat.c
+++ src/stat.c
@@ -491,11 +491,11 @@
491491
style_header("URLs and Checkouts");
492492
style_adunit_config(ADUNIT_RIGHT_OK);
493493
style_submenu_element("Stat", "stat");
494494
style_submenu_element("Schema", "repo_schema");
495495
iNow = db_int64(0, "SELECT strftime('%%s','now')");
496
- @ <div class="section">URLs</div>
496
+ @ <div class="section">URLs used to access</div>
497497
@ <table border="0" width='100%%'>
498498
db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch'), mtime"
499499
" FROM config WHERE name GLOB 'baseurl:*' ORDER BY 3 DESC");
500500
cnt = 0;
501501
nOmitted = 0;
@@ -513,38 +513,45 @@
513513
@ <tr><td>(none)</td>
514514
}else if( nOmitted ){
515515
@ <tr><td><a href="urllist?all"><i>Show %d(nOmitted) more...</i></a>
516516
}
517517
@ </table>
518
- @ <div class="section">Checkouts</div>
519
- @ <table border="0" width='100%%'>
520518
db_prepare(&q, "SELECT substr(name,7), datetime(mtime,'unixepoch')"
521519
" FROM config WHERE name GLOB 'ckout:*' ORDER BY 2 DESC");
522520
cnt = 0;
523521
while( db_step(&q)==SQLITE_ROW ){
524522
const char *zPath = db_column_text(&q,0);
525523
if( vfile_top_of_checkout(zPath) ){
524
+ if( cnt==0 ){
525
+ @ <div class="section">Checkouts</div>
526
+ @ <table border="0" width='100%%'>
527
+ }
526528
@ <tr><td width='100%%'>%h(zPath)</td>
527529
@ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr>
530
+ cnt++;
531
+ }
532
+ }
533
+ db_finalize(&q);
534
+ if( cnt ){
535
+ @ </table>
536
+ }
537
+ cnt = 0;
538
+ db_prepare(&q, "SELECT substr(name,10), datetime(mtime,'unixepoch')"
539
+ " FROM config WHERE name GLOB 'syncwith:*' ORDER BY 2 DESC");
540
+ while( db_step(&q)==SQLITE_ROW ){
541
+ const char *zURL = db_column_text(&q,0);
542
+ if( cnt==0 ){
543
+ @ <div class="section">Sync to these URLs</div>
544
+ @ <table border='0' width='100%%'>
528545
}
546
+ @ <tr><td width='100%%'><a href='%h(zURL)'>%h(zURL)</a>
547
+ @ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr>
529548
cnt++;
530549
}
531550
db_finalize(&q);
532
- if( cnt==0 ){
533
- @ <tr><td>(none)</td>
534
- }
535
- @ </table>
536
- zRemote = db_text(0, "SELECT value FROM config WHERE name='last-sync-url'");
537
- if( zRemote ){
538
- @ <div class="section">Last Sync URL</div>
539
- if( sqlite3_strlike("http%", zRemote, 0)==0 ){
540
- UrlData x;
541
- url_parse_local(zRemote, URL_OMIT_USER, &x);
542
- @ <p><a href='%h(x.canonical)'>%h(zRemote)</a>
543
- }else{
544
- @ <p>%h(zRemote)</p>
545
- }
551
+ if( cnt ){
552
+ @ </table>
546553
}
547554
cnt = 0;
548555
db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch')"
549556
" FROM config WHERE name GLOB 'gitpush:*' ORDER BY 2 DESC");
550557
while( db_step(&q)==SQLITE_ROW ){
551558
--- src/stat.c
+++ src/stat.c
@@ -491,11 +491,11 @@
491 style_header("URLs and Checkouts");
492 style_adunit_config(ADUNIT_RIGHT_OK);
493 style_submenu_element("Stat", "stat");
494 style_submenu_element("Schema", "repo_schema");
495 iNow = db_int64(0, "SELECT strftime('%%s','now')");
496 @ <div class="section">URLs</div>
497 @ <table border="0" width='100%%'>
498 db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch'), mtime"
499 " FROM config WHERE name GLOB 'baseurl:*' ORDER BY 3 DESC");
500 cnt = 0;
501 nOmitted = 0;
@@ -513,38 +513,45 @@
513 @ <tr><td>(none)</td>
514 }else if( nOmitted ){
515 @ <tr><td><a href="urllist?all"><i>Show %d(nOmitted) more...</i></a>
516 }
517 @ </table>
518 @ <div class="section">Checkouts</div>
519 @ <table border="0" width='100%%'>
520 db_prepare(&q, "SELECT substr(name,7), datetime(mtime,'unixepoch')"
521 " FROM config WHERE name GLOB 'ckout:*' ORDER BY 2 DESC");
522 cnt = 0;
523 while( db_step(&q)==SQLITE_ROW ){
524 const char *zPath = db_column_text(&q,0);
525 if( vfile_top_of_checkout(zPath) ){
 
 
 
 
526 @ <tr><td width='100%%'>%h(zPath)</td>
527 @ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
528 }
 
 
529 cnt++;
530 }
531 db_finalize(&q);
532 if( cnt==0 ){
533 @ <tr><td>(none)</td>
534 }
535 @ </table>
536 zRemote = db_text(0, "SELECT value FROM config WHERE name='last-sync-url'");
537 if( zRemote ){
538 @ <div class="section">Last Sync URL</div>
539 if( sqlite3_strlike("http%", zRemote, 0)==0 ){
540 UrlData x;
541 url_parse_local(zRemote, URL_OMIT_USER, &x);
542 @ <p><a href='%h(x.canonical)'>%h(zRemote)</a>
543 }else{
544 @ <p>%h(zRemote)</p>
545 }
546 }
547 cnt = 0;
548 db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch')"
549 " FROM config WHERE name GLOB 'gitpush:*' ORDER BY 2 DESC");
550 while( db_step(&q)==SQLITE_ROW ){
551
--- src/stat.c
+++ src/stat.c
@@ -491,11 +491,11 @@
491 style_header("URLs and Checkouts");
492 style_adunit_config(ADUNIT_RIGHT_OK);
493 style_submenu_element("Stat", "stat");
494 style_submenu_element("Schema", "repo_schema");
495 iNow = db_int64(0, "SELECT strftime('%%s','now')");
496 @ <div class="section">URLs used to access</div>
497 @ <table border="0" width='100%%'>
498 db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch'), mtime"
499 " FROM config WHERE name GLOB 'baseurl:*' ORDER BY 3 DESC");
500 cnt = 0;
501 nOmitted = 0;
@@ -513,38 +513,45 @@
513 @ <tr><td>(none)</td>
514 }else if( nOmitted ){
515 @ <tr><td><a href="urllist?all"><i>Show %d(nOmitted) more...</i></a>
516 }
517 @ </table>
 
 
518 db_prepare(&q, "SELECT substr(name,7), datetime(mtime,'unixepoch')"
519 " FROM config WHERE name GLOB 'ckout:*' ORDER BY 2 DESC");
520 cnt = 0;
521 while( db_step(&q)==SQLITE_ROW ){
522 const char *zPath = db_column_text(&q,0);
523 if( vfile_top_of_checkout(zPath) ){
524 if( cnt==0 ){
525 @ <div class="section">Checkouts</div>
526 @ <table border="0" width='100%%'>
527 }
528 @ <tr><td width='100%%'>%h(zPath)</td>
529 @ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr>
530 cnt++;
531 }
532 }
533 db_finalize(&q);
534 if( cnt ){
535 @ </table>
536 }
537 cnt = 0;
538 db_prepare(&q, "SELECT substr(name,10), datetime(mtime,'unixepoch')"
539 " FROM config WHERE name GLOB 'syncwith:*' ORDER BY 2 DESC");
540 while( db_step(&q)==SQLITE_ROW ){
541 const char *zURL = db_column_text(&q,0);
542 if( cnt==0 ){
543 @ <div class="section">Sync to these URLs</div>
544 @ <table border='0' width='100%%'>
545 }
546 @ <tr><td width='100%%'><a href='%h(zURL)'>%h(zURL)</a>
547 @ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr>
548 cnt++;
549 }
550 db_finalize(&q);
551 if( cnt ){
552 @ </table>
 
 
 
 
 
 
 
 
 
 
 
 
553 }
554 cnt = 0;
555 db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch')"
556 " FROM config WHERE name GLOB 'gitpush:*' ORDER BY 2 DESC");
557 while( db_step(&q)==SQLITE_ROW ){
558
+11
--- src/xfer.c
+++ src/xfer.c
@@ -2132,15 +2132,26 @@
21322132
mHttpFlags = HTTP_USE_LOGIN;
21332133
}
21342134
if( syncFlags & SYNC_NOHTTPCOMPRESS ){
21352135
mHttpFlags |= HTTP_NOCOMPRESS;
21362136
}
2137
+
2138
+ /* Do the round-trip to the server */
21372139
if( http_exchange(&send, &recv, mHttpFlags, MAX_REDIRECTS, 0) ){
21382140
nErr++;
21392141
go = 2;
21402142
break;
21412143
}
2144
+
2145
+ /* Remember the URL of the sync target in the config file on the
2146
+ ** first successful round-trip */
2147
+ if( nCycle==0 && db_is_writeable("repository") ){
2148
+ db_unprotect(PROTECT_CONFIG);
2149
+ db_multi_exec("REPLACE INTO config(name,value,mtime)"
2150
+ "VALUES('syncwith:%q',1,now())", g.url.canonical);
2151
+ db_protect_pop();
2152
+ }
21422153
21432154
/* Output current stats */
21442155
if( syncFlags & SYNC_VERBOSE ){
21452156
fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Sent:",
21462157
blob_size(&send), nCardSent+xfer.nGimmeSent+xfer.nIGotSent,
21472158
--- src/xfer.c
+++ src/xfer.c
@@ -2132,15 +2132,26 @@
2132 mHttpFlags = HTTP_USE_LOGIN;
2133 }
2134 if( syncFlags & SYNC_NOHTTPCOMPRESS ){
2135 mHttpFlags |= HTTP_NOCOMPRESS;
2136 }
 
 
2137 if( http_exchange(&send, &recv, mHttpFlags, MAX_REDIRECTS, 0) ){
2138 nErr++;
2139 go = 2;
2140 break;
2141 }
 
 
 
 
 
 
 
 
 
2142
2143 /* Output current stats */
2144 if( syncFlags & SYNC_VERBOSE ){
2145 fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Sent:",
2146 blob_size(&send), nCardSent+xfer.nGimmeSent+xfer.nIGotSent,
2147
--- src/xfer.c
+++ src/xfer.c
@@ -2132,15 +2132,26 @@
2132 mHttpFlags = HTTP_USE_LOGIN;
2133 }
2134 if( syncFlags & SYNC_NOHTTPCOMPRESS ){
2135 mHttpFlags |= HTTP_NOCOMPRESS;
2136 }
2137
2138 /* Do the round-trip to the server */
2139 if( http_exchange(&send, &recv, mHttpFlags, MAX_REDIRECTS, 0) ){
2140 nErr++;
2141 go = 2;
2142 break;
2143 }
2144
2145 /* Remember the URL of the sync target in the config file on the
2146 ** first successful round-trip */
2147 if( nCycle==0 && db_is_writeable("repository") ){
2148 db_unprotect(PROTECT_CONFIG);
2149 db_multi_exec("REPLACE INTO config(name,value,mtime)"
2150 "VALUES('syncwith:%q',1,now())", g.url.canonical);
2151 db_protect_pop();
2152 }
2153
2154 /* Output current stats */
2155 if( syncFlags & SYNC_VERBOSE ){
2156 fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Sent:",
2157 blob_size(&send), nCardSent+xfer.nGimmeSent+xfer.nIGotSent,
2158

Keyboard Shortcuts

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