Fossil SCM

Use better fork detection mechanism and disable checking during push since it may not have a complete sync and issue warning prematurely.

andybradford 2015-04-13 03:38 pending-review
Commit d0e2f1bd3e71ebf64b8b36b06ff8718896f2f342
+1 -1
--- src/info.c
+++ src/info.c
@@ -121,11 +121,11 @@
121121
" WHERE tx.rid=%d"
122122
" AND tx.tagid=%d"
123123
" AND tx.tagtype>0",
124124
rid, TAG_CLOSED)){
125125
fossil_print("%s\n", "closed");
126
- }else if( fossil_find_nearest_fork(rid) ){
126
+ }else if( fossil_find_nearest_fork(rid, 1) ){
127127
fossil_print("%s\n", "fork");
128128
isFork = 1;
129129
}else{
130130
fossil_print("%s\n", "open");
131131
}
132132
--- src/info.c
+++ src/info.c
@@ -121,11 +121,11 @@
121 " WHERE tx.rid=%d"
122 " AND tx.tagid=%d"
123 " AND tx.tagtype>0",
124 rid, TAG_CLOSED)){
125 fossil_print("%s\n", "closed");
126 }else if( fossil_find_nearest_fork(rid) ){
127 fossil_print("%s\n", "fork");
128 isFork = 1;
129 }else{
130 fossil_print("%s\n", "open");
131 }
132
--- src/info.c
+++ src/info.c
@@ -121,11 +121,11 @@
121 " WHERE tx.rid=%d"
122 " AND tx.tagid=%d"
123 " AND tx.tagtype>0",
124 rid, TAG_CLOSED)){
125 fossil_print("%s\n", "closed");
126 }else if( fossil_find_nearest_fork(rid, 1) ){
127 fossil_print("%s\n", "fork");
128 isFork = 1;
129 }else{
130 fossil_print("%s\n", "open");
131 }
132
+13 -1
--- src/leaf.c
+++ src/leaf.c
@@ -151,10 +151,19 @@
151151
db_bind_int(&addLeaf, ":rid", rid);
152152
db_step(&addLeaf);
153153
db_reset(&addLeaf);
154154
}
155155
}
156
+
157
+/*
158
+** Check for a fork against rid and set g.fForkSeen
159
+*/
160
+void fork_check(int rid){
161
+ if( is_a_leaf(rid) && fossil_find_nearest_fork(rid, 0) ){
162
+ g.forkSeen = 1;
163
+ }
164
+}
156165
157166
/*
158167
** Return an SQL expression (stored in memory obtained from fossil_malloc())
159168
** that is true if the SQL variable named "zVar" contains the rid with
160169
** a CLOSED tag. In other words, return true if the leaf is closed.
@@ -188,14 +197,17 @@
188197
}
189198
db_reset(&parentsOf);
190199
}
191200
192201
/*
193
-** Do all pending leaf checks.
202
+** Do all pending leaf and fork checks.
194203
*/
195204
void leaf_do_pending_checks(void){
196205
int rid;
197206
for(rid=bag_first(&needToCheck); rid; rid=bag_next(&needToCheck,rid)){
198207
leaf_check(rid);
208
+ }
209
+ for(rid=bag_first(&needToCheck); rid; rid=bag_next(&needToCheck,rid)){
210
+ fork_check(rid);
199211
}
200212
bag_clear(&needToCheck);
201213
}
202214
--- src/leaf.c
+++ src/leaf.c
@@ -151,10 +151,19 @@
151 db_bind_int(&addLeaf, ":rid", rid);
152 db_step(&addLeaf);
153 db_reset(&addLeaf);
154 }
155 }
 
 
 
 
 
 
 
 
 
