Fossil SCM
Add code to generate "config" card for transmitting configuration information using the new format.
Commit
9522964b24384ddb0ce8a0d44315d9ce419b688d
Parent
2b4b3303b68e101…
2 files changed
+126
+1
-2
+126
| --- src/configure.c | ||
| +++ src/configure.c | ||
| @@ -480,10 +480,136 @@ | ||
| 480 | 480 | ); |
| 481 | 481 | } |
| 482 | 482 | } |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | +/* | |
| 486 | +** Send "config" cards using the new format for all elements of a group | |
| 487 | +** that have recently changed. | |
| 488 | +** | |
| 489 | +** Output goes into pOut. The groupMask identifies the group(s) to be sent. | |
| 490 | +** Send only entries whose timestamp is later than or equal to iStart. | |
| 491 | +*/ | |
| 492 | +void configure_send_group( | |
| 493 | + Blob *pOut, /* Write output here */ | |
| 494 | + int groupMask, /* Mask of groups to be send */ | |
| 495 | + sqlite3_int64 iStart /* Only write values changed since this time */ | |
| 496 | +){ | |
| 497 | + Stmt q; | |
| 498 | + Blob rec; | |
| 499 | + int ii; | |
| 500 | + | |
| 501 | + blob_zero(&rec); | |
| 502 | + if( groupMask & CONFIGSET_SHUN ){ | |
| 503 | + db_prepare(&q, "SELECT mtime, quote(uuid), quote(scom) FROM shun" | |
| 504 | + " WHERE mtime>=%lld", iStart); | |
| 505 | + while( db_step(&q)==SQLITE_ROW ){ | |
| 506 | + blob_appendf(&rec,"%s %s scom %s\n", | |
| 507 | + db_column_text(&q, 0), | |
| 508 | + db_column_text(&q, 1), | |
| 509 | + db_column_text(&q, 2) | |
| 510 | + ); | |
| 511 | + blob_appendf(pOut, "config /shun %d\n%s", | |
| 512 | + blob_size(&rec), blob_str(&rec)); | |
| 513 | + blob_reset(&rec); | |
| 514 | + } | |
| 515 | + db_finalize(&q); | |
| 516 | + } | |
| 517 | + if( groupMask & CONFIGSET_USER ){ | |
| 518 | + db_prepare(&q, "SELECT mtime, quote(login), quote(pw), quote(cap)," | |
| 519 | + " quote(info), quote(photo) FROM user" | |
| 520 | + " WHERE mtime>=%lld", iStart); | |
| 521 | + while( db_step(&q)==SQLITE_ROW ){ | |
| 522 | + blob_appendf(&rec,"%s %s pw %s cap %s info %s photo %s\n", | |
| 523 | + db_column_text(&q, 0), | |
| 524 | + db_column_text(&q, 1), | |
| 525 | + db_column_text(&q, 2), | |
| 526 | + db_column_text(&q, 3), | |
| 527 | + db_column_text(&q, 4), | |
| 528 | + db_column_text(&q, 5) | |
| 529 | + ); | |
| 530 | + blob_appendf(pOut, "config /user %d\n%s", | |
| 531 | + blob_size(&rec), blob_str(&rec)); | |
| 532 | + blob_reset(&rec); | |
| 533 | + } | |
| 534 | + db_finalize(&q); | |
| 535 | + } | |
| 536 | + if( groupMask & CONFIGSET_TKT ){ | |
| 537 | + db_prepare(&q, "SELECT mtime, quote(title), quote(owner), quote(cols)," | |
| 538 | + " quote(sqlcode) FROM reportfmt" | |
| 539 | + " WHERE mtime>=%lld", iStart); | |
| 540 | + while( db_step(&q)==SQLITE_ROW ){ | |
| 541 | + blob_appendf(&rec,"%s %s owner %s cols %s sqlcode %s\n", | |
| 542 | + db_column_text(&q, 0), | |
| 543 | + db_column_text(&q, 1), | |
| 544 | + db_column_text(&q, 2), | |
| 545 | + db_column_text(&q, 3), | |
| 546 | + db_column_text(&q, 4) | |
| 547 | + ); | |
| 548 | + blob_appendf(pOut, "config /reportfmt %d\n%s", | |
| 549 | + blob_size(&rec), blob_str(&rec)); | |
| 550 | + blob_reset(&rec); | |
| 551 | + } | |
| 552 | + db_finalize(&q); | |
| 553 | + } | |
| 554 | + if( groupMask & CONFIGSET_ADDR ){ | |
| 555 | + db_prepare(&q, "SELECT mtime, quote(hash), quote(content) FROM concealed" | |
| 556 | + " WHERE mtime>=%lld", iStart); | |
| 557 | + while( db_step(&q)==SQLITE_ROW ){ | |
| 558 | + blob_appendf(&rec,"%s %s content %s\n", | |
| 559 | + db_column_text(&q, 0), | |
| 560 | + db_column_text(&q, 1), | |
| 561 | + db_column_text(&q, 2) | |
| 562 | + ); | |
| 563 | + blob_appendf(pOut, "config /concealed %d\n%s", | |
| 564 | + blob_size(&rec), blob_str(&rec)); | |
| 565 | + blob_reset(&rec); | |
| 566 | + } | |
| 567 | + db_finalize(&q); | |
| 568 | + } | |
| 569 | + db_prepare(&q, "SELECT mtime, quote(name), quote(value) FROM config" | |
| 570 | + " WHERE name=:name AND mtime>=%lld", iStart); | |
| 571 | + for(ii=0; ii<count(aConfig); ii++){ | |
| 572 | + if( (aConfig[ii].groupMask & groupMask)!=0 && aConfig[ii].zName[0]!='@' ){ | |
| 573 | + db_bind_text(&q, ":name", aConfig[ii].zName); | |
| 574 | + while( db_step(&q)==SQLITE_ROW ){ | |
| 575 | + blob_appendf(&rec,"%s %s value %s\n", | |
| 576 | + db_column_text(&q, 0), | |
| 577 | + db_column_text(&q, 1), | |
| 578 | + db_column_text(&q, 2) | |
| 579 | + ); | |
| 580 | + blob_appendf(pOut, "config /config %d\n%s", | |
| 581 | + blob_size(&rec), blob_str(&rec)); | |
| 582 | + blob_reset(&rec); | |
| 583 | + } | |
| 584 | + db_reset(&q); | |
| 585 | + } | |
| 586 | + } | |
| 587 | + db_finalize(&q); | |
| 588 | +} | |
| 589 | + | |
| 590 | +/* | |
| 591 | +** COMMAND: test-config-send | |
| 592 | +** | |
| 593 | +** Usage: %fossil test-config-send GROUP START | |
| 594 | +*/ | |
| 595 | +void test_config_send(void){ | |
| 596 | + Blob out; | |
| 597 | + sqlite3_int64 iStart; | |
| 598 | + int i; | |
| 599 | + blob_zero(&out); | |
| 600 | + db_find_and_open_repository(0,0); | |
| 601 | + if( g.argc!=4 ) usage("GROUP START"); | |
| 602 | + iStart = db_int64(0, "SELECT strftime('%%s',%Q)", g.argv[3]); | |
| 603 | + for(i=0; i<count(aGroupName); i++){ | |
| 604 | + if( fossil_strcmp(g.argv[2], aGroupName[i].zName)==0 ){ | |
| 605 | + configure_send_group(&out, aGroupName[i].groupMask, iStart); | |
| 606 | + printf("%s", blob_str(&out)); | |
| 607 | + blob_reset(&out); | |
| 608 | + } | |
| 609 | + } | |
| 610 | +} | |
| 485 | 611 | |
| 486 | 612 | /* |
| 487 | 613 | ** After receiving configuration data, call this routine to transfer |
| 488 | 614 | ** the results into the main database. |
| 489 | 615 | */ |
| 490 | 616 |
| --- src/configure.c | |
| +++ src/configure.c | |
| @@ -480,10 +480,136 @@ | |
| 480 | ); |
| 481 | } |
| 482 | } |
| 483 | } |
| 484 | |
| 485 | |
| 486 | /* |
| 487 | ** After receiving configuration data, call this routine to transfer |
| 488 | ** the results into the main database. |
| 489 | */ |
| 490 |
| --- src/configure.c | |
| +++ src/configure.c | |
| @@ -480,10 +480,136 @@ | |
| 480 | ); |
| 481 | } |
| 482 | } |
| 483 | } |
| 484 | |
| 485 | /* |
| 486 | ** Send "config" cards using the new format for all elements of a group |
| 487 | ** that have recently changed. |
| 488 | ** |
| 489 | ** Output goes into pOut. The groupMask identifies the group(s) to be sent. |
| 490 | ** Send only entries whose timestamp is later than or equal to iStart. |
| 491 | */ |
| 492 | void configure_send_group( |
| 493 | Blob *pOut, /* Write output here */ |
| 494 | int groupMask, /* Mask of groups to be send */ |
| 495 | sqlite3_int64 iStart /* Only write values changed since this time */ |
| 496 | ){ |
| 497 | Stmt q; |
| 498 | Blob rec; |
| 499 | int ii; |
| 500 | |
| 501 | blob_zero(&rec); |
| 502 | if( groupMask & CONFIGSET_SHUN ){ |
| 503 | db_prepare(&q, "SELECT mtime, quote(uuid), quote(scom) FROM shun" |
| 504 | " WHERE mtime>=%lld", iStart); |
| 505 | while( db_step(&q)==SQLITE_ROW ){ |
| 506 | blob_appendf(&rec,"%s %s scom %s\n", |
| 507 | db_column_text(&q, 0), |
| 508 | db_column_text(&q, 1), |
| 509 | db_column_text(&q, 2) |
| 510 | ); |
| 511 | blob_appendf(pOut, "config /shun %d\n%s", |
| 512 | blob_size(&rec), blob_str(&rec)); |
| 513 | blob_reset(&rec); |
| 514 | } |
| 515 | db_finalize(&q); |
| 516 | } |
| 517 | if( groupMask & CONFIGSET_USER ){ |
| 518 | db_prepare(&q, "SELECT mtime, quote(login), quote(pw), quote(cap)," |
| 519 | " quote(info), quote(photo) FROM user" |
| 520 | " WHERE mtime>=%lld", iStart); |
| 521 | while( db_step(&q)==SQLITE_ROW ){ |
| 522 | blob_appendf(&rec,"%s %s pw %s cap %s info %s photo %s\n", |
| 523 | db_column_text(&q, 0), |
| 524 | db_column_text(&q, 1), |
| 525 | db_column_text(&q, 2), |
| 526 | db_column_text(&q, 3), |
| 527 | db_column_text(&q, 4), |
| 528 | db_column_text(&q, 5) |
| 529 | ); |
| 530 | blob_appendf(pOut, "config /user %d\n%s", |
| 531 | blob_size(&rec), blob_str(&rec)); |
| 532 | blob_reset(&rec); |
| 533 | } |
| 534 | db_finalize(&q); |
| 535 | } |
| 536 | if( groupMask & CONFIGSET_TKT ){ |
| 537 | db_prepare(&q, "SELECT mtime, quote(title), quote(owner), quote(cols)," |
| 538 | " quote(sqlcode) FROM reportfmt" |
| 539 | " WHERE mtime>=%lld", iStart); |
| 540 | while( db_step(&q)==SQLITE_ROW ){ |
| 541 | blob_appendf(&rec,"%s %s owner %s cols %s sqlcode %s\n", |
| 542 | db_column_text(&q, 0), |
| 543 | db_column_text(&q, 1), |
| 544 | db_column_text(&q, 2), |
| 545 | db_column_text(&q, 3), |
| 546 | db_column_text(&q, 4) |
| 547 | ); |
| 548 | blob_appendf(pOut, "config /reportfmt %d\n%s", |
| 549 | blob_size(&rec), blob_str(&rec)); |
| 550 | blob_reset(&rec); |
| 551 | } |
| 552 | db_finalize(&q); |
| 553 | } |
| 554 | if( groupMask & CONFIGSET_ADDR ){ |
| 555 | db_prepare(&q, "SELECT mtime, quote(hash), quote(content) FROM concealed" |
| 556 | " WHERE mtime>=%lld", iStart); |
| 557 | while( db_step(&q)==SQLITE_ROW ){ |
| 558 | blob_appendf(&rec,"%s %s content %s\n", |
| 559 | db_column_text(&q, 0), |
| 560 | db_column_text(&q, 1), |
| 561 | db_column_text(&q, 2) |
| 562 | ); |
| 563 | blob_appendf(pOut, "config /concealed %d\n%s", |
| 564 | blob_size(&rec), blob_str(&rec)); |
| 565 | blob_reset(&rec); |
| 566 | } |
| 567 | db_finalize(&q); |
| 568 | } |
| 569 | db_prepare(&q, "SELECT mtime, quote(name), quote(value) FROM config" |
| 570 | " WHERE name=:name AND mtime>=%lld", iStart); |
| 571 | for(ii=0; ii<count(aConfig); ii++){ |
| 572 | if( (aConfig[ii].groupMask & groupMask)!=0 && aConfig[ii].zName[0]!='@' ){ |
| 573 | db_bind_text(&q, ":name", aConfig[ii].zName); |
| 574 | while( db_step(&q)==SQLITE_ROW ){ |
| 575 | blob_appendf(&rec,"%s %s value %s\n", |
| 576 | db_column_text(&q, 0), |
| 577 | db_column_text(&q, 1), |
| 578 | db_column_text(&q, 2) |
| 579 | ); |
| 580 | blob_appendf(pOut, "config /config %d\n%s", |
| 581 | blob_size(&rec), blob_str(&rec)); |
| 582 | blob_reset(&rec); |
| 583 | } |
| 584 | db_reset(&q); |
| 585 | } |
| 586 | } |
| 587 | db_finalize(&q); |
| 588 | } |
| 589 | |
| 590 | /* |
| 591 | ** COMMAND: test-config-send |
| 592 | ** |
| 593 | ** Usage: %fossil test-config-send GROUP START |
| 594 | */ |
| 595 | void test_config_send(void){ |
| 596 | Blob out; |
| 597 | sqlite3_int64 iStart; |
| 598 | int i; |
| 599 | blob_zero(&out); |
| 600 | db_find_and_open_repository(0,0); |
| 601 | if( g.argc!=4 ) usage("GROUP START"); |
| 602 | iStart = db_int64(0, "SELECT strftime('%%s',%Q)", g.argv[3]); |
| 603 | for(i=0; i<count(aGroupName); i++){ |
| 604 | if( fossil_strcmp(g.argv[2], aGroupName[i].zName)==0 ){ |
| 605 | configure_send_group(&out, aGroupName[i].groupMask, iStart); |
| 606 | printf("%s", blob_str(&out)); |
| 607 | blob_reset(&out); |
| 608 | } |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | /* |
| 613 | ** After receiving configuration data, call this routine to transfer |
| 614 | ** the results into the main database. |
| 615 | */ |
| 616 |
+1
-2
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -738,11 +738,11 @@ | ||
| 738 | 738 | } |
| 739 | 739 | db_finalize(&q); |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | 742 | /* |
| 743 | -** Send a single config card for configuration item zName | |
| 743 | +** Send a single old-style config card for configuration item zName | |
| 744 | 744 | */ |
| 745 | 745 | static void send_config_card(Xfer *pXfer, const char *zName){ |
| 746 | 746 | if( zName[0]!='@' ){ |
| 747 | 747 | Blob val; |
| 748 | 748 | blob_zero(&val); |
| @@ -760,11 +760,10 @@ | ||
| 760 | 760 | blob_appendf(pXfer->pOut, "config %s %d\n%s\n", zName, |
| 761 | 761 | blob_size(&content), blob_str(&content)); |
| 762 | 762 | blob_reset(&content); |
| 763 | 763 | } |
| 764 | 764 | } |
| 765 | - | |
| 766 | 765 | |
| 767 | 766 | /* |
| 768 | 767 | ** Called when there is an attempt to transfer private content to and |
| 769 | 768 | ** from a server without authorization. |
| 770 | 769 | */ |
| 771 | 770 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -738,11 +738,11 @@ | |
| 738 | } |
| 739 | db_finalize(&q); |
| 740 | } |
| 741 | |
| 742 | /* |
| 743 | ** Send a single config card for configuration item zName |
| 744 | */ |
| 745 | static void send_config_card(Xfer *pXfer, const char *zName){ |
| 746 | if( zName[0]!='@' ){ |
| 747 | Blob val; |
| 748 | blob_zero(&val); |
| @@ -760,11 +760,10 @@ | |
| 760 | blob_appendf(pXfer->pOut, "config %s %d\n%s\n", zName, |
| 761 | blob_size(&content), blob_str(&content)); |
| 762 | blob_reset(&content); |
| 763 | } |
| 764 | } |
| 765 | |
| 766 | |
| 767 | /* |
| 768 | ** Called when there is an attempt to transfer private content to and |
| 769 | ** from a server without authorization. |
| 770 | */ |
| 771 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -738,11 +738,11 @@ | |
| 738 | } |
| 739 | db_finalize(&q); |
| 740 | } |
| 741 | |
| 742 | /* |
| 743 | ** Send a single old-style config card for configuration item zName |
| 744 | */ |
| 745 | static void send_config_card(Xfer *pXfer, const char *zName){ |
| 746 | if( zName[0]!='@' ){ |
| 747 | Blob val; |
| 748 | blob_zero(&val); |
| @@ -760,11 +760,10 @@ | |
| 760 | blob_appendf(pXfer->pOut, "config %s %d\n%s\n", zName, |
| 761 | blob_size(&content), blob_str(&content)); |
| 762 | blob_reset(&content); |
| 763 | } |
| 764 | } |
| 765 | |
| 766 | /* |
| 767 | ** Called when there is an attempt to transfer private content to and |
| 768 | ** from a server without authorization. |
| 769 | */ |
| 770 |