Fossil SCM

Only check for forks in newly received content after all round-trips of sync have completed.

andybradford 2015-04-22 05:21 sync-forkwarn
Commit b9728c4aa23b80244b391dc005bd58c2e942a7f9
3 files changed +1 -13 +25 +1 -1
+1 -13
--- src/leaf.c
+++ src/leaf.c
@@ -134,19 +134,10 @@
134134
db_step(&addLeaf);
135135
db_reset(&addLeaf);
136136
}
137137
}
138138
139
-/*
140
-** Check for a fork against rid and set g.fForkSeen
141
-*/
142
-void fork_check(int rid){
143
- if( is_a_leaf(rid) && fossil_find_nearest_fork(rid, 0) ){
144
- g.forkSeen = 1;
145
- }
146
-}
147
-
148139
/*
149140
** Return an SQL expression (stored in memory obtained from fossil_malloc())
150141
** that is true if the SQL variable named "zVar" contains the rid with
151142
** a CLOSED tag. In other words, return true if the leaf is closed.
152143
**
@@ -179,17 +170,14 @@
179170
}
180171
db_reset(&parentsOf);
181172
}
182173
183174
/*
184
-** Do all pending leaf and fork checks.
175
+** Do all pending leaf checks.
185176
*/
186177
void leaf_do_pending_checks(void){
187178
int rid;
188179
for(rid=bag_first(&needToCheck); rid; rid=bag_next(&needToCheck,rid)){
189180
leaf_check(rid);
190181
}
191
- for(rid=bag_first(&needToCheck); rid; rid=bag_next(&needToCheck,rid)){
192
- fork_check(rid);
193
- }
194182
bag_clear(&needToCheck);
195183
}
196184
--- src/leaf.c
+++ src/leaf.c
@@ -134,19 +134,10 @@
134 db_step(&addLeaf);
135 db_reset(&addLeaf);
136 }
137 }
138
139 /*
140 ** Check for a fork against rid and set g.fForkSeen
141 */
142 void fork_check(int rid){
143 if( is_a_leaf(rid) && fossil_find_nearest_fork(rid, 0) ){
144 g.forkSeen = 1;
145 }
146 }
147
148 /*
149 ** Return an SQL expression (stored in memory obtained from fossil_malloc())
150 ** that is true if the SQL variable named "zVar" contains the rid with
151 ** a CLOSED tag. In other words, return true if the leaf is closed.
152 **
@@ -179,17 +170,14 @@
179 }
180 db_reset(&parentsOf);
181 }
182
183 /*
184 ** Do all pending leaf and fork checks.
185 */
186 void leaf_do_pending_checks(void){
187 int rid;
188 for(rid=bag_first(&needToCheck); rid; rid=bag_next(&needToCheck,rid)){
189 leaf_check(rid);
190 }
191 for(rid=bag_first(&needToCheck); rid; rid=bag_next(&needToCheck,rid)){
192 fork_check(rid);
193 }
194 bag_clear(&needToCheck);
195 }
196
--- src/leaf.c
+++ src/leaf.c
@@ -134,19 +134,10 @@
134 db_step(&addLeaf);
135 db_reset(&addLeaf);
136 }
137 }
138
 
 
 
 
 
 
 
 
 