156
157 /*
158 ** Return an SQL expression (stored in memory obtained from fossil_malloc())
159 ** that is true if the SQL variable named "zVar" contains the rid with
160 ** a CLOSED tag. In other words, return true if the leaf is closed.
@@ -188,14 +197,17 @@
188 }
189 db_reset(&parentsOf);
190 }
191
192 /*
193 ** Do all pending leaf checks.
194 */
195 void leaf_do_pending_checks(void){
196 int rid;
197 for(rid=bag_first(&needToCheck); rid; rid=bag_next(&needToCheck,rid)){
198 leaf_check(rid);
 
 
 
199 }
200 bag_clear(&needToCheck);
201 }
202
--- src/leaf.c
+++ src/leaf.c
@@ -151,10 +151,19 @@
151 db_bind_int(&addLeaf, ":rid", rid);
152 db_step(&addLeaf);
153 db_reset(&addLeaf);
154 }
155 }
156
157 /*
158 ** Check for a fork against rid and set g.fForkSeen
159 */
160 void fork_check(int rid){
161 if( is_a_leaf(rid) && fossil_find_nearest_fork(rid, 0) ){
162 g.forkSeen = 1;
163 }
164 }
165
166 /*
167 ** Return an SQL expression (stored in memory obtained from fossil_malloc())
168 ** that is true if the SQL variable named "zVar" contains the rid with
169 ** a CLOSED tag. In other words, return true if the leaf is closed.
@@ -188,14 +197,17 @@
197 }
198 db_reset(&parentsOf);
199 }
200
201 /*
202 ** Do all pending leaf and fork checks.
203 */
204 void leaf_do_pending_checks(void){
205 int rid;
206 for(rid=bag_first(&needToCheck); rid; rid=bag_next(&needToCheck,rid)){
207 leaf_check(rid);
208 }
209 for(rid=bag_first(&needToCheck); rid; rid=bag_next(&needToCheck,rid)){
210 fork_check(rid);
211 }
212 bag_clear(&needToCheck);
213 }
214
+1
--- src/main.c
+++ src/main.c
@@ -174,10 +174,11 @@
174174
int xlinkClusterOnly; /* Set when cloning. Only process clusters */
175175
int fTimeFormat; /* 1 for UTC. 2 for localtime. 0 not yet selected */
176176
int *aCommitFile; /* Array of files to be committed */
177177
int markPrivate; /* All new artifacts are private if true */
178178
int clockSkewSeen; /* True if clocks on client and server out of sync */
179
+ int forkSeen; /* True if an unhandled fork was seen during sync */
179180
int wikiFlags; /* Wiki conversion flags applied to %W */
180181
char isHTTP; /* True if server/CGI modes, else assume CLI. */
181182
char javascriptHyperlink; /* If true, set href= using script, not HTML */
182183
Blob httpHeader; /* Complete text of the HTTP request header */
183184
UrlData url; /* Information about current URL */
184185
--- src/main.c
+++ src/main.c
@@ -174,10 +174,11 @@
174 int xlinkClusterOnly; /* Set when cloning. Only process clusters */
175 int fTimeFormat; /* 1 for UTC. 2 for localtime. 0 not yet selected */
176 int *aCommitFile; /* Array of files to be committed */
177 int markPrivate; /* All new artifacts are private if true */
178 int clockSkewSeen; /* True if clocks on client and server out of sync */
 
