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().

drh 2021-08-17 15:41 trunk
Commit 9bdbcd39cb71ce9df1d28f69d22414f088c5467c0d03e40408bf40a998d9da2e
2 files changed +15 -21 +19 -2
+15 -21
--- src/stat.c
+++ src/stat.c
@@ -490,11 +490,11 @@
490490
style_header("URLs and Checkouts");
491491
style_adunit_config(ADUNIT_RIGHT_OK);
492492
style_submenu_element("Stat", "stat");
493493
style_submenu_element("Schema", "repo_schema");
494494
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>
496496
@ <table border="0" width='100%%'>
497497
db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch'), mtime"
498498
" FROM config WHERE name GLOB 'baseurl:*' ORDER BY 3 DESC");
499499
cnt = 0;
500500
nOmitted = 0;
@@ -532,40 +532,34 @@
532532
db_finalize(&q);
533533
if( cnt ){
534534
@ </table>
535535
}
536536
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
+ );
556548
while( db_step(&q)==SQLITE_ROW ){
557549
const char *zURL = db_column_text(&q,0);
558550
UrlData x;
559551
if( cnt==0 ){
560
- @ <div class="section">Git Mirrors</div>
552
+ @ <div class="section">Sync with these URLs</div>
561553
@ <table border='0' width='100%%'>
562554
}
555
+ memset(&x, 0, sizeof(x));
563556
url_parse_local(zURL, URL_OMIT_USER, &x);
564557
@ <tr><td width='100%%'><a href='%h(x.canonical)'>%h(x.canonical)</a>
565558
@ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr>
566559
cnt++;
560
+ url_unparse(&x);
567561
}
568562
db_finalize(&q);
569563
if( cnt ){
570564
@ </table>
571565
}
572566
--- 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 @@
227227
i++;
228228
}
229229
if( fossil_strcmp(zName,"fossil")==0 ){
230230
pUrlData->fossil = zValue;
231231
dehttpize(pUrlData->fossil);
232
+ fossil_free(zExe);
232233
zExe = mprintf("%cfossil=%T", cQuerySep, pUrlData->fossil);
233234
cQuerySep = '&';
234235
}
235236
}
236237
237238
dehttpize(pUrlData->path);
238239
if( pUrlData->dfltPort==pUrlData->port ){
239240
pUrlData->canonical = mprintf(
240
- "%s://%s%T%T%s",
241
+ "%s://%s%T%T%z",
241242
pUrlData->protocol, zLogin, pUrlData->name, pUrlData->path, zExe
242243
);
243244
}else{
244245
pUrlData->canonical = mprintf(
245
- "%s://%s%T:%d%T%s",
246
+ "%s://%s%T:%d%T%z",
246247
pUrlData->protocol, zLogin, pUrlData->name, pUrlData->port,
247248
pUrlData->path, zExe
248249
);
249250
}
250251
if( pUrlData->isSsh && pUrlData->path[1] ) pUrlData->path++;
@@ -295,10 +296,25 @@
295296
pUrlData->flags = urlFlags &= ~URL_REMEMBER_PW;
296297
}
297298
}
298299
}
299300
}
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
+}
300316
301317
/*
302318
** Parse the given URL, which describes a sync server. Populate variables
303319
** in the global "g.url" structure as shown below. If zUrl is NULL, then
304320
** parse the URL given in the last-sync-url setting, taking the password
@@ -369,10 +385,11 @@
369385
if( g.url.isFile || g.url.isSsh ) break;
370386
if( i==0 ){
371387
fossil_print("********\n");
372388
url_enable_proxy("Using proxy: ");
373389
}
390
+ url_unparse(0);
374391
}
375392
}
376393
377394
/*
378395
** Proxy specified on the command-line using the --proxy option.
379396
--- 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

Keyboard Shortcuts

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