| ︙ | | | ︙ | |
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
** Insert an artifact into the BLOB table if it isn't there already.
** If zMark is not zero, create a cross-reference from that mark back
** to the newly inserted artifact.
**
** If saveUuid is true, then pContent is a commit record. Record its
** UUID in gg.zPrevCheckin.
*/
static int fast_insert_content(Blob *pContent, const char *zMark, int saveUuid){
Blob hash;
Blob cmpr;
int rid;
sha1sum_blob(pContent, &hash);
rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%B", &hash);
if( rid==0 ){
static Stmt ins;
db_static_prepare(&ins,
"INSERT INTO blob(uuid, size, content) VALUES(:uuid, :size, :content)"
);
db_bind_text(&ins, ":uuid", blob_str(&hash));
db_bind_int(&ins, ":size", gg.nData);
blob_compress(pContent, &cmpr);
db_bind_blob(&ins, ":content", &cmpr);
db_step(&ins);
db_reset(&ins);
blob_reset(&cmpr);
rid = db_last_insert_rowid();
}
if( zMark ){
db_multi_exec(
"INSERT OR IGNORE INTO xmark(tname, trid, tuuid)"
"VALUES(%Q,%d,%B)",
zMark, rid, &hash
);
|
|
>
>
>
>
>
>
>
>
|
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
** Insert an artifact into the BLOB table if it isn't there already.
** If zMark is not zero, create a cross-reference from that mark back
** to the newly inserted artifact.
**
** If saveUuid is true, then pContent is a commit record. Record its
** UUID in gg.zPrevCheckin.
*/
static int fast_insert_content(
Blob *pContent, /* Content to insert */
const char *zMark, /* Label using this mark, if not NULL */
int saveUuid, /* Save SHA1 hash in gg.zPrevCheckin */
int doParse /* Invoke manifest_crosslink() */
){
Blob hash;
Blob cmpr;
int rid;
sha1sum_blob(pContent, &hash);
rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%B", &hash);
if( rid==0 ){
static Stmt ins;
db_static_prepare(&ins,
"INSERT INTO blob(uuid, size, content) VALUES(:uuid, :size, :content)"
);
db_bind_text(&ins, ":uuid", blob_str(&hash));
db_bind_int(&ins, ":size", gg.nData);
blob_compress(pContent, &cmpr);
db_bind_blob(&ins, ":content", &cmpr);
db_step(&ins);
db_reset(&ins);
blob_reset(&cmpr);
rid = db_last_insert_rowid();
if( doParse ){
manifest_crosslink(rid, pContent, MC_NONE);
}
}
if( zMark ){
db_multi_exec(
"INSERT OR IGNORE INTO xmark(tname, trid, tuuid)"
"VALUES(%Q,%d,%B)",
zMark, rid, &hash
);
|
| ︙ | | | ︙ | |
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
/*
** Use data accumulated in gg from a "blob" record to add a new file
** to the BLOB table.
*/
static void finish_blob(void){
Blob content;
blob_init(&content, gg.aData, gg.nData);
fast_insert_content(&content, gg.zMark, 0);
blob_reset(&content);
import_reset(0);
}
/*
** Use data accumulated in gg from a "tag" record to add a new
** control artifact to the BLOB table.
*/
static void finish_tag(void){
Blob record, cksum;
if( gg.zDate && gg.zTag && gg.zFrom && gg.zUser ){
blob_zero(&record);
blob_appendf(&record, "D %s\n", gg.zDate);
blob_appendf(&record, "T +%F %s\n", gg.zTag, gg.zFrom);
blob_appendf(&record, "U %F\n", gg.zUser);
md5sum_blob(&record, &cksum);
blob_appendf(&record, "Z %b\n", &cksum);
fast_insert_content(&record, 0, 0);
blob_reset(&record);
blob_reset(&cksum);
}
import_reset(0);
}
/*
** Compare two ImportFile objects for sorting
|
|
|
<
|
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
/*
** Use data accumulated in gg from a "blob" record to add a new file
** to the BLOB table.
*/
static void finish_blob(void){
Blob content;
blob_init(&content, gg.aData, gg.nData);
fast_insert_content(&content, gg.zMark, 0, 0);
blob_reset(&content);
import_reset(0);
}
/*
** Use data accumulated in gg from a "tag" record to add a new
** control artifact to the BLOB table.
*/
static void finish_tag(void){
Blob record, cksum;
if( gg.zDate && gg.zTag && gg.zFrom && gg.zUser ){
blob_zero(&record);
blob_appendf(&record, "D %s\n", gg.zDate);
blob_appendf(&record, "T +%F %s\n", gg.zTag, gg.zFrom);
blob_appendf(&record, "U %F\n", gg.zUser);
md5sum_blob(&record, &cksum);
blob_appendf(&record, "Z %b\n", &cksum);
fast_insert_content(&record, 0, 0, 1);
blob_reset(&cksum);
}
import_reset(0);
}
/*
** Compare two ImportFile objects for sorting
|
| ︙ | | | ︙ | |
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
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;
if( zUuid==0 ) continue;
blob_appendf(&record, "F %F %s", gg.aFile[i].zName, zUuid);
if( gg.aFile[i].isExe ){
blob_append(&record, " x\n", 3);
}else if( gg.aFile[i].isLink ){
|
>
|
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
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);
if( !g.fQuiet ) fossil_print("%.10s\r", gg.zDate);
for(i=0; i<gg.nFile; i++){
const char *zUuid = gg.aFile[i].zUuid;
if( zUuid==0 ) continue;
blob_appendf(&record, "F %F %s", gg.aFile[i].zName, zUuid);
if( gg.aFile[i].isExe ){
blob_append(&record, " x\n", 3);
}else if( gg.aFile[i].isLink ){
|
| ︙ | | | ︙ | |
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
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);
blob_reset(&cksum);
/* The "git fast-export" command might output multiple "commit" lines
** that reference a tag using "refs/tags/TAGNAME". The tag should only
** be applied to the last commit that is output. The problem is we do not
** know at this time if the current commit is the last one to hold this
** tag or not. So make an entry in the XTAG table to record this tag
|
|
<
|
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
|
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, 1);
blob_reset(&cksum);
/* The "git fast-export" command might output multiple "commit" lines
** that reference a tag using "refs/tags/TAGNAME". The tag should only
** be applied to the last commit that is output. The problem is we do not
** know at this time if the current commit is the last one to hold this
** tag or not. So make an entry in the XTAG table to record this tag
|
| ︙ | | | ︙ | |
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
|
** --tags FOLDER Name of tags folder
** --base PATH Path to project root in repository
** --flat The whole dump is a single branch
**
** Common Options:
** -i|--incremental allow importing into an existing repository
** -f|--force overwrite repository if already exist
**
** The --incremental option allows an existing repository to be extended
** with new content.
**
**
** See also: export
*/
|
>
|
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
|
** --tags FOLDER Name of tags folder
** --base PATH Path to project root in repository
** --flat The whole dump is a single branch
**
** Common Options:
** -i|--incremental allow importing into an existing repository
** -f|--force overwrite repository if already exist
** -q|--quiet omit progress output
**
** The --incremental option allows an existing repository to be extended
** with new content.
**
**
** See also: export
*/
|
| ︙ | | | ︙ | |
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
|
*/
db_multi_exec(
"CREATE TEMP TABLE xmark(tname TEXT UNIQUE, trid INT, tuuid TEXT);"
"CREATE TEMP TABLE xbranch(tname TEXT UNIQUE, brnm TEXT);"
"CREATE TEMP TABLE xtag(tname TEXT UNIQUE, tcontent TEXT);"
);
git_fast_import(pIn);
db_prepare(&q, "SELECT tcontent FROM xtag");
while( db_step(&q)==SQLITE_ROW ){
Blob record;
db_ephemeral_blob(&q, 0, &record);
fast_insert_content(&record, 0, 0);
import_reset(0);
}
db_finalize(&q);
}
verify_cancel();
db_end_transaction(0);
db_begin_transaction();
fossil_print("Rebuilding repository meta-data...\n");
rebuild_db(0, 1, !incrFlag);
|
>
|
>
|
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
|
*/
db_multi_exec(
"CREATE TEMP TABLE xmark(tname TEXT UNIQUE, trid INT, tuuid TEXT);"
"CREATE TEMP TABLE xbranch(tname TEXT UNIQUE, brnm TEXT);"
"CREATE TEMP TABLE xtag(tname TEXT UNIQUE, tcontent TEXT);"
);
manifest_crosslink_begin();
git_fast_import(pIn);
db_prepare(&q, "SELECT tcontent FROM xtag");
while( db_step(&q)==SQLITE_ROW ){
Blob record;
db_ephemeral_blob(&q, 0, &record);
fast_insert_content(&record, 0, 0, 1);
import_reset(0);
}
db_finalize(&q);
manifest_crosslink_end(MC_NONE);
}
verify_cancel();
db_end_transaction(0);
db_begin_transaction();
fossil_print("Rebuilding repository meta-data...\n");
rebuild_db(0, 1, !incrFlag);
|
| ︙ | | | ︙ | |