205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
** Compare two ImportFile objects for sorting
*/
static int mfile_cmp(const void *pLeft, const void *pRight){
const ImportFile *pA = (const ImportFile*)pLeft;
const ImportFile *pB = (const ImportFile*)pRight;
return fossil_strcmp(pA->zName, pB->zName);
}
/* Forward reference */
static void import_prior_files(void);
/*
** Use data accumulated in gg from a "commit" record to add a new
** manifest artifact to the BLOB table.
*/
static void finish_commit(void){
int i;
char *zFromBranch;
Blob record, cksum;
import_prior_files();
qsort(gg.aFile, gg.nFile, sizeof(gg.aFile[0]), mfile_cmp);
blob_zero(&record);
blob_appendf(&record, "C %F\n", gg.zComment);
blob_appendf(&record, "D %s\n", gg.zDate);
for(i=0; i<gg.nFile; i++){
const char *zUuid = gg.aFile[i].zUuid;
|
>
>
>
>
>
>
>
>
>
>
>
>
|
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
** Compare two ImportFile objects for sorting
*/
static int mfile_cmp(const void *pLeft, const void *pRight){
const ImportFile *pA = (const ImportFile*)pLeft;
const ImportFile *pB = (const ImportFile*)pRight;
return fossil_strcmp(pA->zName, pB->zName);
}
/*
** Compare two strings for sorting.
*/
static int string_cmp(const void *pLeft, const void *pRight){
const char *zLeft = *(char const **)pLeft;
const char *zRight = *(char const **)pRight;
return fossil_strcmp(zLeft, zRight);
}
/* Forward reference */
static void import_prior_files(void);
/*
** Use data accumulated in gg from a "commit" record to add a new
** manifest artifact to the BLOB table.
*/
static void finish_commit(void){
int i;
char *zFromBranch;
char *aTCard[4]; /* Array of T cards for manifest */
int nTCard = 0; /* Entries used in aTCard[] */
Blob record, cksum;
import_prior_files();
qsort(gg.aFile, gg.nFile, sizeof(gg.aFile[0]), mfile_cmp);
blob_zero(&record);
blob_appendf(&record, "C %F\n", gg.zComment);
blob_appendf(&record, "D %s\n", gg.zDate);
for(i=0; i<gg.nFile; i++){
const char *zUuid = gg.aFile[i].zUuid;
|
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
|
}
blob_append(&record, "\n", 1);
zFromBranch = db_text(0, "SELECT brnm FROM xbranch WHERE tname=%Q",
gg.zFromMark);
}else{
zFromBranch = 0;
}
if( !gg.tagCommit && fossil_strcmp(zFromBranch, gg.zBranch)!=0 ){
blob_appendf(&record, "T *branch * %F\n", gg.zBranch);
blob_appendf(&record, "T *sym-%F *\n", gg.zBranch);
if( zFromBranch ){
blob_appendf(&record, "T -sym-%F *\n", zFromBranch);
}
}
free(zFromBranch);
if( gg.zFrom==0 ){
blob_appendf(&record, "T *sym-trunk *\n");
}
db_multi_exec("INSERT INTO xbranch(tname, brnm) VALUES(%Q,%Q)",
gg.zMark, gg.zBranch);
blob_appendf(&record, "U %F\n", gg.zUser);
md5sum_blob(&record, &cksum);
blob_appendf(&record, "Z %b\n", &cksum);
fast_insert_content(&record, gg.zMark, 1);
blob_reset(&record);
|
>
>
>
>
|
|
|
<
>
>
>
>
>
|
|
>
>
>
>
|
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
|
}
blob_append(&record, "\n", 1);
zFromBranch = db_text(0, "SELECT brnm FROM xbranch WHERE tname=%Q",
gg.zFromMark);
}else{
zFromBranch = 0;
}
/* Add the required "T" cards to the manifest. Make sure they are added
** in sorted order and without any duplicates. Otherwise, fossil will not
** recognize the document as a valid manifest. */
if( !gg.tagCommit && fossil_strcmp(zFromBranch, gg.zBranch)!=0 ){
aTCard[nTCard++] = mprintf("T *branch * %F\n", gg.zBranch);
aTCard[nTCard++] = mprintf("T *sym-%F *\n", gg.zBranch);
if( zFromBranch ){
aTCard[nTCard++] = mprintf("T -sym-%F *\n", zFromBranch);
}
}
if( gg.zFrom==0 ){
aTCard[nTCard++] = mprintf("T *sym-trunk *\n");
}
qsort(aTCard, nTCard, sizeof(char *), string_cmp);
for(i=0; i<nTCard; i++){
if( i==0 || fossil_strcmp(aTCard[i-1], aTCard[i]) ){
blob_appendf(&record, "%s", aTCard[i]);
}
}
for(i=0; i<nTCard; i++) free(aTCard[i]);
free(zFromBranch);
db_multi_exec("INSERT INTO xbranch(tname, brnm) VALUES(%Q,%Q)",
gg.zMark, gg.zBranch);
blob_appendf(&record, "U %F\n", gg.zUser);
md5sum_blob(&record, &cksum);
blob_appendf(&record, "Z %b\n", &cksum);
fast_insert_content(&record, gg.zMark, 1);
blob_reset(&record);
|