179 int wikiFlags; /* Wiki conversion flags applied to %W */
180 char isHTTP; /* True if server/CGI modes, else assume CLI. */
181 char javascriptHyperlink; /* If true, set href= using script, not HTML */
182 Blob httpHeader; /* Complete text of the HTTP request header */
183 UrlData url; /* Information about current URL */
184
--- src/main.c
+++ src/main.c
@@ -174,10 +174,11 @@
174 int xlinkClusterOnly; /* Set when cloning. Only process clusters */
175 int fTimeFormat; /* 1 for UTC. 2 for localtime. 0 not yet selected */
176 int *aCommitFile; /* Array of files to be committed */
177 int markPrivate; /* All new artifacts are private if true */
178 int clockSkewSeen; /* True if clocks on client and server out of sync */
179 int forkSeen; /* True if an unhandled fork was seen during sync */
180 int wikiFlags; /* Wiki conversion flags applied to %W */
181 char isHTTP; /* True if server/CGI modes, else assume CLI. */
182 char javascriptHyperlink; /* If true, set href= using script, not HTML */
183 Blob httpHeader; /* Complete text of the HTTP request header */
184 UrlData url; /* Information about current URL */
185
+27 -6
--- src/merge.c
+++ src/merge.c
@@ -57,29 +57,50 @@
5757
5858
5959
/* Pick the most recent leaf that is (1) not equal to vid and (2)
6060
** has not already been merged into vid and (3) the leaf is not
6161
** closed and (4) the leaf is in the same branch as vid.
62
+**
63
+** Set vmergeFlag to control whether the vmerge table is checked.
6264
*/
63
-int fossil_find_nearest_fork(int vid){
64
- return db_int(0,
65
+int fossil_find_nearest_fork(int vid, int vmergeFlag){
66
+ Blob sql;
67
+ Stmt q;
68
+ int rid = 0;
69
+
70
+ blob_zero(&sql);
71
+ blob_append_sql(&sql,
6572
"SELECT leaf.rid"
6673
" FROM leaf, event"
6774
" WHERE leaf.rid=event.objid"
68
- " AND leaf.rid!=%d" /* Constraint (1) */
69
- " AND leaf.rid NOT IN (SELECT merge FROM vmerge)" /* Constraint (2) */
75
+ " AND leaf.rid!=%d", /* Constraint (1) */
76
+ vid
77
+ );
78
+ if( vmergeFlag ){
79
+ blob_append_sql(&sql,
80
+ " AND leaf.rid NOT IN (SELECT merge FROM vmerge)" /* Constraint (2) */
81
+ );
82
+ }
83
+ blob_append_sql(&sql,
7084
" AND NOT EXISTS(SELECT 1 FROM tagxref" /* Constraint (3) */
7185
" WHERE rid=leaf.rid"
7286
" AND tagid=%d"
7387
" AND tagtype>0)"
7488
" AND (SELECT value FROM tagxref" /* Constraint (4) */
7589
" WHERE tagid=%d AND rid=%d AND tagtype>0) ="
7690
" (SELECT value FROM tagxref"
7791
" WHERE tagid=%d AND rid=leaf.rid AND tagtype>0)"
7892
" ORDER BY event.mtime DESC LIMIT 1",
79
- vid, TAG_CLOSED, TAG_BRANCH, vid, TAG_BRANCH
93
+ TAG_CLOSED, TAG_BRANCH, vid, TAG_BRANCH
8094
);
95
+ db_prepare(&q, "%s", blob_sql_text(&sql));
96
+ blob_reset(&sql);
97
+ if( db_step(&q)==SQLITE_ROW ){
98
+ rid = db_column_int(&q, 0);
99
+ }
100
+ db_finalize(&q);
101
+ return rid;
81102
}
82103
83104
/*
84105
** COMMAND: merge
85106
**
@@ -196,11 +217,11 @@
196217
*/
197218
Stmt q;
198219
if( pickFlag || backoutFlag || integrateFlag){
199220
fossil_fatal("cannot use --backout, --cherrypick or --integrate with a fork merge");
200221
}
201
- mid = fossil_find_nearest_fork(vid);
222
+ mid = fossil_find_nearest_fork(vid, 1);
202223
if( mid==0 ){
203224
fossil_fatal("no unmerged forks of branch \"%s\"",
204225
db_text(0, "SELECT value FROM tagxref"
205226
" WHERE tagid=%d AND rid=%d AND tagtype>0",
206227
TAG_BRANCH, vid)
207228
--- src/merge.c
+++ src/merge.c
@@ -57,29 +57,50 @@
57
58
59 /* Pick the most recent leaf that is (1) not equal to vid and (2)
60 ** has not already been merged into vid and (3) the leaf is not
61 ** closed and (4) the leaf is in the same branch as vid.
 
 
62 */
63 int fossil_find_nearest_fork(int vid){
64 return db_int(0,
 
 
 
 
 
65 "SELECT leaf.rid"
66 " FROM leaf, event"
67 " WHERE leaf.rid=event.objid"
68 " AND leaf.rid!=%d" /* Constraint (1) */
69 " AND leaf.rid NOT IN (SELECT merge FROM vmerge)" /* Constraint (2) */
 
 
 
 
 
 
 
70 " AND NOT EXISTS(SELECT 1 FROM tagxref" /* Constraint (3) */
71 " WHERE rid=leaf.rid"
72 " AND tagid=%d"
73 " AND tagtype>0)"
74 " AND (SELECT value FROM tagxref" /* Constraint (4) */
75 " WHERE tagid=%d AND rid=%d AND tagtype>0) ="
76 " (SELECT value FROM tagxref"
77 " WHERE tagid=%d AND rid=leaf.rid AND tagtype>0)"
78 " ORDER BY event.mtime DESC LIMIT 1",
79 vid, TAG_CLOSED, TAG_BRANCH, vid, TAG_BRANCH
80 );
 
 
 
 
 
 
 
81 }
82
83 /*
84 ** COMMAND: merge
85 **
@@ -196,11 +217,11 @@
196 */
197 Stmt q;
198 if( pickFlag || backoutFlag || integrateFlag){
199 fossil_fatal("cannot use --backout, --cherrypick or --integrate with a fork merge");
200 }
201 mid = fossil_find_nearest_fork(vid);
202 if( mid==0 ){
203 fossil_fatal("no unmerged forks of branch \"%s\"",
204 db_text(0, "SELECT value FROM tagxref"
205 " WHERE tagid=%d AND rid=%d AND tagtype>0",
206 TAG_BRANCH, vid)
207
--- src/merge.c
+++ src/merge.c
@@ -57,29 +57,50 @@
57
58
59 /* Pick the most recent leaf that is (1) not equal to vid and (2)
60 ** has not already been merged into vid and (3) the leaf is not
61 ** closed and (4) the leaf is in the same branch as vid.
62 **
63 ** Set vmergeFlag to control whether the vmerge table is checked.
64 */
65 int fossil_find_nearest_fork(int vid, int vmergeFlag){
66 Blob sql;
67 Stmt q;
68 int rid = 0;
69
70 blob_zero(&sql);
71 blob_append_sql(&sql,
72 "SELECT leaf.rid"
73 " FROM leaf, event"
74 " WHERE leaf.rid=event.objid"
75 " AND leaf.rid!=%d", /* Constraint (1) */
76 vid
77 );
78 if( vmergeFlag ){
79 blob_append_sql(&sql,
80 " AND leaf.rid NOT IN (SELECT merge FROM vmerge)" /* Constraint (2) */
81 );
82 }
83 blob_append_sql(&sql,
84 " AND NOT EXISTS(SELECT 1 FROM tagxref" /* Constraint (3) */
85 " WHERE rid=leaf.rid"
86 " AND tagid=%d"
87 " AND tagtype>0)"
88 " AND (SELECT value FROM tagxref" /* Constraint (4) */
89 " WHERE tagid=%d AND rid=%d AND tagtype>0) ="
90 " (SELECT value FROM tagxref"
91 " WHERE tagid=%d AND rid=leaf.rid AND tagtype>0)"
92 " ORDER BY event.mtime DESC LIMIT 1",
93 TAG_CLOSED, TAG_BRANCH, vid, TAG_BRANCH
94 );
95 db_prepare(&q, "%s", blob_sql_text(&sql));
96 blob_reset(&sql);
97 if( db_step(&q)==SQLITE_ROW ){
98 rid = db_column_int(&q, 0);
99 }
100 db_finalize(&q);
101 return rid;
102 }
103
104 /*
105 ** COMMAND: merge
106 **
@@ -196,11 +217,11 @@
217 */
218 Stmt q;
219 if( pickFlag || backoutFlag || integrateFlag){
220 fossil_fatal("cannot use --backout, --cherrypick or --integrate with a fork merge");
221 }
222 mid = fossil_find_nearest_fork(vid, 1);
223 if( mid==0 ){
224 fossil_fatal("no unmerged forks of branch \"%s\"",
225 db_text(0, "SELECT value FROM tagxref"
226 " WHERE tagid=%d AND rid=%d AND tagtype>0",
227 TAG_BRANCH, vid)
228
+4 -31
--- src/xfer.c
+++ src/xfer.c
@@ -47,11 +47,10 @@
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" when pOut reaches this size */
5151
int resync; /* Send igot cards for all holdings */
52
- int fHasFork; /* True if a fork has been seen */
5352
u8 syncPrivate; /* True to enable syncing private content */
5453
u8 nextIsPrivate; /* If true, next "file" received is a private */
5554
time_t maxTime; /* Time when this transfer should be finished */
5655
};
5756
@@ -203,14 +202,10 @@
203202
blob_appendf(&pXfer->err, "%s", g.zErrMsg);
204203
blob_reset(&content);
205204
}else{
206205
if( !isPriv ) content_make_public(rid);
207206
manifest_crosslink(rid, &content, MC_NO_ERRORS);
208
- if( cloneFlag==0 &&
209
- count_nonbranch_children(primary_parent_pid_from_rid(rid))>1 ){
210
- pXfer->fHasFork = 1;
211
- }
212207
}
213208
assert( blob_is_reset(&content) );
214209
remote_has(rid);
215210
}
216211
@@ -283,14 +278,10 @@
283278
}
284279
rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid,
285280
szC, isPriv);
286281
Th_AppendToList(pzUuidList, pnUuidList, blob_str(&pXfer->aToken[1]),
287282
blob_size(&pXfer->aToken[1]));
288
- if( cloneFlag==0 &&
289
- count_nonbranch_children(primary_parent_pid_from_rid(rid))>1 ){
290
- pXfer->fHasFork = 1;
291
- }
292283
remote_has(rid);
293284
blob_reset(&content);
294285
}
295286
296287
/*
@@ -933,11 +924,10 @@
933924
*/
934925
void page_xfer(void){
935926
int isPull = 0;
936927
int isPush = 0;
937928
int nErr = 0;
938
- int fForkSeen = 0; /* True if fork was seen while receiving content */
939929
Xfer xfer;
940930
int deltaFlag = 0;
941931
int isClone = 0;
942932
int nGimme = 0;
943933
int size;
@@ -988,11 +978,10 @@
988978
if( zScript ){ /* NOTE: Are TH1 transfer hooks enabled? */
989979
pzUuidList = &zUuidList;
990980
pnUuidList = &nUuidList;
991981
}
992982
while( blob_line(xfer.pIn, &xfer.line) ){
993
- xfer.fHasFork = 0;
994983
if( blob_buffer(&xfer.line)[0]=='#' ) continue;
995984
if( blob_size(&xfer.line)==0 ) continue;
996985
xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
997986
998987
/* file UUID SIZE \n CONTENT
@@ -1006,13 +995,10 @@
1006995
@ error not\sauthorized\sto\swrite
1007996
nErr++;
1008997
break;
1009998
}
1010999
xfer_accept_file(&xfer, 0, pzUuidList, pnUuidList);
1011
- if( xfer.fHasFork ){
1012
- fForkSeen = 1;
1013
- }
10141000
if( blob_size(&xfer.err) ){
10151001
cgi_reset_content();
10161002
@ error %T(blob_str(&xfer.err))
10171003
nErr++;
10181004
break;
@@ -1030,13 +1016,10 @@
10301016
@ error not\sauthorized\sto\swrite
10311017
nErr++;
10321018
break;
10331019
}
10341020
xfer_accept_compressed_file(&xfer, 0, pzUuidList, pnUuidList);
1035
- if( xfer.fHasFork ){
1036
- fForkSeen = 1;
1037
- }
10381021
if( blob_size(&xfer.err) ){
10391022
cgi_reset_content();
10401023
@ error %T(blob_str(&xfer.err))
10411024
nErr++;
10421025
break;
@@ -1315,13 +1298,10 @@
13151298
@ error bad\scommand:\s%F(blob_str(&xfer.line))
13161299
}
13171300
blobarray_reset(xfer.aToken, xfer.nToken);
13181301
blob_reset(&xfer.line);
13191302
}
1320
- if( fForkSeen ){
1321
- @ message *****\s\sWARNING:\sa\sfork\shas\soccurred\s\s*****
1322
- }
13231303
if( isPush ){
13241304
if( rc==TH_OK ){
13251305
rc = xfer_run_script(zScript, zUuidList, 1);
13261306
if( rc==TH_ERROR ){
13271307
cgi_reset_content();
@@ -1456,11 +1436,10 @@
14561436
int lastPctDone = -1; /* Last displayed pctDone */
14571437
double rArrivalTime; /* Time at which a message arrived */
14581438
const char *zSCode = db_get("server-code", "x");
14591439
const char *zPCode = db_get("project-code", 0);
14601440
int nErr = 0; /* Number of errors */
1461
- int fForkSeen = 0; /* True if a fork was seen during pull */
14621441
int nRoundtrip= 0; /* Number of HTTP requests */
14631442
int nArtifactSent = 0; /* Total artifacts sent */
14641443
int nArtifactRcvd = 0; /* Total artifacts received */
14651444
const char *zOpType = 0;/* Push, Pull, Sync, Clone */
14661445
double rSkew = 0.0; /* Maximum time skew */
@@ -1474,10 +1453,11 @@
14741453
memset(&xfer, 0, sizeof(xfer));
14751454
xfer.pIn = &recv;
14761455
xfer.pOut = &send;
14771456
xfer.mxSend = db_get_int("max-upload", 250000);
14781457
xfer.maxTime = -1;
1458
+ g.forkSeen = 0;
14791459
if( syncFlags & SYNC_PRIVATE ){
14801460
g.perm.Private = 1;
14811461
xfer.syncPrivate = 1;
14821462
}
14831463
@@ -1672,11 +1652,10 @@
16721652
}
16731653
nCardRcvd++;
16741654
continue;
16751655
}
16761656
xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
1677
- xfer.fHasFork = 0;
16781657
nCardRcvd++;
16791658
if( (syncFlags & SYNC_VERBOSE)!=0 && recv.nUsed>0 ){
16801659
pctDone = (recv.iCursor*100)/recv.nUsed;
16811660
if( pctDone!=lastPctDone ){
16821661
fossil_print("\rprocessed: %d%% ", pctDone);
@@ -1690,13 +1669,10 @@
16901669
**
16911670
** Receive a file transmitted from the server.
16921671
*/
16931672
if( blob_eq(&xfer.aToken[0],"file") ){
16941673
xfer_accept_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0);
1695
- if( (syncFlags & SYNC_PULL) && xfer.fHasFork ){
1696
- fForkSeen = 1;
1697
- }
16981674
nArtifactRcvd++;
16991675
}else
17001676
17011677
/* cfile UUID USIZE CSIZE \n CONTENT
17021678
** cfile UUID DELTASRC USIZE CSIZE \n CONTENT
@@ -1703,13 +1679,10 @@
17031679
**
17041680
** Receive a compressed file transmitted from the server.
17051681
*/
17061682
if( blob_eq(&xfer.aToken[0],"cfile") ){
17071683
xfer_accept_compressed_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0);
1708
- if( (syncFlags & SYNC_PULL) && xfer.fHasFork ){
1709
- fForkSeen = 1;
1710
- }
17111684
nArtifactRcvd++;
17121685
}else
17131686
17141687
/* gimme UUID
17151688
**
@@ -1978,13 +1951,10 @@
19781951
manifest_crosslink_end(MC_PERMIT_HOOKS);
19791952
content_enable_dephantomize(1);
19801953
}
19811954
db_end_transaction(0);
19821955
};
1983
- if( fForkSeen ){
1984
- fossil_warning("***** WARNING: a fork has occurred *****");
1985
- }
19861956
transport_stats(&nSent, &nRcvd, 1);
19871957
if( (rSkew*24.0*3600.0) > 10.0 ){
19881958
fossil_warning("*** time skew *** server is fast by %s",
19891959
db_timespan_name(rSkew));
19901960
g.clockSkewSeen = 1;
@@ -2004,7 +1974,10 @@
20041974
db_multi_exec("DROP TABLE onremote");
20051975
manifest_crosslink_end(MC_PERMIT_HOOKS);
20061976
content_enable_dephantomize(1);
20071977
db_end_transaction(0);
20081978
}
1979
+ if( (syncFlags & SYNC_CLONE)==0 && g.forkSeen ){
1980
+ fossil_warning("***** WARNING: a fork has occurred *****");
1981
+ }
20091982
return nErr;
20101983
}
20111984
--- src/xfer.c
+++ src/xfer.c
@@ -47,11 +47,10 @@
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" when pOut reaches this size */
51 int resync; /* Send igot cards for all holdings */
52 int fHasFork; /* True if a fork has been seen */
53 u8 syncPrivate; /* True to enable syncing private content */
54 u8 nextIsPrivate; /* If true, next "file" received is a private */
55 time_t maxTime; /* Time when this transfer should be finished */
56 };
57
@@ -203,14 +202,10 @@
203 blob_appendf(&pXfer->err, "%s", g.zErrMsg);
204 blob_reset(&content);
205 }else{
206 if( !isPriv ) content_make_public(rid);
207 manifest_crosslink(rid, &content, MC_NO_ERRORS);
208 if( cloneFlag==0 &&
209 count_nonbranch_children(primary_parent_pid_from_rid(rid))>1 ){
210 pXfer->fHasFork = 1;
211 }
212 }
213 assert( blob_is_reset(&content) );
214 remote_has(rid);
215 }
216
@@ -283,14 +278,10 @@
283 }
284 rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid,
285 szC, isPriv);
286 Th_AppendToList(pzUuidList, pnUuidList, blob_str(&pXfer->aToken[1]),
287 blob_size(&pXfer->aToken[1]));
288 if( cloneFlag==0 &&
289 count_nonbranch_children(primary_parent_pid_from_rid(rid))>1 ){
290 pXfer->fHasFork = 1;
291 }
292 remote_has(rid);
293 blob_reset(&content);
294 }
295
296 /*
@@ -933,11 +924,10 @@
933 */
934 void page_xfer(void){
935 int isPull = 0;
936 int isPush = 0;
937 int nErr = 0;
938 int fForkSeen = 0; /* True if fork was seen while receiving content */
939 Xfer xfer;
940 int deltaFlag = 0;
941 int isClone = 0;
942 int nGimme = 0;
943 int size;
@@ -988,11 +978,10 @@
988 if( zScript ){ /* NOTE: Are TH1 transfer hooks enabled? */
989 pzUuidList = &zUuidList;
990 pnUuidList = &nUuidList;
991 }
992 while( blob_line(xfer.pIn, &xfer.line) ){
993 xfer.fHasFork = 0;
994 if( blob_buffer(&xfer.line)[0]=='#' ) continue;
995 if( blob_size(&xfer.line)==0 ) continue;
996 xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
997
998 /* file UUID SIZE \n CONTENT
@@ -1006,13 +995,10 @@
1006 @ error not\sauthorized\sto\swrite
1007 nErr++;
1008 break;
1009 }
1010 xfer_accept_file(&xfer, 0, pzUuidList, pnUuidList);
1011 if( xfer.fHasFork ){
1012 fForkSeen = 1;
1013 }
1014 if( blob_size(&xfer.err) ){
1015 cgi_reset_content();
1016 @ error %T(blob_str(&xfer.err))
1017 nErr++;
1018 break;
@@ -1030,13 +1016,10 @@
1030 @ error not\sauthorized\sto\swrite
1031 nErr++;
1032 break;
1033 }
1034 xfer_accept_compressed_file(&xfer, 0, pzUuidList, pnUuidList);
1035 if( xfer.fHasFork ){
1036 fForkSeen = 1;
1037 }
1038 if( blob_size(&xfer.err) ){
1039 cgi_reset_content();
1040 @ error %T(blob_str(&xfer.err))
1041 nErr++;
1042 break;
@@ -1315,13 +1298,10 @@
1315 @ error bad\scommand:\s%F(blob_str(&xfer.line))
1316 }
1317 blobarray_reset(xfer.aToken, xfer.nToken);
1318 blob_reset(&xfer.line);
1319 }
1320 if( fForkSeen ){
1321 @ message *****\s\sWARNING:\sa\sfork\shas\soccurred\s\s*****
1322 }
1323 if( isPush ){
1324 if( rc==TH_OK ){
1325 rc = xfer_run_script(zScript, zUuidList, 1);
1326 if( rc==TH_ERROR ){
1327 cgi_reset_content();
@@ -1456,11 +1436,10 @@
1456 int lastPctDone = -1; /* Last displayed pctDone */
1457 double rArrivalTime; /* Time at which a message arrived */
1458 const char *zSCode = db_get("server-code", "x");
1459 const char *zPCode = db_get("project-code", 0);
1460 int nErr = 0; /* Number of errors */
1461 int fForkSeen = 0; /* True if a fork was seen during pull */
1462 int nRoundtrip= 0; /* Number of HTTP requests */
1463 int nArtifactSent = 0; /* Total artifacts sent */
1464 int nArtifactRcvd = 0; /* Total artifacts received */
1465 const char *zOpType = 0;/* Push, Pull, Sync, Clone */
1466 double rSkew = 0.0; /* Maximum time skew */
@@ -1474,10 +1453,11 @@
1474 memset(&xfer, 0, sizeof(xfer));
1475 xfer.pIn = &recv;
1476 xfer.pOut = &send;
1477 xfer.mxSend = db_get_int("max-upload", 250000);
1478 xfer.maxTime = -1;
 
1479 if( syncFlags & SYNC_PRIVATE ){
1480 g.perm.Private = 1;
1481 xfer.syncPrivate = 1;
1482 }
1483
@@ -1672,11 +1652,10 @@
1672 }
1673 nCardRcvd++;
1674 continue;
1675 }
1676 xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
1677 xfer.fHasFork = 0;
1678 nCardRcvd++;
1679 if( (syncFlags & SYNC_VERBOSE)!=0 && recv.nUsed>0 ){
1680 pctDone = (recv.iCursor*100)/recv.nUsed;
1681 if( pctDone!=lastPctDone ){
1682 fossil_print("\rprocessed: %d%% ", pctDone);
@@ -1690,13 +1669,10 @@
1690 **
1691 ** Receive a file transmitted from the server.
1692 */
1693 if( blob_eq(&xfer.aToken[0],"file") ){
1694 xfer_accept_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0);
1695 if( (syncFlags & SYNC_PULL) && xfer.fHasFork ){
1696 fForkSeen = 1;
1697 }
1698 nArtifactRcvd++;
1699 }else
1700
1701 /* cfile UUID USIZE CSIZE \n CONTENT
1702 ** cfile UUID DELTASRC USIZE CSIZE \n CONTENT
@@ -1703,13 +1679,10 @@
1703 **
1704 ** Receive a compressed file transmitted from the server.
1705 */
1706 if( blob_eq(&xfer.aToken[0],"cfile") ){
1707 xfer_accept_compressed_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0);
1708 if( (syncFlags & SYNC_PULL) && xfer.fHasFork ){
1709 fForkSeen = 1;
1710 }
1711 nArtifactRcvd++;
1712 }else
1713
1714 /* gimme UUID
1715 **
@@ -1978,13 +1951,10 @@
1978 manifest_crosslink_end(MC_PERMIT_HOOKS);
1979 content_enable_dephantomize(1);
1980 }
1981 db_end_transaction(0);
1982 };
1983 if( fForkSeen ){
1984 fossil_warning("***** WARNING: a fork has occurred *****");
1985 }
1986 transport_stats(&nSent, &nRcvd, 1);
1987 if( (rSkew*24.0*3600.0) > 10.0 ){
1988 fossil_warning("*** time skew *** server is fast by %s",
1989 db_timespan_name(rSkew));
1990 g.clockSkewSeen = 1;
@@ -2004,7 +1974,10 @@
2004 db_multi_exec("DROP TABLE onremote");
2005 manifest_crosslink_end(MC_PERMIT_HOOKS);
2006 content_enable_dephantomize(1);
2007 db_end_transaction(0);
2008 }
 
 
 
2009 return nErr;
2010 }
2011
--- src/xfer.c
+++ src/xfer.c
@@ -47,11 +47,10 @@
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" when 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
@@ -203,14 +202,10 @@
202 blob_appendf(&pXfer->err, "%s", g.zErrMsg);
203 blob_reset(&content);
204 }else{
205 if( !isPriv ) content_make_public(rid);
206 manifest_crosslink(rid, &content, MC_NO_ERRORS);
 
 
 
 
207 }
208 assert( blob_is_reset(&content) );
209 remote_has(rid);
210 }
211
@@ -283,14 +278,10 @@
278 }
279 rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid,
280 szC, isPriv);
281 Th_AppendToList(pzUuidList, pnUuidList, blob_str(&pXfer->aToken[1]),
282 blob_size(&pXfer->aToken[1]));
 
 
 
 
283 remote_has(rid);
284 blob_reset(&content);
285 }
286
287 /*
@@ -933,11 +924,10 @@
924 */
925 void page_xfer(void){
926 int isPull = 0;
927 int isPush = 0;
928 int nErr = 0;
 
929 Xfer xfer;
930 int deltaFlag = 0;
931 int isClone = 0;
932 int nGimme = 0;
933 int size;
@@ -988,11 +978,10 @@
978 if( zScript ){ /* NOTE: Are TH1 transfer hooks enabled? */
979 pzUuidList = &zUuidList;
980 pnUuidList = &nUuidList;
981 }
982 while( blob_line(xfer.pIn, &xfer.line) ){
 
983 if( blob_buffer(&xfer.line)[0]=='#' ) continue;
984 if( blob_size(&xfer.line)==0 ) continue;
985 xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
986
987 /* file UUID SIZE \n CONTENT
@@ -1006,13 +995,10 @@
995 @ error not\sauthorized\sto\swrite
996 nErr++;
997 break;
998 }
999 xfer_accept_file(&xfer, 0, pzUuidList, pnUuidList);
 
 
 
1000 if( blob_size(&xfer.err) ){
1001 cgi_reset_content();
1002 @ error %T(blob_str(&xfer.err))
1003 nErr++;
1004 break;
@@ -1030,13 +1016,10 @@
1016 @ error not\sauthorized\sto\swrite
1017 nErr++;
1018 break;
1019 }
1020 xfer_accept_compressed_file(&xfer, 0, pzUuidList, pnUuidList);
 
 
 
1021 if( blob_size(&xfer.err) ){
1022 cgi_reset_content();
1023 @ error %T(blob_str(&xfer.err))
1024 nErr++;
1025 break;
@@ -1315,13 +1298,10 @@
1298 @ error bad\scommand:\s%F(blob_str(&xfer.line))
1299 }
1300 blobarray_reset(xfer.aToken, xfer.nToken);
1301 blob_reset(&xfer.line);
1302 }
 
 
 
1303 if( isPush ){
1304 if( rc==TH_OK ){
1305 rc = xfer_run_script(zScript, zUuidList, 1);
1306 if( rc==TH_ERROR ){
1307 cgi_reset_content();
@@ -1456,11 +1436,10 @@
1436 int lastPctDone = -1; /* Last displayed pctDone */
1437 double rArrivalTime; /* Time at which a message arrived */
1438 const char *zSCode = db_get("server-code", "x");
1439 const char *zPCode = db_get("project-code", 0);
1440 int nErr = 0; /* Number of errors */
 
1441 int nRoundtrip= 0; /* Number of HTTP requests */
1442 int nArtifactSent = 0; /* Total artifacts sent */
1443 int nArtifactRcvd = 0; /* Total artifacts received */
1444 const char *zOpType = 0;/* Push, Pull, Sync, Clone */
1445 double rSkew = 0.0; /* Maximum time skew */
@@ -1474,10 +1453,11 @@
1453 memset(&xfer, 0, sizeof(xfer));
1454 xfer.pIn = &recv;
1455 xfer.pOut = &send;
1456 xfer.mxSend = db_get_int("max-upload", 250000);
1457 xfer.maxTime = -1;
1458 g.forkSeen = 0;
1459 if( syncFlags & SYNC_PRIVATE ){
1460 g.perm.Private = 1;
1461 xfer.syncPrivate = 1;
1462 }
1463
@@ -1672,11 +1652,10 @@
1652 }
1653 nCardRcvd++;
1654 continue;
1655 }
1656 xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
 
