| ︙ | | | ︙ | |
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
** merchantability or fitness for a particular purpose.
**
** Author contact information:
** drh@sqlite.org
**
*******************************************************************************
**
** This file contains code used to import the content of a Git
** repository in the git-fast-import format as a new Fossil
** repository.
*/
#include "config.h"
#include "import.h"
#include <assert.h>
#if INTERFACE
/*
** A single file change record.
*/
struct ImportFile {
char *zName; /* Name of a file */
char *zUuid; /* UUID of the file */
char *zPrior; /* Prior name if the name was changed */
char isFrom; /* True if obtained from the parent */
char isExe; /* True if executable */
char isLink; /* True if symlink */
};
|
|
|
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
** merchantability or fitness for a particular purpose.
**
** Author contact information:
** drh@sqlite.org
**
*******************************************************************************
**
** This file contains code used to import the content of a Git
** repository in the git-fast-import format as a new Fossil
** repository.
*/
#include "config.h"
#include "import.h"
#include <assert.h>
#if INTERFACE
/*
** A single file change record.
*/
struct ImportFile {
char *zName; /* Name of a file */
char *zUuid; /* UUID of the file */
char *zPrior; /* Prior name if the name was changed */
char isFrom; /* True if obtained from the parent */
char isExe; /* True if executable */
char isLink; /* True if symlink */
};
|
| ︙ | | | ︙ | |
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
return z;
}
/*
** A no-op "xFinish" method
*/
static void finish_noop(void){}
/*
** Deallocate the state information.
**
** The azMerge[] and aFile[] arrays are zeroed by allocated space is
** retained unless the freeAll flag is set.
*/
static void import_reset(int freeAll){
|
|
|
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
return z;
}
/*
** A no-op "xFinish" method
*/
static void finish_noop(void){}
/*
** Deallocate the state information.
**
** The azMerge[] and aFile[] arrays are zeroed by allocated space is
** retained unless the freeAll flag is set.
*/
static void import_reset(int freeAll){
|
| ︙ | | | ︙ | |
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
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
);
db_multi_exec(
"INSERT OR IGNORE INTO xmark(tname, trid, tuuid)"
"VALUES(%B,%d,%B)",
&hash, rid, &hash
);
}
if( saveUuid ){
fossil_free(gg.zPrevCheckin);
gg.zPrevCheckin = fossil_strdup(blob_str(&hash));
}
|
|
|
|
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
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
);
db_multi_exec(
"INSERT OR IGNORE INTO xmark(tname, trid, tuuid)"
"VALUES(%B,%d,%B)",
&hash, rid, &hash
);
}
if( saveUuid ){
fossil_free(gg.zPrevCheckin);
gg.zPrevCheckin = fossil_strdup(blob_str(&hash));
}
|
| ︙ | | | ︙ | |
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
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);
|
|
|
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
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);
|
| ︙ | | | ︙ | |
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
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[] */
|
|
|
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
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[] */
|
| ︙ | | | ︙ | |
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
|
static void import_prior_files(void){
Manifest *p;
int rid;
ManifestFile *pOld;
ImportFile *pNew;
if( gg.fromLoaded ) return;
gg.fromLoaded = 1;
if( gg.zFrom==0 && gg.zPrevCheckin!=0
&& fossil_strcmp(gg.zBranch, gg.zPrevBranch)==0
){
gg.zFrom = gg.zPrevCheckin;
gg.zPrevCheckin = 0;
}
if( gg.zFrom==0 ) return;
rid = fast_uuid_to_rid(gg.zFrom);
|
|
|
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
|
static void import_prior_files(void){
Manifest *p;
int rid;
ManifestFile *pOld;
ImportFile *pNew;
if( gg.fromLoaded ) return;
gg.fromLoaded = 1;
if( gg.zFrom==0 && gg.zPrevCheckin!=0
&& fossil_strcmp(gg.zBranch, gg.zPrevBranch)==0
){
gg.zFrom = gg.zPrevCheckin;
gg.zPrevCheckin = 0;
}
if( gg.zFrom==0 ) return;
rid = fast_uuid_to_rid(gg.zFrom);
|
| ︙ | | | ︙ | |
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
|
return 0;
}
/*
** Dequote a fast-export filename. Filenames are normally unquoted. But
** if the contain some obscure special characters, quotes might be added.
*/
static dequote_git_filename(char *zName){
int n, i, j;
if( zName==0 || zName[0]!='"' ) return;
n = (int)strlen(zName);
if( zName[n-1]!='"' ) return;
for(i=0, j=1; j<n-1; j++){
char c = zName[j];
if( c=='\\' ) c = zName[++j];
|
|
|
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
|
return 0;
}
/*
** Dequote a fast-export filename. Filenames are normally unquoted. But
** if the contain some obscure special characters, quotes might be added.
*/
static void dequote_git_filename(char *zName){
int n, i, j;
if( zName==0 || zName[0]!='"' ) return;
n = (int)strlen(zName);
if( zName[n-1]!='"' ) return;
for(i=0, j=1; j<n-1; j++){
char c = zName[j];
if( c=='\\' ) c = zName[++j];
|
| ︙ | | | ︙ | |
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
|
i = 0;
pFile = import_find_file(zName, &i, gg.nFile);
if( pFile==0 ){
pFile = import_add_file();
pFile->zName = fossil_strdup(zName);
}
pFile->isExe = (fossil_strcmp(zPerm, "100755")==0);
pFile->isLink = (fossil_strcmp(zPerm, "120000")==0);
fossil_free(pFile->zUuid);
pFile->zUuid = resolve_committish(zUuid);
pFile->isFrom = 0;
}else
if( memcmp(zLine, "D ", 2)==0 ){
import_prior_files();
z = &zLine[2];
|
|
|
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
|
i = 0;
pFile = import_find_file(zName, &i, gg.nFile);
if( pFile==0 ){
pFile = import_add_file();
pFile->zName = fossil_strdup(zName);
}
pFile->isExe = (fossil_strcmp(zPerm, "100755")==0);
pFile->isLink = (fossil_strcmp(zPerm, "120000")==0);
fossil_free(pFile->zUuid);
pFile->zUuid = resolve_committish(zUuid);
pFile->isFrom = 0;
}else
if( memcmp(zLine, "D ", 2)==0 ){
import_prior_files();
z = &zLine[2];
|
| ︙ | | | ︙ | |
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
|
db_open_repository(g.argv[2]);
db_open_config(0);
/* The following temp-tables are used to hold information needed for
** the import.
**
** The XMARK table provides a mapping from fast-import "marks" and symbols
** into artifact ids (UUIDs - the 40-byte hex SHA1 hash of artifacts).
** Given any valid fast-import symbol, the corresponding fossil rid and
** uuid can found by searching against the xmark.tname field.
**
** The XBRANCH table maps commit marks and symbols into the branch those
** commits belong to. If xbranch.tname is a fast-import symbol for a
** checkin then xbranch.brnm is the branch that checkin is part of.
**
|
|
|
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
|
db_open_repository(g.argv[2]);
db_open_config(0);
/* The following temp-tables are used to hold information needed for
** the import.
**
** The XMARK table provides a mapping from fast-import "marks" and symbols
** into artifact ids (UUIDs - the 40-byte hex SHA1 hash of artifacts).
** Given any valid fast-import symbol, the corresponding fossil rid and
** uuid can found by searching against the xmark.tname field.
**
** The XBRANCH table maps commit marks and symbols into the branch those
** commits belong to. If xbranch.tname is a fast-import symbol for a
** checkin then xbranch.brnm is the branch that checkin is part of.
**
|
| ︙ | | | ︙ | |