Fossil SCM

Delay activation of ticket hook until after the ticket tables have been rebuilt.

jan.nijtmans 2014-01-09 15:39 trunk
Commit dff7d2c1ee2089fa7cf52744ed4d9d5cae349a5e
+9 -3
--- src/manifest.c
+++ src/manifest.c
@@ -1494,18 +1494,25 @@
14941494
#endif /* LOCAL_INTERFACE */
14951495
14961496
/*
14971497
** Finish up a sequence of manifest_crosslink calls.
14981498
*/
1499
-void manifest_crosslink_end(void){
1499
+int manifest_crosslink_end(int flags){
15001500
Stmt q, u;
15011501
int i;
1502
+ int rc = TH_ERROR;
15021503
assert( manifest_crosslink_busy==1 );
1504
+ if( flags&MC_PERMIT_HOOKS ){
1505
+ rc = xfer_run_common_script();
1506
+ }
15031507
db_prepare(&q, "SELECT uuid FROM pending_tkt");
15041508
while( db_step(&q)==SQLITE_ROW ){
15051509
const char *zUuid = db_column_text(&q, 0);
15061510
ticket_rebuild_entry(zUuid);
1511
+ if( rc==TH_OK ){
1512
+ rc = xfer_run_script(xfer_ticket_code(), zUuid);
1513
+ }
15071514
}
15081515
db_finalize(&q);
15091516
db_multi_exec("DROP TABLE pending_tkt");
15101517
15111518
/* If multiple check-ins happen close together in time, adjust their
@@ -1536,10 +1543,11 @@
15361543
"DROP TABLE time_fudge;"
15371544
);
15381545
15391546
db_end_transaction(0);
15401547
manifest_crosslink_busy = 0;
1548
+ return rc;
15411549
}
15421550
15431551
/*
15441552
** Make an entry in the event table for a ticket change artifact.
15451553
*/
@@ -1883,12 +1891,10 @@
18831891
}
18841892
}
18851893
if( p->type==CFTYPE_TICKET ){
18861894
char *zTag;
18871895
1888
- zScript = xfer_ticket_code();
1889
- zUuid = p->zTicketUuid;
18901896
assert( manifest_crosslink_busy==1 );
18911897
zTag = mprintf("tkt-%s", p->zTicketUuid);
18921898
tag_insert(zTag, 1, 0, rid, p->rDate, rid);
18931899
free(zTag);
18941900
db_multi_exec("INSERT OR IGNORE INTO pending_tkt VALUES(%Q)",
18951901
--- src/manifest.c
+++ src/manifest.c
@@ -1494,18 +1494,25 @@
1494 #endif /* LOCAL_INTERFACE */
1495
1496 /*
1497 ** Finish up a sequence of manifest_crosslink calls.
1498 */
1499 void manifest_crosslink_end(void){
1500 Stmt q, u;
1501 int i;
 
1502 assert( manifest_crosslink_busy==1 );
 
 
 
1503 db_prepare(&q, "SELECT uuid FROM pending_tkt");
1504 while( db_step(&q)==SQLITE_ROW ){
1505 const char *zUuid = db_column_text(&q, 0);
1506 ticket_rebuild_entry(zUuid);
 
 
 
1507 }
1508 db_finalize(&q);
1509 db_multi_exec("DROP TABLE pending_tkt");
1510
1511 /* If multiple check-ins happen close together in time, adjust their
@@ -1536,10 +1543,11 @@
1536 "DROP TABLE time_fudge;"
1537 );
1538
1539 db_end_transaction(0);
1540 manifest_crosslink_busy = 0;
 
1541 }
1542
1543 /*
1544 ** Make an entry in the event table for a ticket change artifact.
1545 */
@@ -1883,12 +1891,10 @@
1883 }
1884 }
1885 if( p->type==CFTYPE_TICKET ){
1886 char *zTag;
1887
1888 zScript = xfer_ticket_code();
1889 zUuid = p->zTicketUuid;
1890 assert( manifest_crosslink_busy==1 );
1891 zTag = mprintf("tkt-%s", p->zTicketUuid);
1892 tag_insert(zTag, 1, 0, rid, p->rDate, rid);
1893 free(zTag);
1894 db_multi_exec("INSERT OR IGNORE INTO pending_tkt VALUES(%Q)",
1895
--- src/manifest.c
+++ src/manifest.c
@@ -1494,18 +1494,25 @@
1494 #endif /* LOCAL_INTERFACE */
1495
1496 /*
1497 ** Finish up a sequence of manifest_crosslink calls.
1498 */
1499 int manifest_crosslink_end(int flags){
1500 Stmt q, u;
1501 int i;
1502 int rc = TH_ERROR;
1503 assert( manifest_crosslink_busy==1 );
1504 if( flags&MC_PERMIT_HOOKS ){
1505 rc = xfer_run_common_script();
1506 }
1507 db_prepare(&q, "SELECT uuid FROM pending_tkt");
1508 while( db_step(&q)==SQLITE_ROW ){
1509 const char *zUuid = db_column_text(&q, 0);
1510 ticket_rebuild_entry(zUuid);
1511 if( rc==TH_OK ){
1512 rc = xfer_run_script(xfer_ticket_code(), zUuid);
1513 }
1514 }
1515 db_finalize(&q);
1516 db_multi_exec("DROP TABLE pending_tkt");
1517
1518 /* If multiple check-ins happen close together in time, adjust their
@@ -1536,10 +1543,11 @@
1543 "DROP TABLE time_fudge;"
1544 );
1545
1546 db_end_transaction(0);
1547 manifest_crosslink_busy = 0;
1548 return rc;
1549 }
1550
1551 /*
1552 ** Make an entry in the event table for a ticket change artifact.
1553 */
@@ -1883,12 +1891,10 @@
1891 }
1892 }
1893 if( p->type==CFTYPE_TICKET ){
1894 char *zTag;
1895
 
 
1896 assert( manifest_crosslink_busy==1 );
1897 zTag = mprintf("tkt-%s", p->zTicketUuid);
1898 tag_insert(zTag, 1, 0, rid, p->rDate, rid);
1899 free(zTag);
1900 db_multi_exec("INSERT OR IGNORE INTO pending_tkt VALUES(%Q)",
1901
+1 -1
--- src/rebuild.c
+++ src/rebuild.c
@@ -412,11 +412,11 @@
412412
db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid);
413413
rebuild_step_done(rid);
414414
}
415415
}
416416
db_finalize(&s);
417
- manifest_crosslink_end();
417
+ manifest_crosslink_end(0);
418418
rebuild_tag_trunk();
419419
if( ttyOutput && !g.fQuiet && totalSize>0 ){
420420
processCnt += incrSize;
421421
percent_complete((processCnt*1000)/totalSize);
422422
}
423423
--- src/rebuild.c
+++ src/rebuild.c
@@ -412,11 +412,11 @@
412 db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid);
413 rebuild_step_done(rid);
414 }
415 }
416 db_finalize(&s);
417 manifest_crosslink_end();
418 rebuild_tag_trunk();
419 if( ttyOutput && !g.fQuiet && totalSize>0 ){
420 processCnt += incrSize;
421 percent_complete((processCnt*1000)/totalSize);
422 }
423
--- src/rebuild.c
+++ src/rebuild.c
@@ -412,11 +412,11 @@
412 db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid);
413 rebuild_step_done(rid);
414 }
415 }
416 db_finalize(&s);
417 manifest_crosslink_end(0);
418 rebuild_tag_trunk();
419 if( ttyOutput && !g.fQuiet && totalSize>0 ){
420 processCnt += incrSize;
421 percent_complete((processCnt*1000)/totalSize);
422 }
423
+6 -2
--- src/tkt.c
+++ src/tkt.c
@@ -535,13 +535,17 @@
535535
}else{
536536
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d);", rid);
537537
db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", rid);
538538
}
539539
manifest_crosslink_begin();
540
- result = (manifest_crosslink(rid, pTicket, MC_PERMIT_HOOKS)==0);
540
+ result = (manifest_crosslink(rid, pTicket, 0)==0);
541541
assert( blob_is_reset(pTicket) );
542
- manifest_crosslink_end();
542
+ if( result ){
543
+ result = manifest_crosslink_end(MC_PERMIT_HOOKS);
544
+ }else{
545
+ manifest_crosslink_end(0);
546
+ }
543547
return result;
544548
}
545549
546550
/*
547551
** Subscript command: submit_ticket
548552
--- src/tkt.c
+++ src/tkt.c
@@ -535,13 +535,17 @@
535 }else{
536 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d);", rid);
537 db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", rid);
538 }
539 manifest_crosslink_begin();
540 result = (manifest_crosslink(rid, pTicket, MC_PERMIT_HOOKS)==0);
541 assert( blob_is_reset(pTicket) );
542 manifest_crosslink_end();
 
 
 
 
543 return result;
544 }
545
546 /*
547 ** Subscript command: submit_ticket
548
--- src/tkt.c
+++ src/tkt.c
@@ -535,13 +535,17 @@
535 }else{
536 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d);", rid);
537 db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", rid);
538 }
539 manifest_crosslink_begin();
540 result = (manifest_crosslink(rid, pTicket, 0)==0);
541 assert( blob_is_reset(pTicket) );
542 if( result ){
543 result = manifest_crosslink_end(MC_PERMIT_HOOKS);
544 }else{
545 manifest_crosslink_end(0);
546 }
547 return result;
548 }
549
550 /*
551 ** Subscript command: submit_ticket
552
+2 -2
--- src/xfer.c
+++ src/xfer.c
@@ -1302,11 +1302,11 @@
13021302
}
13031303
if( recvConfig ){
13041304
configure_finalize_receive();
13051305
}
13061306
db_multi_exec("DROP TABLE onremote");
1307
- manifest_crosslink_end();
1307
+ manifest_crosslink_end(MC_PERMIT_HOOKS);
13081308
13091309
/* Send the server timestamp last, in case prior processing happened
13101310
** to use up a significant fraction of our time window.
13111311
*/
13121312
zNow = db_text(0, "SELECT strftime('%%Y-%%m-%%dT%%H:%%M:%%S', 'now')");
@@ -1929,10 +1929,10 @@
19291929
"%s finished with %lld bytes sent, %lld bytes received\n",
19301930
zOpType, nSent, nRcvd);
19311931
transport_close(GLOBAL_URL());
19321932
transport_global_shutdown(GLOBAL_URL());
19331933
db_multi_exec("DROP TABLE onremote");
1934
- manifest_crosslink_end();
1934
+ manifest_crosslink_end(MC_PERMIT_HOOKS);
19351935
content_enable_dephantomize(1);
19361936
db_end_transaction(0);
19371937
return nErr;
19381938
}
19391939
--- src/xfer.c
+++ src/xfer.c
@@ -1302,11 +1302,11 @@
1302 }
1303 if( recvConfig ){
1304 configure_finalize_receive();
1305 }
1306 db_multi_exec("DROP TABLE onremote");
1307 manifest_crosslink_end();
1308
1309 /* Send the server timestamp last, in case prior processing happened
1310 ** to use up a significant fraction of our time window.
1311 */
1312 zNow = db_text(0, "SELECT strftime('%%Y-%%m-%%dT%%H:%%M:%%S', 'now')");
@@ -1929,10 +1929,10 @@
1929 "%s finished with %lld bytes sent, %lld bytes received\n",
1930 zOpType, nSent, nRcvd);
1931 transport_close(GLOBAL_URL());
1932 transport_global_shutdown(GLOBAL_URL());
1933 db_multi_exec("DROP TABLE onremote");
1934 manifest_crosslink_end();
1935 content_enable_dephantomize(1);
1936 db_end_transaction(0);
1937 return nErr;
1938 }
1939
--- src/xfer.c
+++ src/xfer.c
@@ -1302,11 +1302,11 @@
1302 }
1303 if( recvConfig ){
1304 configure_finalize_receive();
1305 }
1306 db_multi_exec("DROP TABLE onremote");
1307 manifest_crosslink_end(MC_PERMIT_HOOKS);
1308
1309 /* Send the server timestamp last, in case prior processing happened
1310 ** to use up a significant fraction of our time window.
1311 */
1312 zNow = db_text(0, "SELECT strftime('%%Y-%%m-%%dT%%H:%%M:%%S', 'now')");
@@ -1929,10 +1929,10 @@
1929 "%s finished with %lld bytes sent, %lld bytes received\n",
1930 zOpType, nSent, nRcvd);
1931 transport_close(GLOBAL_URL());
1932 transport_global_shutdown(GLOBAL_URL());
1933 db_multi_exec("DROP TABLE onremote");
1934 manifest_crosslink_end(MC_PERMIT_HOOKS);
1935 content_enable_dephantomize(1);
1936 db_end_transaction(0);
1937 return nErr;
1938 }
1939

Keyboard Shortcuts

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