139 /*
140 ** Return an SQL expression (stored in memory obtained from fossil_malloc())
141 ** that is true if the SQL variable named "zVar" contains the rid with
142 ** a CLOSED tag. In other words, return true if the leaf is closed.
143 **
@@ -179,17 +170,14 @@
170 }
171 db_reset(&parentsOf);
172 }
173
174 /*
175 ** Do all pending leaf checks.
176 */
177 void leaf_do_pending_checks(void){
178 int rid;
179 for(rid=bag_first(&needToCheck); rid; rid=bag_next(&needToCheck,rid)){
180 leaf_check(rid);
181 }
 
 
 
182 bag_clear(&needToCheck);
183 }
184
+25
--- src/merge.c
+++ src/merge.c
@@ -98,10 +98,35 @@
9898
rid = db_column_int(&q, 0);
9999
}
100100
db_finalize(&q);
101101
return rid;
102102
}
103
+
104
+/*
105
+** Check for any fork that is not a closed leaf and that was received
106
+** with rcvid and return true if any is found.
107
+*/
108
+int fossil_find_any_fork(int rcvid){
109
+ Blob sql;
110
+ Stmt q;
111
+ int fForkSeen = 0;
112
+
113
+ blob_zero(&sql);
114
+ blob_append_sql(&sql,
115
+ " SELECT blob.rid FROM blob"
116
+ " JOIN leaf ON blob.rid=leaf.rid"
117
+ " WHERE rcvid = %d"
118
+ " AND NOT %z", rcvid, leaf_is_closed_sql("leaf.rid"));
119
+ db_prepare(&q, "%s", blob_sql_text(&sql));
120
+ blob_reset(&sql);
121
+ while( !fForkSeen && db_step(&q)==SQLITE_ROW ){
122
+ int rid = db_column_int(&q, 0);
123
+ fForkSeen = fossil_find_nearest_fork(rid, db_open_local(0))!=0;
124
+ }
125
+ db_finalize(&q);
126
+ return fForkSeen;
127
+}
103128
104129
/*
105130
** COMMAND: merge
106131
**
107132
** Usage: %fossil merge ?OPTIONS? ?VERSION?
108133
--- src/merge.c
+++ src/merge.c
@@ -98,10 +98,35 @@
98 rid = db_column_int(&q, 0);
99 }
100 db_finalize(&q);
101 return rid;
102 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
104 /*
105 ** COMMAND: merge
106 **
107 ** Usage: %fossil merge ?OPTIONS? ?VERSION?
108
--- src/merge.c
+++ src/merge.c
@@ -98,10 +98,35 @@
98 rid = db_column_int(&q, 0);
99 }
100 db_finalize(&q);
101 return rid;
102 }
103
104 /*
105 ** Check for any fork that is not a closed leaf and that was received
106 ** with rcvid and return true if any is found.
107 */
108 int fossil_find_any_fork(int rcvid){
109 Blob sql;
110 Stmt q;
111 int fForkSeen = 0;
112
113 blob_zero(&sql);
114 blob_append_sql(&sql,
115 " SELECT blob.rid FROM blob"
116 " JOIN leaf ON blob.rid=leaf.rid"
117 " WHERE rcvid = %d"
118 " AND NOT %z", rcvid, leaf_is_closed_sql("leaf.rid"));
119 db_prepare(&q, "%s", blob_sql_text(&sql));
120 blob_reset(&sql);
121 while( !fForkSeen && db_step(&q)==SQLITE_ROW ){
122 int rid = db_column_int(&q, 0);
123 fForkSeen = fossil_find_nearest_fork(rid, db_open_local(0))!=0;
124 }
125 db_finalize(&q);
126 return fForkSeen;
127 }
128
129 /*
130 ** COMMAND: merge
131 **
132 ** Usage: %fossil merge ?OPTIONS? ?VERSION?
133
+1 -1
--- src/xfer.c
+++ src/xfer.c
@@ -1973,11 +1973,11 @@
19731973
db_multi_exec("DROP TABLE onremote");
19741974
manifest_crosslink_end(MC_PERMIT_HOOKS);
19751975
content_enable_dephantomize(1);
19761976
db_end_transaction(0);
19771977
}
1978
- if( (syncFlags & SYNC_CLONE)==0 && g.forkSeen ){
1978
+ if( (syncFlags & SYNC_CLONE)==0 && fossil_find_any_fork(g.rcvid) ){
19791979
fossil_warning("***** WARNING: a fork has occurred ***** use "
19801980
"\"fossil forks\" for more details.");
19811981
}
19821982
return nErr;
19831983
}
19841984
--- src/xfer.c
+++ src/xfer.c
@@ -1973,11 +1973,11 @@
1973 db_multi_exec("DROP TABLE onremote");
1974 manifest_crosslink_end(MC_PERMIT_HOOKS);
1975 content_enable_dephantomize(1);
1976 db_end_transaction(0);
1977 }
1978 if( (syncFlags & SYNC_CLONE)==0 && g.forkSeen ){
1979 fossil_warning("***** WARNING: a fork has occurred ***** use "
1980 "\"fossil forks\" for more details.");
1981 }
1982 return nErr;
1983 }
1984
--- src/xfer.c
+++ src/xfer.c
@@ -1973,11 +1973,11 @@
1973 db_multi_exec("DROP TABLE onremote");
1974 manifest_crosslink_end(MC_PERMIT_HOOKS);
1975 content_enable_dephantomize(1);
1976 db_end_transaction(0);
1977 }
1978 if( (syncFlags & SYNC_CLONE)==0 && fossil_find_any_fork(g.rcvid) ){
1979 fossil_warning("***** WARNING: a fork has occurred ***** use "
1980 "\"fossil forks\" for more details.");
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