1657 nCardRcvd++;
1658 if( (syncFlags & SYNC_VERBOSE)!=0 && recv.nUsed>0 ){
1659 pctDone = (recv.iCursor*100)/recv.nUsed;
1660 if( pctDone!=lastPctDone ){
1661 fossil_print("\rprocessed: %d%% ", pctDone);
@@ -1690,13 +1669,10 @@
1669 **
1670 ** Receive a file transmitted from the server.
1671 */
1672 if( blob_eq(&xfer.aToken[0],"file") ){
1673 xfer_accept_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0);
 
 
 
1674 nArtifactRcvd++;
1675 }else
1676
1677 /* cfile UUID USIZE CSIZE \n CONTENT
1678 ** cfile UUID DELTASRC USIZE CSIZE \n CONTENT
@@ -1703,13 +1679,10 @@
1679 **
1680 ** Receive a compressed file transmitted from the server.
1681 */
1682 if( blob_eq(&xfer.aToken[0],"cfile") ){
1683 xfer_accept_compressed_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0);
 
 
 
1684 nArtifactRcvd++;
1685 }else
1686
1687 /* gimme UUID
1688 **
@@ -1978,13 +1951,10 @@
1951 manifest_crosslink_end(MC_PERMIT_HOOKS);
1952 content_enable_dephantomize(1);
1953 }
1954 db_end_transaction(0);
1955 };
 
 
 
1956 transport_stats(&nSent, &nRcvd, 1);
1957 if( (rSkew*24.0*3600.0) > 10.0 ){
1958 fossil_warning("*** time skew *** server is fast by %s",
1959 db_timespan_name(rSkew));
1960 g.clockSkewSeen = 1;
@@ -2004,7 +1974,10 @@
1974 db_multi_exec("DROP TABLE onremote");
1975 manifest_crosslink_end(MC_PERMIT_HOOKS);
1976 content_enable_dephantomize(1);
1977 db_end_transaction(0);
1978 }
1979 if( (syncFlags & SYNC_CLONE)==0 && g.forkSeen ){
1980 fossil_warning("***** WARNING: a fork has occurred *****");
1981 }
1982 return nErr;
1983 }
1984

Keyboard Shortcuts

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