Fossil SCM
Fix the check-in time fudger so that it will not move the date/time of a check-in by more than a few seconds. If the sequence of check-ins is further off than that chronologically, then they just show up out of order in the timeline.
Commit
feaab7baf1c424e5de9f853416c322ddac3ca62c
Parent
195073fb78f7c6a…
1 file changed
+35
-9
+35
-9
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -1205,14 +1205,16 @@ | ||
| 1205 | 1205 | content_deltify(pid, cid, 0); |
| 1206 | 1206 | }else if( pChild->zBaseline==0 && pParent->zBaseline!=0 ){ |
| 1207 | 1207 | content_deltify(pParent->pBaseline->rid, cid, 0); |
| 1208 | 1208 | } |
| 1209 | 1209 | |
| 1210 | - /* Remember all children less than 2 seconds younger than their parent, | |
| 1210 | + /* Remember all children less than a few seconds younger than their parent, | |
| 1211 | 1211 | ** as we might want to fudge the times for those children. |
| 1212 | 1212 | */ |
| 1213 | - if( pChild->rDate<pParent->rDate+2.3e-5 && manifest_crosslink_busy ){ | |
| 1213 | + if( pChild->rDate<pParent->rDate+AGE_FUDGE_WINDOW | |
| 1214 | + && manifest_crosslink_busy | |
| 1215 | + ){ | |
| 1214 | 1216 | db_multi_exec( |
| 1215 | 1217 | "INSERT OR REPLACE INTO time_fudge VALUES(%d, %.17g, %d, %.17g);", |
| 1216 | 1218 | pParent->rid, pParent->rDate, pChild->rid, pChild->rDate |
| 1217 | 1219 | ); |
| 1218 | 1220 | } |
| @@ -1265,18 +1267,32 @@ | ||
| 1265 | 1267 | manifest_crosslink_busy = 1; |
| 1266 | 1268 | db_begin_transaction(); |
| 1267 | 1269 | db_multi_exec( |
| 1268 | 1270 | "CREATE TEMP TABLE pending_tkt(uuid TEXT UNIQUE);" |
| 1269 | 1271 | "CREATE TEMP TABLE time_fudge(" |
| 1270 | - " mid INTEGER PRIMARY KEY," | |
| 1271 | - " m1 REAL," | |
| 1272 | - " cid INTEGER," | |
| 1273 | - " m2 REAL" | |
| 1272 | + " mid INTEGER PRIMARY KEY," /* The rid of a manifest */ | |
| 1273 | + " m1 REAL," /* The timestamp on mid */ | |
| 1274 | + " cid INTEGER," /* A child or mid */ | |
| 1275 | + " m2 REAL" /* Timestamp on the child */ | |
| 1274 | 1276 | ");" |
| 1275 | 1277 | ); |
| 1276 | 1278 | } |
| 1277 | 1279 | |
| 1280 | +#if INTERFACE | |
| 1281 | +/* Timestamps might be adjusted slightly to ensure that checkins appear | |
| 1282 | +** on the timeline in chronological order. This is the maximum amount | |
| 1283 | +** of the adjustment window, in days. | |
| 1284 | +*/ | |
| 1285 | +#define AGE_FUDGE_WINDOW (2.0/86400.0) /* 2 seconds */ | |
| 1286 | + | |
| 1287 | +/* This is increment (in days) by which timestamps are adjusted for | |
| 1288 | +** use on the timeline. | |
| 1289 | +*/ | |
| 1290 | +#define AGE_ADJUST_INCREMENT (25.0/86400000.0) /* 25 milliseconds */ | |
| 1291 | + | |
| 1292 | +#endif /* LOCAL_INTERFACE */ | |
| 1293 | + | |
| 1278 | 1294 | /* |
| 1279 | 1295 | ** Finish up a sequence of manifest_crosslink calls. |
| 1280 | 1296 | */ |
| 1281 | 1297 | void manifest_crosslink_end(void){ |
| 1282 | 1298 | Stmt q, u; |
| @@ -1288,13 +1304,23 @@ | ||
| 1288 | 1304 | ticket_rebuild_entry(zUuid); |
| 1289 | 1305 | } |
| 1290 | 1306 | db_finalize(&q); |
| 1291 | 1307 | db_multi_exec("DROP TABLE pending_tkt"); |
| 1292 | 1308 | |
| 1293 | - db_prepare(&q, "UPDATE time_fudge SET m1=m2-2.8935e-7 WHERE m1>=m2"); | |
| 1294 | - db_prepare(&u, "UPDATE time_fudge SET m2=" | |
| 1295 | - "(SELECT x.m1 FROM time_fudge AS x WHERE x.mid=time_fudge.cid)"); | |
| 1309 | + /* If multiple check-ins happen close together in time, adjust their | |
| 1310 | + ** times by a few milliseconds to make sure they appear in chronological | |
| 1311 | + ** order. | |
| 1312 | + */ | |
| 1313 | + db_prepare(&q, | |
| 1314 | + "UPDATE time_fudge SET m1=m2-:incr WHERE m1>=m2 AND m1<m2+:window" | |
| 1315 | + ); | |
| 1316 | + db_bind_double(&q, ":incr", AGE_ADJUST_INCREMENT); | |
| 1317 | + db_bind_double(&q, ":window", AGE_FUDGE_WINDOW); | |
| 1318 | + db_prepare(&u, | |
| 1319 | + "UPDATE time_fudge SET m2=" | |
| 1320 | + "(SELECT x.m1 FROM time_fudge AS x WHERE x.mid=time_fudge.cid)" | |
| 1321 | + ); | |
| 1296 | 1322 | for(i=0; i<30; i++){ |
| 1297 | 1323 | db_step(&q); |
| 1298 | 1324 | db_reset(&q); |
| 1299 | 1325 | if( sqlite3_changes(g.db)==0 ) break; |
| 1300 | 1326 | db_step(&u); |
| 1301 | 1327 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -1205,14 +1205,16 @@ | |
| 1205 | content_deltify(pid, cid, 0); |
| 1206 | }else if( pChild->zBaseline==0 && pParent->zBaseline!=0 ){ |
| 1207 | content_deltify(pParent->pBaseline->rid, cid, 0); |
| 1208 | } |
| 1209 | |
| 1210 | /* Remember all children less than 2 seconds younger than their parent, |
| 1211 | ** as we might want to fudge the times for those children. |
| 1212 | */ |
| 1213 | if( pChild->rDate<pParent->rDate+2.3e-5 && manifest_crosslink_busy ){ |
| 1214 | db_multi_exec( |
| 1215 | "INSERT OR REPLACE INTO time_fudge VALUES(%d, %.17g, %d, %.17g);", |
| 1216 | pParent->rid, pParent->rDate, pChild->rid, pChild->rDate |
| 1217 | ); |
| 1218 | } |
| @@ -1265,18 +1267,32 @@ | |
| 1265 | manifest_crosslink_busy = 1; |
| 1266 | db_begin_transaction(); |
| 1267 | db_multi_exec( |
| 1268 | "CREATE TEMP TABLE pending_tkt(uuid TEXT UNIQUE);" |
| 1269 | "CREATE TEMP TABLE time_fudge(" |
| 1270 | " mid INTEGER PRIMARY KEY," |
| 1271 | " m1 REAL," |
| 1272 | " cid INTEGER," |
| 1273 | " m2 REAL" |
| 1274 | ");" |
| 1275 | ); |
| 1276 | } |
| 1277 | |
| 1278 | /* |
| 1279 | ** Finish up a sequence of manifest_crosslink calls. |
| 1280 | */ |
| 1281 | void manifest_crosslink_end(void){ |
| 1282 | Stmt q, u; |
| @@ -1288,13 +1304,23 @@ | |
| 1288 | ticket_rebuild_entry(zUuid); |
| 1289 | } |
| 1290 | db_finalize(&q); |
| 1291 | db_multi_exec("DROP TABLE pending_tkt"); |
| 1292 | |
| 1293 | db_prepare(&q, "UPDATE time_fudge SET m1=m2-2.8935e-7 WHERE m1>=m2"); |
| 1294 | db_prepare(&u, "UPDATE time_fudge SET m2=" |
| 1295 | "(SELECT x.m1 FROM time_fudge AS x WHERE x.mid=time_fudge.cid)"); |
| 1296 | for(i=0; i<30; i++){ |
| 1297 | db_step(&q); |
| 1298 | db_reset(&q); |
| 1299 | if( sqlite3_changes(g.db)==0 ) break; |
| 1300 | db_step(&u); |
| 1301 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -1205,14 +1205,16 @@ | |
| 1205 | content_deltify(pid, cid, 0); |
| 1206 | }else if( pChild->zBaseline==0 && pParent->zBaseline!=0 ){ |
| 1207 | content_deltify(pParent->pBaseline->rid, cid, 0); |
| 1208 | } |
| 1209 | |
| 1210 | /* Remember all children less than a few seconds younger than their parent, |
| 1211 | ** as we might want to fudge the times for those children. |
| 1212 | */ |
| 1213 | if( pChild->rDate<pParent->rDate+AGE_FUDGE_WINDOW |
| 1214 | && manifest_crosslink_busy |
| 1215 | ){ |
| 1216 | db_multi_exec( |
| 1217 | "INSERT OR REPLACE INTO time_fudge VALUES(%d, %.17g, %d, %.17g);", |
| 1218 | pParent->rid, pParent->rDate, pChild->rid, pChild->rDate |
| 1219 | ); |
| 1220 | } |
| @@ -1265,18 +1267,32 @@ | |
| 1267 | manifest_crosslink_busy = 1; |
| 1268 | db_begin_transaction(); |
| 1269 | db_multi_exec( |
| 1270 | "CREATE TEMP TABLE pending_tkt(uuid TEXT UNIQUE);" |
| 1271 | "CREATE TEMP TABLE time_fudge(" |
| 1272 | " mid INTEGER PRIMARY KEY," /* The rid of a manifest */ |
| 1273 | " m1 REAL," /* The timestamp on mid */ |
| 1274 | " cid INTEGER," /* A child or mid */ |
| 1275 | " m2 REAL" /* Timestamp on the child */ |
| 1276 | ");" |
| 1277 | ); |
| 1278 | } |
| 1279 | |
| 1280 | #if INTERFACE |
| 1281 | /* Timestamps might be adjusted slightly to ensure that checkins appear |
| 1282 | ** on the timeline in chronological order. This is the maximum amount |
| 1283 | ** of the adjustment window, in days. |
| 1284 | */ |
| 1285 | #define AGE_FUDGE_WINDOW (2.0/86400.0) /* 2 seconds */ |
| 1286 | |
| 1287 | /* This is increment (in days) by which timestamps are adjusted for |
| 1288 | ** use on the timeline. |
| 1289 | */ |
| 1290 | #define AGE_ADJUST_INCREMENT (25.0/86400000.0) /* 25 milliseconds */ |
| 1291 | |
| 1292 | #endif /* LOCAL_INTERFACE */ |
| 1293 | |
| 1294 | /* |
| 1295 | ** Finish up a sequence of manifest_crosslink calls. |
| 1296 | */ |
| 1297 | void manifest_crosslink_end(void){ |
| 1298 | Stmt q, u; |
| @@ -1288,13 +1304,23 @@ | |
| 1304 | ticket_rebuild_entry(zUuid); |
| 1305 | } |
| 1306 | db_finalize(&q); |
| 1307 | db_multi_exec("DROP TABLE pending_tkt"); |
| 1308 | |
| 1309 | /* If multiple check-ins happen close together in time, adjust their |
| 1310 | ** times by a few milliseconds to make sure they appear in chronological |
| 1311 | ** order. |
| 1312 | */ |
| 1313 | db_prepare(&q, |
| 1314 | "UPDATE time_fudge SET m1=m2-:incr WHERE m1>=m2 AND m1<m2+:window" |
| 1315 | ); |
| 1316 | db_bind_double(&q, ":incr", AGE_ADJUST_INCREMENT); |
| 1317 | db_bind_double(&q, ":window", AGE_FUDGE_WINDOW); |
| 1318 | db_prepare(&u, |
| 1319 | "UPDATE time_fudge SET m2=" |
| 1320 | "(SELECT x.m1 FROM time_fudge AS x WHERE x.mid=time_fudge.cid)" |
| 1321 | ); |
| 1322 | for(i=0; i<30; i++){ |
| 1323 | db_step(&q); |
| 1324 | db_reset(&q); |
| 1325 | if( sqlite3_changes(g.db)==0 ) break; |
| 1326 | db_step(&u); |
| 1327 |