Fossil SCM

Add the undocumented --heavy option to the sync, push, and pull commands. The --heavy option causes all known artifacts to be reported using "igot" cards and can be used to overcome a sync-stall.

drh 2013-08-02 18:53 UTC trunk
Commit 05ba15e448d7676d88c332cc5cd47298aa57f060
2 files changed +3 +36 -6
+3
--- src/sync.c
+++ src/sync.c
@@ -93,10 +93,13 @@
9393
if( find_option("private",0,0)!=0 ){
9494
*pSyncFlags |= SYNC_PRIVATE;
9595
}
9696
if( find_option("verbose","v",0)!=0 ){
9797
*pSyncFlags |= SYNC_VERBOSE;
98
+ }
99
+ if( find_option("heavy",0,0)!=0 ){
100
+ *pSyncFlags |= SYNC_RESYNC;
98101
}
99102
url_proxy_options();
100103
db_find_and_open_repository(0, 0);
101104
db_open_config(0);
102105
if( g.argc==2 ){
103106
--- src/sync.c
+++ src/sync.c
@@ -93,10 +93,13 @@
93 if( find_option("private",0,0)!=0 ){
94 *pSyncFlags |= SYNC_PRIVATE;
95 }
96 if( find_option("verbose","v",0)!=0 ){
97 *pSyncFlags |= SYNC_VERBOSE;
 
 
 
98 }
99 url_proxy_options();
100 db_find_and_open_repository(0, 0);
101 db_open_config(0);
102 if( g.argc==2 ){
103
--- src/sync.c
+++ src/sync.c
@@ -93,10 +93,13 @@
93 if( find_option("private",0,0)!=0 ){
94 *pSyncFlags |= SYNC_PRIVATE;
95 }
96 if( find_option("verbose","v",0)!=0 ){
97 *pSyncFlags |= SYNC_VERBOSE;
98 }
99 if( find_option("heavy",0,0)!=0 ){
100 *pSyncFlags |= SYNC_RESYNC;
101 }
102 url_proxy_options();
103 db_find_and_open_repository(0, 0);
104 db_open_config(0);
105 if( g.argc==2 ){
106
+36 -6
--- src/xfer.c
+++ src/xfer.c
@@ -46,10 +46,11 @@
4646
int nDeltaSent; /* Number of deltas sent */
4747
int nFileRcvd; /* Number of files received */
4848
int nDeltaRcvd; /* Number of deltas received */
4949
int nDanglingFile; /* Number of dangling deltas received */
5050
int mxSend; /* Stop sending "file" with pOut reaches this size */
51
+ int resync; /* Send igot cards for all holdings */
5152
u8 syncPrivate; /* True to enable syncing private content */
5253
u8 nextIsPrivate; /* If true, next "file" received is a private */
5354
time_t maxTime; /* Time when this transfer should be finished */
5455
};
5556
@@ -736,21 +737,37 @@
736737
** Return the number of cards sent.
737738
*/
738739
static int send_unclustered(Xfer *pXfer){
739740
Stmt q;
740741
int cnt = 0;
741
- db_prepare(&q,
742
- "SELECT uuid FROM unclustered JOIN blob USING(rid)"
743
- " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
744
- " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)"
745
- " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)"
746
- );
742
+ if( pXfer->resync ){
743
+ db_prepare(&q,
744
+ "SELECT uuid, rid FROM blob"
745
+ " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
746
+ " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)"
747
+ " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)"
748
+ " AND blob.rid<=%d"
749
+ " ORDER BY blob.rid DESC",
750
+ pXfer->resync
751
+ );
752
+ }else{
753
+ db_prepare(&q,
754
+ "SELECT uuid FROM unclustered JOIN blob USING(rid)"
755
+ " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
756
+ " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)"
757
+ " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)"
758
+ );
759
+ }
747760
while( db_step(&q)==SQLITE_ROW ){
748761
blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0));
749762
cnt++;
763
+ if( pXfer->resync && pXfer->mxSend<blob_size(pXfer->pOut) ){
764
+ pXfer->resync = db_column_int(&q, 1)-1;
765
+ }
750766
}
751767
db_finalize(&q);
768
+ if( cnt==0 ) pXfer->resync = 0;
752769
return cnt;
753770
}
754771
755772
/*
756773
** Send an igot message for every artifact.
@@ -1195,10 +1212,17 @@
11951212
server_private_xfer_not_authorized();
11961213
}else{
11971214
xfer.syncPrivate = 1;
11981215
}
11991216
}
1217
+ /* pragma send-catalog
1218
+ **
1219
+ ** Send igot cards for all known artifacts.
1220
+ */
1221
+ if( blob_eq(&xfer.aToken[1], "send-catalog") ){
1222
+ xfer.resync = 0x7fffffff;
1223
+ }
12001224
}else
12011225
12021226
/* Unknown message
12031227
*/
12041228
{
@@ -1292,10 +1316,11 @@
12921316
#define SYNC_PUSH 0x0001
12931317
#define SYNC_PULL 0x0002
12941318
#define SYNC_CLONE 0x0004
12951319
#define SYNC_PRIVATE 0x0008
12961320
#define SYNC_VERBOSE 0x0010
1321
+#define SYNC_RESYNC 0x0020
12971322
#endif
12981323
12991324
/*
13001325
** Sync to the host identified in g.urlName and g.urlPath. This
13011326
** routine is called by the client.
@@ -1380,15 +1405,20 @@
13801405
zOpType = "Clone";
13811406
}else if( syncFlags & SYNC_PULL ){
13821407
blob_appendf(&send, "pull %s %s\n", zSCode, zPCode);
13831408
nCardSent++;
13841409
zOpType = (syncFlags & SYNC_PUSH)?"Sync":"Pull";
1410
+ if( (syncFlags & SYNC_RESYNC)!=0 && nCycle<2 ){
1411
+ blob_appendf(&send, "pragma send-catalog\n");
1412
+ nCardSent++;
1413
+ }
13851414
}
13861415
if( syncFlags & SYNC_PUSH ){
13871416
blob_appendf(&send, "push %s %s\n", zSCode, zPCode);
13881417
nCardSent++;
13891418
if( (syncFlags & SYNC_PULL)==0 ) zOpType = "Push";
1419
+ if( (syncFlags & SYNC_RESYNC)!=0 ) xfer.resync = 0x7fffffff;
13901420
}
13911421
manifest_crosslink_begin();
13921422
transport_global_startup();
13931423
if( syncFlags & SYNC_VERBOSE ){
13941424
fossil_print(zLabelFormat, "", "Bytes", "Cards", "Artifacts", "Deltas");
13951425
--- src/xfer.c
+++ src/xfer.c
@@ -46,10 +46,11 @@
46 int nDeltaSent; /* Number of deltas sent */
47 int nFileRcvd; /* Number of files received */
48 int nDeltaRcvd; /* Number of deltas received */
49 int nDanglingFile; /* Number of dangling deltas received */
50 int mxSend; /* Stop sending "file" with pOut reaches this size */
 
51 u8 syncPrivate; /* True to enable syncing private content */
52 u8 nextIsPrivate; /* If true, next "file" received is a private */
53 time_t maxTime; /* Time when this transfer should be finished */
54 };
55
@@ -736,21 +737,37 @@
736 ** Return the number of cards sent.
737 */
738 static int send_unclustered(Xfer *pXfer){
739 Stmt q;
740 int cnt = 0;
741 db_prepare(&q,
742 "SELECT uuid FROM unclustered JOIN blob USING(rid)"
743 " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
744 " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)"
745 " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)"
746 );
 
 
 
 
 
 
 
 
 
 
 
 
747 while( db_step(&q)==SQLITE_ROW ){
748 blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0));
749 cnt++;
 
 
 
