1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
|
** by the call to manifest_crosslink_end().
*/
void manifest_crosslink_begin(void){
assert( manifest_crosslink_busy==0 );
manifest_crosslink_busy = 1;
db_begin_transaction();
db_multi_exec(
"CREATE TEMP TABLE pending_tkt(uuid TEXT UNIQUE);"
"CREATE TEMP TABLE time_fudge("
" mid INTEGER PRIMARY KEY," /* The rid of a manifest */
" m1 REAL," /* The timestamp on mid */
" cid INTEGER," /* A child or mid */
" m2 REAL" /* Timestamp on the child */
");"
);
}
#if INTERFACE
/* Timestamps might be adjusted slightly to ensure that check-ins appear
** on the timeline in chronological order. This is the maximum amount
** of the adjustment window, in days.
*/
#define AGE_FUDGE_WINDOW (2.0/86400.0) /* 2 seconds */
|
|
>
>
>
>
>
>
>
>
>
>
>
|
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
|
** by the call to manifest_crosslink_end().
*/
void manifest_crosslink_begin(void){
assert( manifest_crosslink_busy==0 );
manifest_crosslink_busy = 1;
db_begin_transaction();
db_multi_exec(
"CREATE TEMP TABLE pending_xlink(id TEXT PRIMARY KEY)WITHOUT ROWID;"
"CREATE TEMP TABLE time_fudge("
" mid INTEGER PRIMARY KEY," /* The rid of a manifest */
" m1 REAL," /* The timestamp on mid */
" cid INTEGER," /* A child or mid */
" m2 REAL" /* Timestamp on the child */
");"
);
}
/*
** Add a new entry to the pending_xlink table.
*/
static void add_pending_crosslink(char cType, const char *zId){
assert( manifest_crosslink_busy==1 );
db_multi_exec(
"INSERT OR IGNORE INTO pending_xlink VALUES('%c%q')",
cType, zId
);
}
#if INTERFACE
/* Timestamps might be adjusted slightly to ensure that check-ins appear
** on the timeline in chronological order. This is the maximum amount
** of the adjustment window, in days.
*/
#define AGE_FUDGE_WINDOW (2.0/86400.0) /* 2 seconds */
|
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
|
);
while( db_step(&q)==SQLITE_ROW ){
int rid = db_column_int(&q,0);
const char *zValue = db_column_text(&q,1);
manifest_reparent_checkin(rid, zValue);
}
db_finalize(&q);
db_prepare(&q, "SELECT uuid FROM pending_tkt");
while( db_step(&q)==SQLITE_ROW ){
const char *zUuid = db_column_text(&q, 0);
ticket_rebuild_entry(zUuid);
if( permitHooks && rc==TH_OK ){
rc = xfer_run_script(zScript, zUuid, 0);
}
}
db_finalize(&q);
db_multi_exec("DROP TABLE pending_tkt");
/* If multiple check-ins happen close together in time, adjust their
** times by a few milliseconds to make sure they appear in chronological
** order.
*/
db_prepare(&q,
"UPDATE time_fudge SET m1=m2-:incr WHERE m1>=m2 AND m1<m2+:window"
|
|
|
>
>
>
>
>
|
|
|
>
>
>
|
|
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
|
);
while( db_step(&q)==SQLITE_ROW ){
int rid = db_column_int(&q,0);
const char *zValue = db_column_text(&q,1);
manifest_reparent_checkin(rid, zValue);
}
db_finalize(&q);
db_prepare(&q, "SELECT id FROM pending_xlink");
while( db_step(&q)==SQLITE_ROW ){
const char *zId = db_column_text(&q, 0);
char cType;
if( zId==0 || zId[0]==0 ) continue;
cType = zId[0];
zId++;
if( cType=='t' ){
ticket_rebuild_entry(zId);
if( permitHooks && rc==TH_OK ){
rc = xfer_run_script(zScript, zId, 0);
}
}else if( cType=='w' ){
backlink_wiki_refresh(zId);
}
}
db_finalize(&q);
db_multi_exec("DROP TABLE pending_xlink");
/* If multiple check-ins happen close together in time, adjust their
** times by a few milliseconds to make sure they appear in chronological
** order.
*/
db_prepare(&q,
"UPDATE time_fudge SET m1=m2-:incr WHERE m1>=m2 AND m1<m2+:window"
|
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
|
}
if( nWiki>0 ){
zComment = mprintf("Changes to wiki page [%h]", p->zWikiTitle);
}else{
zComment = mprintf("Deleted wiki page [%h]", p->zWikiTitle);
}
search_doc_touch('w',rid,p->zWikiTitle);
db_multi_exec(
"REPLACE INTO event(type,mtime,objid,user,comment,"
" bgcolor,euser,ecomment)"
"VALUES('w',%.17g,%d,%Q,%Q,"
" (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype>1),"
" (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d),"
" (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d));",
|
>
|
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
|
}
if( nWiki>0 ){
zComment = mprintf("Changes to wiki page [%h]", p->zWikiTitle);
}else{
zComment = mprintf("Deleted wiki page [%h]", p->zWikiTitle);
}
search_doc_touch('w',rid,p->zWikiTitle);
add_pending_crosslink('w',p->zWikiTitle);
db_multi_exec(
"REPLACE INTO event(type,mtime,objid,user,comment,"
" bgcolor,euser,ecomment)"
"VALUES('w',%.17g,%d,%Q,%Q,"
" (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype>1),"
" (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d),"
" (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d));",
|
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
|
if( p->type==CFTYPE_TICKET ){
char *zTag;
Stmt qatt;
assert( manifest_crosslink_busy==1 );
zTag = mprintf("tkt-%s", p->zTicketUuid);
tag_insert(zTag, 1, 0, rid, p->rDate, rid);
fossil_free(zTag);
db_multi_exec("INSERT OR IGNORE INTO pending_tkt VALUES(%Q)",
p->zTicketUuid);
/* Locate and update comment for any attachments */
db_prepare(&qatt,
"SELECT attachid, src, target, filename FROM attachment"
" WHERE target=%Q",
p->zTicketUuid
);
while( db_step(&qatt)==SQLITE_ROW ){
|
<
|
|
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
|
if( p->type==CFTYPE_TICKET ){
char *zTag;
Stmt qatt;
assert( manifest_crosslink_busy==1 );
zTag = mprintf("tkt-%s", p->zTicketUuid);
tag_insert(zTag, 1, 0, rid, p->rDate, rid);
fossil_free(zTag);
add_pending_crosslink('t',p->zTicketUuid);
/* Locate and update comment for any attachments */
db_prepare(&qatt,
"SELECT attachid, src, target, filename FROM attachment"
" WHERE target=%Q",
p->zTicketUuid
);
while( db_step(&qatt)==SQLITE_ROW ){
|