Fossil SCM
Improvements to the /urllist page → the sync URLs and Git mirrors are combined into a single section. Add the url_unparse() interface for freeing memory from a url_parse_local().
Commit
9bdbcd39cb71ce9df1d28f69d22414f088c5467c0d03e40408bf40a998d9da2e
Parent
a004b1729c419c4…
2 files changed
+15
-21
+19
-2
+15
-21
| --- src/stat.c | ||
| +++ src/stat.c | ||
| @@ -490,11 +490,11 @@ | ||
| 490 | 490 | style_header("URLs and Checkouts"); |
| 491 | 491 | style_adunit_config(ADUNIT_RIGHT_OK); |
| 492 | 492 | style_submenu_element("Stat", "stat"); |
| 493 | 493 | style_submenu_element("Schema", "repo_schema"); |
| 494 | 494 | iNow = db_int64(0, "SELECT strftime('%%s','now')"); |
| 495 | - @ <div class="section">URLs used to access</div> | |
| 495 | + @ <div class="section">URLs used to access this repository</div> | |
| 496 | 496 | @ <table border="0" width='100%%'> |
| 497 | 497 | db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch'), mtime" |
| 498 | 498 | " FROM config WHERE name GLOB 'baseurl:*' ORDER BY 3 DESC"); |
| 499 | 499 | cnt = 0; |
| 500 | 500 | nOmitted = 0; |
| @@ -532,40 +532,34 @@ | ||
| 532 | 532 | db_finalize(&q); |
| 533 | 533 | if( cnt ){ |
| 534 | 534 | @ </table> |
| 535 | 535 | } |
| 536 | 536 | cnt = 0; |
| 537 | - db_prepare(&q, "SELECT substr(name,10), datetime(mtime,'unixepoch')" | |
| 538 | - " FROM config WHERE name GLOB 'syncwith:*' ORDER BY 2 DESC"); | |
| 539 | - while( db_step(&q)==SQLITE_ROW ){ | |
| 540 | - const char *zURL = db_column_text(&q,0); | |
| 541 | - if( cnt==0 ){ | |
| 542 | - @ <div class="section">Sync to these URLs</div> | |
| 543 | - @ <table border='0' width='100%%'> | |
| 544 | - } | |
| 545 | - @ <tr><td width='100%%'><a href='%h(zURL)'>%h(zURL)</a> | |
| 546 | - @ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr> | |
| 547 | - cnt++; | |
| 548 | - } | |
| 549 | - db_finalize(&q); | |
| 550 | - if( cnt ){ | |
| 551 | - @ </table> | |
| 552 | - } | |
| 553 | - cnt = 0; | |
| 554 | - db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch')" | |
| 555 | - " FROM config WHERE name GLOB 'gitpush:*' ORDER BY 2 DESC"); | |
| 537 | + db_prepare(&q, | |
| 538 | + "SELECT substr(name,10), datetime(mtime,'unixepoch')" | |
| 539 | + " FROM config WHERE name GLOB 'syncwith:*'" | |
| 540 | + "UNION ALL " | |
| 541 | + "SELECT substr(name,10), datetime(mtime,'unixepoch')" | |
| 542 | + " FROM config WHERE name GLOB 'syncfrom:*'" | |
| 543 | + "UNION ALL " | |
| 544 | + "SELECT substr(name,9), datetime(mtime,'unixepoch')" | |
| 545 | + " FROM config WHERE name GLOB 'gitpush:*'" | |
| 546 | + "ORDER BY 2 DESC" | |
| 547 | + ); | |
| 556 | 548 | while( db_step(&q)==SQLITE_ROW ){ |
| 557 | 549 | const char *zURL = db_column_text(&q,0); |
| 558 | 550 | UrlData x; |
| 559 | 551 | if( cnt==0 ){ |
| 560 | - @ <div class="section">Git Mirrors</div> | |
| 552 | + @ <div class="section">Sync with these URLs</div> | |
| 561 | 553 | @ <table border='0' width='100%%'> |
| 562 | 554 | } |
| 555 | + memset(&x, 0, sizeof(x)); | |
| 563 | 556 | url_parse_local(zURL, URL_OMIT_USER, &x); |
| 564 | 557 | @ <tr><td width='100%%'><a href='%h(x.canonical)'>%h(x.canonical)</a> |
| 565 | 558 | @ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr> |
| 566 | 559 | cnt++; |
| 560 | + url_unparse(&x); | |
| 567 | 561 | } |
| 568 | 562 | db_finalize(&q); |
| 569 | 563 | if( cnt ){ |
| 570 | 564 | @ </table> |
| 571 | 565 | } |
| 572 | 566 |
| --- src/stat.c | |
| +++ src/stat.c | |
| @@ -490,11 +490,11 @@ | |
| 490 | style_header("URLs and Checkouts"); |
| 491 | style_adunit_config(ADUNIT_RIGHT_OK); |
| 492 | style_submenu_element("Stat", "stat"); |
| 493 | style_submenu_element("Schema", "repo_schema"); |
| 494 | iNow = db_int64(0, "SELECT strftime('%%s','now')"); |
| 495 | @ <div class="section">URLs used to access</div> |
| 496 | @ <table border="0" width='100%%'> |
| 497 | db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch'), mtime" |
| 498 | " FROM config WHERE name GLOB 'baseurl:*' ORDER BY 3 DESC"); |
| 499 | cnt = 0; |
| 500 | nOmitted = 0; |
| @@ -532,40 +532,34 @@ | |
| 532 | db_finalize(&q); |
| 533 | if( cnt ){ |
| 534 | @ </table> |
| 535 | } |
| 536 | cnt = 0; |
| 537 | db_prepare(&q, "SELECT substr(name,10), datetime(mtime,'unixepoch')" |
| 538 | " FROM config WHERE name GLOB 'syncwith:*' ORDER BY 2 DESC"); |
| 539 | while( db_step(&q)==SQLITE_ROW ){ |
| 540 | const char *zURL = db_column_text(&q,0); |
| 541 | if( cnt==0 ){ |
| 542 | @ <div class="section">Sync to these URLs</div> |
| 543 | @ <table border='0' width='100%%'> |
| 544 | } |
| 545 | @ <tr><td width='100%%'><a href='%h(zURL)'>%h(zURL)</a> |
| 546 | @ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr> |
| 547 | cnt++; |
| 548 | } |
| 549 | db_finalize(&q); |
| 550 | if( cnt ){ |
| 551 | @ </table> |
| 552 | } |
| 553 | cnt = 0; |
| 554 | db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch')" |
| 555 | " FROM config WHERE name GLOB 'gitpush:*' ORDER BY 2 DESC"); |
| 556 | while( db_step(&q)==SQLITE_ROW ){ |
| 557 | const char *zURL = db_column_text(&q,0); |
| 558 | UrlData x; |
| 559 | if( cnt==0 ){ |
| 560 | @ <div class="section">Git Mirrors</div> |
| 561 | @ <table border='0' width='100%%'> |
| 562 | } |
| 563 | url_parse_local(zURL, URL_OMIT_USER, &x); |
| 564 | @ <tr><td width='100%%'><a href='%h(x.canonical)'>%h(x.canonical)</a> |
| 565 | @ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr> |
| 566 | cnt++; |
| 567 | } |
| 568 | db_finalize(&q); |
| 569 | if( cnt ){ |
| 570 | @ </table> |
| 571 | } |
| 572 |
| --- src/stat.c | |
| +++ src/stat.c | |
| @@ -490,11 +490,11 @@ | |
| 490 | style_header("URLs and Checkouts"); |
| 491 | style_adunit_config(ADUNIT_RIGHT_OK); |
| 492 | style_submenu_element("Stat", "stat"); |
| 493 | style_submenu_element("Schema", "repo_schema"); |
| 494 | iNow = db_int64(0, "SELECT strftime('%%s','now')"); |
| 495 | @ <div class="section">URLs used to access this repository</div> |
| 496 | @ <table border="0" width='100%%'> |
| 497 | db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch'), mtime" |
| 498 | " FROM config WHERE name GLOB 'baseurl:*' ORDER BY 3 DESC"); |
| 499 | cnt = 0; |
| 500 | nOmitted = 0; |
| @@ -532,40 +532,34 @@ | |
| 532 | db_finalize(&q); |
| 533 | if( cnt ){ |
| 534 | @ </table> |
| 535 | } |
| 536 | cnt = 0; |
| 537 | db_prepare(&q, |
| 538 | "SELECT substr(name,10), datetime(mtime,'unixepoch')" |
| 539 | " FROM config WHERE name GLOB 'syncwith:*'" |
| 540 | "UNION ALL " |
| 541 | "SELECT substr(name,10), datetime(mtime,'unixepoch')" |
| 542 | " FROM config WHERE name GLOB 'syncfrom:*'" |
| 543 | "UNION ALL " |
| 544 | "SELECT substr(name,9), datetime(mtime,'unixepoch')" |
| 545 | " FROM config WHERE name GLOB 'gitpush:*'" |
| 546 | "ORDER BY 2 DESC" |
| 547 | ); |
| 548 | while( db_step(&q)==SQLITE_ROW ){ |
| 549 | const char *zURL = db_column_text(&q,0); |
| 550 | UrlData x; |
| 551 | if( cnt==0 ){ |
| 552 | @ <div class="section">Sync with these URLs</div> |
| 553 | @ <table border='0' width='100%%'> |
| 554 | } |
| 555 | memset(&x, 0, sizeof(x)); |
| 556 | url_parse_local(zURL, URL_OMIT_USER, &x); |
| 557 | @ <tr><td width='100%%'><a href='%h(x.canonical)'>%h(x.canonical)</a> |
| 558 | @ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr> |
| 559 | cnt++; |
| 560 | url_unparse(&x); |
| 561 | } |
| 562 | db_finalize(&q); |
| 563 | if( cnt ){ |
| 564 | @ </table> |
| 565 | } |
| 566 |
+19
-2
| --- src/url.c | ||
| +++ src/url.c | ||
| @@ -227,24 +227,25 @@ | ||
| 227 | 227 | i++; |
| 228 | 228 | } |
| 229 | 229 | if( fossil_strcmp(zName,"fossil")==0 ){ |
| 230 | 230 | pUrlData->fossil = zValue; |
| 231 | 231 | dehttpize(pUrlData->fossil); |
| 232 | + fossil_free(zExe); | |
| 232 | 233 | zExe = mprintf("%cfossil=%T", cQuerySep, pUrlData->fossil); |
| 233 | 234 | cQuerySep = '&'; |
| 234 | 235 | } |
| 235 | 236 | } |
| 236 | 237 | |
| 237 | 238 | dehttpize(pUrlData->path); |
| 238 | 239 | if( pUrlData->dfltPort==pUrlData->port ){ |
| 239 | 240 | pUrlData->canonical = mprintf( |
| 240 | - "%s://%s%T%T%s", | |
| 241 | + "%s://%s%T%T%z", | |
| 241 | 242 | pUrlData->protocol, zLogin, pUrlData->name, pUrlData->path, zExe |
| 242 | 243 | ); |
| 243 | 244 | }else{ |
| 244 | 245 | pUrlData->canonical = mprintf( |
| 245 | - "%s://%s%T:%d%T%s", | |
| 246 | + "%s://%s%T:%d%T%z", | |
| 246 | 247 | pUrlData->protocol, zLogin, pUrlData->name, pUrlData->port, |
| 247 | 248 | pUrlData->path, zExe |
| 248 | 249 | ); |
| 249 | 250 | } |
| 250 | 251 | if( pUrlData->isSsh && pUrlData->path[1] ) pUrlData->path++; |
| @@ -295,10 +296,25 @@ | ||
| 295 | 296 | pUrlData->flags = urlFlags &= ~URL_REMEMBER_PW; |
| 296 | 297 | } |
| 297 | 298 | } |
| 298 | 299 | } |
| 299 | 300 | } |
| 301 | + | |
| 302 | +/* | |
| 303 | +** Reclaim malloced memory from a UrlData object | |
| 304 | +*/ | |
| 305 | +void url_unparse(UrlData *p){ | |
| 306 | + if( p==0 ){ | |
| 307 | + p = &g.url; | |
| 308 | + } | |
| 309 | + fossil_free(p->canonical); | |
| 310 | + fossil_free(p->name); | |
| 311 | + fossil_free(p->path); | |
| 312 | + fossil_free(p->user); | |
| 313 | + fossil_free(p->passwd); | |
| 314 | + memset(p, 0, sizeof(*p)); | |
| 315 | +} | |
| 300 | 316 | |
| 301 | 317 | /* |
| 302 | 318 | ** Parse the given URL, which describes a sync server. Populate variables |
| 303 | 319 | ** in the global "g.url" structure as shown below. If zUrl is NULL, then |
| 304 | 320 | ** parse the URL given in the last-sync-url setting, taking the password |
| @@ -369,10 +385,11 @@ | ||
| 369 | 385 | if( g.url.isFile || g.url.isSsh ) break; |
| 370 | 386 | if( i==0 ){ |
| 371 | 387 | fossil_print("********\n"); |
| 372 | 388 | url_enable_proxy("Using proxy: "); |
| 373 | 389 | } |
| 390 | + url_unparse(0); | |
| 374 | 391 | } |
| 375 | 392 | } |
| 376 | 393 | |
| 377 | 394 | /* |
| 378 | 395 | ** Proxy specified on the command-line using the --proxy option. |
| 379 | 396 |
| --- src/url.c | |
| +++ src/url.c | |
| @@ -227,24 +227,25 @@ | |
| 227 | i++; |
| 228 | } |
| 229 | if( fossil_strcmp(zName,"fossil")==0 ){ |
| 230 | pUrlData->fossil = zValue; |
| 231 | dehttpize(pUrlData->fossil); |
| 232 | zExe = mprintf("%cfossil=%T", cQuerySep, pUrlData->fossil); |
| 233 | cQuerySep = '&'; |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | dehttpize(pUrlData->path); |
| 238 | if( pUrlData->dfltPort==pUrlData->port ){ |
| 239 | pUrlData->canonical = mprintf( |
| 240 | "%s://%s%T%T%s", |
| 241 | pUrlData->protocol, zLogin, pUrlData->name, pUrlData->path, zExe |
| 242 | ); |
| 243 | }else{ |
| 244 | pUrlData->canonical = mprintf( |
| 245 | "%s://%s%T:%d%T%s", |
| 246 | pUrlData->protocol, zLogin, pUrlData->name, pUrlData->port, |
| 247 | pUrlData->path, zExe |
| 248 | ); |
| 249 | } |
| 250 | if( pUrlData->isSsh && pUrlData->path[1] ) pUrlData->path++; |
| @@ -295,10 +296,25 @@ | |
| 295 | pUrlData->flags = urlFlags &= ~URL_REMEMBER_PW; |
| 296 | } |
| 297 | } |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | /* |
| 302 | ** Parse the given URL, which describes a sync server. Populate variables |
| 303 | ** in the global "g.url" structure as shown below. If zUrl is NULL, then |
| 304 | ** parse the URL given in the last-sync-url setting, taking the password |
| @@ -369,10 +385,11 @@ | |
| 369 | if( g.url.isFile || g.url.isSsh ) break; |
| 370 | if( i==0 ){ |
| 371 | fossil_print("********\n"); |
| 372 | url_enable_proxy("Using proxy: "); |
| 373 | } |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | /* |
| 378 | ** Proxy specified on the command-line using the --proxy option. |
| 379 |
| --- src/url.c | |
| +++ src/url.c | |
| @@ -227,24 +227,25 @@ | |
| 227 | i++; |
| 228 | } |
| 229 | if( fossil_strcmp(zName,"fossil")==0 ){ |
| 230 | pUrlData->fossil = zValue; |
| 231 | dehttpize(pUrlData->fossil); |
| 232 | fossil_free(zExe); |
| 233 | zExe = mprintf("%cfossil=%T", cQuerySep, pUrlData->fossil); |
| 234 | cQuerySep = '&'; |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | dehttpize(pUrlData->path); |
| 239 | if( pUrlData->dfltPort==pUrlData->port ){ |
| 240 | pUrlData->canonical = mprintf( |
| 241 | "%s://%s%T%T%z", |
| 242 | pUrlData->protocol, zLogin, pUrlData->name, pUrlData->path, zExe |
| 243 | ); |
| 244 | }else{ |
| 245 | pUrlData->canonical = mprintf( |
| 246 | "%s://%s%T:%d%T%z", |
| 247 | pUrlData->protocol, zLogin, pUrlData->name, pUrlData->port, |
| 248 | pUrlData->path, zExe |
| 249 | ); |
| 250 | } |
| 251 | if( pUrlData->isSsh && pUrlData->path[1] ) pUrlData->path++; |
| @@ -295,10 +296,25 @@ | |
| 296 | pUrlData->flags = urlFlags &= ~URL_REMEMBER_PW; |
| 297 | } |
| 298 | } |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | /* |
| 303 | ** Reclaim malloced memory from a UrlData object |
| 304 | */ |
| 305 | void url_unparse(UrlData *p){ |
| 306 | if( p==0 ){ |
| 307 | p = &g.url; |
| 308 | } |
| 309 | fossil_free(p->canonical); |
| 310 | fossil_free(p->name); |
| 311 | fossil_free(p->path); |
| 312 | fossil_free(p->user); |
| 313 | fossil_free(p->passwd); |
| 314 | memset(p, 0, sizeof(*p)); |
| 315 | } |
| 316 | |
| 317 | /* |
| 318 | ** Parse the given URL, which describes a sync server. Populate variables |
| 319 | ** in the global "g.url" structure as shown below. If zUrl is NULL, then |
| 320 | ** parse the URL given in the last-sync-url setting, taking the password |
| @@ -369,10 +385,11 @@ | |
| 385 | if( g.url.isFile || g.url.isSsh ) break; |
| 386 | if( i==0 ){ |
| 387 | fossil_print("********\n"); |
| 388 | url_enable_proxy("Using proxy: "); |
| 389 | } |
| 390 | url_unparse(0); |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | /* |
| 395 | ** Proxy specified on the command-line using the --proxy option. |
| 396 |