750 }
751 db_finalize(&q);
 
752 return cnt;
753 }
754
755 /*
756 ** Send an igot message for every artifact.
@@ -1195,10 +1212,17 @@
1195 server_private_xfer_not_authorized();
1196 }else{
1197 xfer.syncPrivate = 1;
1198 }
1199 }
 
 
 
 
 
 
 
1200 }else
1201
1202 /* Unknown message
1203 */
1204 {
@@ -1292,10 +1316,11 @@
1292 #define SYNC_PUSH 0x0001
1293 #define SYNC_PULL 0x0002
1294 #define SYNC_CLONE 0x0004
1295 #define SYNC_PRIVATE 0x0008
1296 #define SYNC_VERBOSE 0x0010
 
1297 #endif
1298
1299 /*
1300 ** Sync to the host identified in g.urlName and g.urlPath. This
1301 ** routine is called by the client.
@@ -1380,15 +1405,20 @@
1380 zOpType = "Clone";
1381 }else if( syncFlags & SYNC_PULL ){
1382 blob_appendf(&send, "pull %s %s\n", zSCode, zPCode);
1383 nCardSent++;
1384 zOpType = (syncFlags & SYNC_PUSH)?"Sync":"Pull";
 
 
 
 
1385 }
1386 if( syncFlags & SYNC_PUSH ){
1387 blob_appendf(&send, "push %s %s\n", zSCode, zPCode);
1388 nCardSent++;
1389 if( (syncFlags & SYNC_PULL)==0 ) zOpType = "Push";
 
1390 }
1391 manifest_crosslink_begin();
1392 transport_global_startup();
1393 if( syncFlags & SYNC_VERBOSE ){
1394 fossil_print(zLabelFormat, "", "Bytes", "Cards", "Artifacts", "Deltas");
1395
--- src/xfer.c
+++ src/xfer.c
@@ -46,10 +46,11 @@
46 int nDeltaSent; /* Number of deltas sent */
47 int nFileRcvd; /* Number of files received */
48 int nDeltaRcvd; /* Number of deltas received */
49 int nDanglingFile; /* Number of dangling deltas received */
50 int mxSend; /* Stop sending "file" with pOut reaches this size */
51 int resync; /* Send igot cards for all holdings */
52 u8 syncPrivate; /* True to enable syncing private content */
53 u8 nextIsPrivate; /* If true, next "file" received is a private */
54 time_t maxTime; /* Time when this transfer should be finished */
55 };
56
@@ -736,21 +737,37 @@
737 ** Return the number of cards sent.
738 */
739 static int send_unclustered(Xfer *pXfer){
740 Stmt q;
741 int cnt = 0;
742 if( pXfer->resync ){
743 db_prepare(&q,
744 "SELECT uuid, rid FROM blob"
745 " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
746 " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)"
747 " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)"
748 " AND blob.rid<=%d"
749 " ORDER BY blob.rid DESC",
750 pXfer->resync
751 );
752 }else{
753 db_prepare(&q,
754 "SELECT uuid FROM unclustered JOIN blob USING(rid)"
755 " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
756 " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)"
757 " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)"
758 );
759 }
760 while( db_step(&q)==SQLITE_ROW ){
761 blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0));
762 cnt++;
763 if( pXfer->resync && pXfer->mxSend<blob_size(pXfer->pOut) ){
764 pXfer->resync = db_column_int(&q, 1)-1;
765 }
766 }
767 db_finalize(&q);
768 if( cnt==0 ) pXfer->resync = 0;
769 return cnt;
770 }
771
772 /*
773 ** Send an igot message for every artifact.
@@ -1195,10 +1212,17 @@
1212 server_private_xfer_not_authorized();
1213 }else{
1214 xfer.syncPrivate = 1;
1215 }
1216 }
1217 /* pragma send-catalog
1218 **
1219 ** Send igot cards for all known artifacts.
1220 */
1221 if( blob_eq(&xfer.aToken[1], "send-catalog") ){
1222 xfer.resync = 0x7fffffff;
1223 }
1224 }else
1225
1226 /* Unknown message
1227 */
1228 {
@@ -1292,10 +1316,11 @@
1316 #define SYNC_PUSH 0x0001
1317 #define SYNC_PULL 0x0002
1318 #define SYNC_CLONE 0x0004
1319 #define SYNC_PRIVATE 0x0008
1320 #define SYNC_VERBOSE 0x0010
1321 #define SYNC_RESYNC 0x0020
1322 #endif
1323
1324 /*
1325 ** Sync to the host identified in g.urlName and g.urlPath. This
1326 ** routine is called by the client.
@@ -1380,15 +1405,20 @@
1405 zOpType = "Clone";
1406 }else if( syncFlags & SYNC_PULL ){
1407 blob_appendf(&send, "pull %s %s\n", zSCode, zPCode);
1408 nCardSent++;
1409 zOpType = (syncFlags & SYNC_PUSH)?"Sync":"Pull";
1410 if( (syncFlags & SYNC_RESYNC)!=0 && nCycle<2 ){
1411 blob_appendf(&send, "pragma send-catalog\n");
1412 nCardSent++;
1413 }
1414 }
1415 if( syncFlags & SYNC_PUSH ){
1416 blob_appendf(&send, "push %s %s\n", zSCode, zPCode);
1417 nCardSent++;
1418 if( (syncFlags & SYNC_PULL)==0 ) zOpType = "Push";
1419 if( (syncFlags & SYNC_RESYNC)!=0 ) xfer.resync = 0x7fffffff;
1420 }
1421 manifest_crosslink_begin();
1422 transport_global_startup();
1423 if( syncFlags & SYNC_VERBOSE ){
1424 fossil_print(zLabelFormat, "", "Bytes", "Cards", "Artifacts", "Deltas");
1425

Keyboard Shortcuts

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