Fossil

Check-in [b9728c4a]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Only check for forks in newly received content after all round-trips of sync have completed.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sync-forkwarn
Files: files | file ages | folders
SHA1:b9728c4aa23b80244b391dc005bd58c2e942a7f9
User & Date: andybradford 2015-04-22 05:21:23
Context
2015-04-22
16:32
Style consistency change only. check-in: e1f614f3 user: andybradford tags: sync-forkwarn
16:23
Style consistency change. Closed-Leaf check-in: 509360e5 user: andybradford tags: mistake
05:21
Only check for forks in newly received content after all round-trips of sync have completed. check-in: b9728c4a user: andybradford tags: sync-forkwarn
2015-04-19
18:26
Merge trunk. More to-the-point message in case of fork warnings after sync. check-in: cf59ea31 user: jan.nijtmans tags: sync-forkwarn
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/leaf.c.

132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
...
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
    db_static_prepare(&addLeaf, "INSERT OR IGNORE INTO leaf VALUES(:rid)");
    db_bind_int(&addLeaf, ":rid", rid);
    db_step(&addLeaf);
    db_reset(&addLeaf);
  }
}

/*
** Check for a fork against rid and set g.fForkSeen
*/
void fork_check(int rid){
  if( is_a_leaf(rid) && fossil_find_nearest_fork(rid, 0) ){
    g.forkSeen = 1;
  }
}

/*
** Return an SQL expression (stored in memory obtained from fossil_malloc())
** that is true if the SQL variable named "zVar" contains the rid with
** a CLOSED tag.  In other words, return true if the leaf is closed.
**
** The result can be prefaced with a NOT operator to get all leaves that
** are open.
................................................................................
  while( db_step(&parentsOf)==SQLITE_ROW ){
    bag_insert(&needToCheck, db_column_int(&parentsOf, 0));
  }
  db_reset(&parentsOf);
}

/*
** Do all pending leaf and fork checks.
*/
void leaf_do_pending_checks(void){
  int rid;
  for(rid=bag_first(&needToCheck); rid; rid=bag_next(&needToCheck,rid)){
    leaf_check(rid);
  }
  for(rid=bag_first(&needToCheck); rid; rid=bag_next(&needToCheck,rid)){
    fork_check(rid);
  }
  bag_clear(&needToCheck);
}







<
<
<
<
<
<
<
<
<







 







|






<
<
<


132
133
134
135
136
137
138









139
140
141
142
143
144
145
...
168
169
170
171
172
173
174
175
176
177
178
179
180
181



182
183
    db_static_prepare(&addLeaf, "INSERT OR IGNORE INTO leaf VALUES(:rid)");
    db_bind_int(&addLeaf, ":rid", rid);
    db_step(&addLeaf);
    db_reset(&addLeaf);
  }
}










/*
** Return an SQL expression (stored in memory obtained from fossil_malloc())
** that is true if the SQL variable named "zVar" contains the rid with
** a CLOSED tag.  In other words, return true if the leaf is closed.
**
** The result can be prefaced with a NOT operator to get all leaves that
** are open.
................................................................................
  while( db_step(&parentsOf)==SQLITE_ROW ){
    bag_insert(&needToCheck, db_column_int(&parentsOf, 0));
  }
  db_reset(&parentsOf);
}

/*
** Do all pending leaf checks.
*/
void leaf_do_pending_checks(void){
  int rid;
  for(rid=bag_first(&needToCheck); rid; rid=bag_next(&needToCheck,rid)){
    leaf_check(rid);
  }



  bag_clear(&needToCheck);
}

Changes to src/merge.c.

96
97
98
99
100
101
102

























103
104
105
106
107
108
109
  blob_reset(&sql);
  if( db_step(&q)==SQLITE_ROW ){
    rid = db_column_int(&q, 0);
  }
  db_finalize(&q);
  return rid;
}


























/*
** COMMAND: merge
**
** Usage: %fossil merge ?OPTIONS? ?VERSION?
**
** The argument VERSION is a version that should be merged into the







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
  blob_reset(&sql);
  if( db_step(&q)==SQLITE_ROW ){
    rid = db_column_int(&q, 0);
  }
  db_finalize(&q);
  return rid;
}

/*
** Check for any fork that is not a closed leaf and that was received
** with rcvid and return true if any is found.
*/
int fossil_find_any_fork(int rcvid){
  Blob sql;
  Stmt q;
  int fForkSeen = 0;

  blob_zero(&sql);
  blob_append_sql(&sql,
    "  SELECT blob.rid FROM blob"
    "    JOIN leaf ON blob.rid=leaf.rid"
    "   WHERE rcvid = %d" 
    " AND NOT %z", rcvid, leaf_is_closed_sql("leaf.rid"));
  db_prepare(&q, "%s", blob_sql_text(&sql));
  blob_reset(&sql);
  while( !fForkSeen && db_step(&q)==SQLITE_ROW ){
    int rid = db_column_int(&q, 0);
    fForkSeen = fossil_find_nearest_fork(rid, db_open_local(0))!=0;
  }
  db_finalize(&q);
  return fForkSeen;
}

/*
** COMMAND: merge
**
** Usage: %fossil merge ?OPTIONS? ?VERSION?
**
** The argument VERSION is a version that should be merged into the

Changes to src/xfer.c.

1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
  transport_global_shutdown(&g.url);
  if( nErr && go==2 ){
    db_multi_exec("DROP TABLE onremote");
    manifest_crosslink_end(MC_PERMIT_HOOKS);
    content_enable_dephantomize(1);
    db_end_transaction(0);
  }
  if( (syncFlags & SYNC_CLONE)==0 && g.forkSeen ){
    fossil_warning("***** WARNING: a fork has occurred ***** use "
                   "\"fossil forks\" for more details.");
  }
  return nErr;
}







|





1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
  transport_global_shutdown(&g.url);
  if( nErr && go==2 ){
    db_multi_exec("DROP TABLE onremote");
    manifest_crosslink_end(MC_PERMIT_HOOKS);
    content_enable_dephantomize(1);
    db_end_transaction(0);
  }
  if( (syncFlags & SYNC_CLONE)==0 && fossil_find_any_fork(g.rcvid) ){
    fossil_warning("***** WARNING: a fork has occurred ***** use "
                   "\"fossil forks\" for more details.");
  }
  return nErr;
}