Fossil SCM
Improve the /urllist page so that it shows all servers with which the repository has synced.
Commit
89e5c03a326933dd5ba93cdcf1ef4c29a00b1dc3243cd96b359659fd14f575f1
Parent
458b35a50717c1b…
2 files changed
+24
-17
+11
+24
-17
| --- src/stat.c | ||
| +++ src/stat.c | ||
| @@ -491,11 +491,11 @@ | ||
| 491 | 491 | style_header("URLs and Checkouts"); |
| 492 | 492 | style_adunit_config(ADUNIT_RIGHT_OK); |
| 493 | 493 | style_submenu_element("Stat", "stat"); |
| 494 | 494 | style_submenu_element("Schema", "repo_schema"); |
| 495 | 495 | iNow = db_int64(0, "SELECT strftime('%%s','now')"); |
| 496 | - @ <div class="section">URLs</div> | |
| 496 | + @ <div class="section">URLs used to access</div> | |
| 497 | 497 | @ <table border="0" width='100%%'> |
| 498 | 498 | db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch'), mtime" |
| 499 | 499 | " FROM config WHERE name GLOB 'baseurl:*' ORDER BY 3 DESC"); |
| 500 | 500 | cnt = 0; |
| 501 | 501 | nOmitted = 0; |
| @@ -513,38 +513,45 @@ | ||
| 513 | 513 | @ <tr><td>(none)</td> |
| 514 | 514 | }else if( nOmitted ){ |
| 515 | 515 | @ <tr><td><a href="urllist?all"><i>Show %d(nOmitted) more...</i></a> |
| 516 | 516 | } |
| 517 | 517 | @ </table> |
| 518 | - @ <div class="section">Checkouts</div> | |
| 519 | - @ <table border="0" width='100%%'> | |
| 520 | 518 | db_prepare(&q, "SELECT substr(name,7), datetime(mtime,'unixepoch')" |
| 521 | 519 | " FROM config WHERE name GLOB 'ckout:*' ORDER BY 2 DESC"); |
| 522 | 520 | cnt = 0; |
| 523 | 521 | while( db_step(&q)==SQLITE_ROW ){ |
| 524 | 522 | const char *zPath = db_column_text(&q,0); |
| 525 | 523 | if( vfile_top_of_checkout(zPath) ){ |
| 524 | + if( cnt==0 ){ | |
| 525 | + @ <div class="section">Checkouts</div> | |
| 526 | + @ <table border="0" width='100%%'> | |
| 527 | + } | |
| 526 | 528 | @ <tr><td width='100%%'>%h(zPath)</td> |
| 527 | 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%%'> | |
| 528 | 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> | |
| 529 | 548 | cnt++; |
| 530 | 549 | } |
| 531 | 550 | 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> | |
| 546 | 553 | } |
| 547 | 554 | cnt = 0; |
| 548 | 555 | db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch')" |
| 549 | 556 | " FROM config WHERE name GLOB 'gitpush:*' ORDER BY 2 DESC"); |
| 550 | 557 | while( db_step(&q)==SQLITE_ROW ){ |
| 551 | 558 |
| --- 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 @@ | ||
| 2132 | 2132 | mHttpFlags = HTTP_USE_LOGIN; |
| 2133 | 2133 | } |
| 2134 | 2134 | if( syncFlags & SYNC_NOHTTPCOMPRESS ){ |
| 2135 | 2135 | mHttpFlags |= HTTP_NOCOMPRESS; |
| 2136 | 2136 | } |
| 2137 | + | |
| 2138 | + /* Do the round-trip to the server */ | |
| 2137 | 2139 | if( http_exchange(&send, &recv, mHttpFlags, MAX_REDIRECTS, 0) ){ |
| 2138 | 2140 | nErr++; |
| 2139 | 2141 | go = 2; |
| 2140 | 2142 | break; |
| 2141 | 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 | + } | |
| 2142 | 2153 | |
| 2143 | 2154 | /* Output current stats */ |
| 2144 | 2155 | if( syncFlags & SYNC_VERBOSE ){ |
| 2145 | 2156 | fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Sent:", |
| 2146 | 2157 | blob_size(&send), nCardSent+xfer.nGimmeSent+xfer.nIGotSent, |
| 2147 | 2158 |
| --- 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 |