Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Use stable marks derived from the rid in preparation for optional incremental exports. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
22d414e517b5846de1a0849f69f385ea |
| User & Date: | joerg 2011-07-21 17:37:07.190 |
Context
|
2011-07-21
| ||
| 19:20 | Add support for incremental exports check-in: c2ccd82522 user: joerg tags: trunk | |
| 17:37 | Use stable marks derived from the rid in preparation for optional incremental exports. check-in: 22d414e517 user: joerg tags: trunk | |
| 17:35 | Skip missing merge parents. Git doesn't like missing marks and there isn't anything to be done about them. check-in: b71b32d131 user: joerg tags: trunk | |
Changes
Changes to src/export.c.
| ︙ | ︙ | |||
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
zName[j] = 0;
printf(" %s %s", zName, zEmail);
free(zName);
free(zEmail);
db_reset(&q);
}
/*
** COMMAND: export
**
** Usage: %fossil export --git ?REPOSITORY?
**
** Write an export of all check-ins to standard output. The export is
| > > | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
zName[j] = 0;
printf(" %s %s", zName, zEmail);
free(zName);
free(zEmail);
db_reset(&q);
}
#define BLOBMARK(rid) ((rid) * 2)
#define COMMITMARK(rid) ((rid) * 2 + 1)
/*
** COMMAND: export
**
** Usage: %fossil export --git ?REPOSITORY?
**
** Write an export of all check-ins to standard output. The export is
|
| ︙ | ︙ | |||
97 98 99 100 101 102 103 |
**
** Only check-ins are exported using --git. Git does not support tickets
** or wiki or events or attachments, so none of those are exported.
*/
void export_cmd(void){
Stmt q;
int i;
| < | < | 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 135 136 137 138 139 140 |
**
** Only check-ins are exported using --git. Git does not support tickets
** or wiki or events or attachments, so none of those are exported.
*/
void export_cmd(void){
Stmt q;
int i;
Bag blobs, vers;
bag_init(&blobs);
bag_init(&vers);
find_option("git", 0, 0); /* Ignore the --git option for now */
db_find_and_open_repository(0, 2);
verify_all_options();
if( g.argc!=2 && g.argc!=3 ){ usage("--git ?REPOSITORY?"); }
/* Step 1: Generate "blob" records for every artifact that is part
** of a check-in
*/
fossil_binary_mode(stdout);
db_prepare(&q, "SELECT DISTINCT fid FROM mlink WHERE fid>0");
while( db_step(&q)==SQLITE_ROW ){
int rid = db_column_int(&q, 0);
Blob content;
content_get(rid, &content);
printf("blob\nmark :%d\ndata %d\n", BLOBMARK(rid), blob_size(&content));
bag_insert(&blobs, rid);
fwrite(blob_buffer(&content), 1, blob_size(&content), stdout);
printf("\n");
blob_reset(&content);
}
db_finalize(&q);
/* Output the commit records.
*/
db_prepare(&q,
"SELECT strftime('%%s',mtime), objid, coalesce(comment,ecomment),"
" coalesce(user,euser),"
" (SELECT value FROM tagxref WHERE rid=objid AND tagid=%d)"
" FROM event"
" WHERE type='ci'"
" ORDER BY mtime ASC",
|
| ︙ | ︙ | |||
151 152 153 154 155 156 157 |
bag_insert(&vers, ckinId);
if( zBranch==0 ) zBranch = "trunk";
zBr = mprintf("%s", zBranch);
for(i=0; zBr[i]; i++){
if( !fossil_isalnum(zBr[i]) ) zBr[i] = '_';
}
| | | | | | | | | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 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 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
bag_insert(&vers, ckinId);
if( zBranch==0 ) zBranch = "trunk";
zBr = mprintf("%s", zBranch);
for(i=0; zBr[i]; i++){
if( !fossil_isalnum(zBr[i]) ) zBr[i] = '_';
}
printf("commit refs/heads/%s\nmark :%d\n", zBr, COMMITMARK(ckinId));
free(zBr);
printf("committer");
print_person(zUser);
printf(" %s +0000\n", zSecondsSince1970);
if( zComment==0 ) zComment = "null comment";
printf("data %d\n%s\n", (int)strlen(zComment), zComment);
db_prepare(&q2, "SELECT pid FROM plink WHERE cid=%d AND isprim", ckinId);
if( db_step(&q2) != SQLITE_ROW ){
const char *zFromType;
Manifest *p;
ManifestFile *pFile;
zFromType = "from";
p = manifest_get(ckinId, CFTYPE_ANY);
for(i=0; i<p->nParent; i++){
int pid = fast_uuid_to_rid(p->azParent[i]);
if( pid==0 || !bag_find(&vers, pid) ) continue;
printf("%s :%d\n", zFromType, COMMITMARK(fast_uuid_to_rid(p->azParent[i])));
zFromType = "merge";
}
printf("deleteall\n");
manifest_file_rewind(p);
while( (pFile=manifest_file_next(p, 0))!=0 ){
int fid = fast_uuid_to_rid(pFile->zUuid);
const char *zPerm = "100644";
if( fid==0 ) continue;
if( pFile->zPerm && strstr(pFile->zPerm,"x") ) zPerm = "100755";
if( !bag_find(&blobs, fid) ) continue;
printf("M %s :%d %s\n", zPerm, BLOBMARK(fid), pFile->zName);
}
manifest_cache_insert(p);
}else{
Stmt q3;
int parent;
parent = db_column_int(&q2, 0);
printf("from :%d\n", COMMITMARK(parent));
db_prepare(&q3,
"SELECT pid FROM plink"
" WHERE cid=%d AND NOT isprim"
" AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)"
" ORDER BY pid",
ckinId);
while( db_step(&q3)==SQLITE_ROW ){
printf("merge :%d\n", COMMITMARK(db_column_int(&q3,0)));
}
db_finalize(&q3);
db_prepare(&q3,
"SELECT filename.name, mlink.fid, mlink.mperm FROM mlink"
" JOIN filename ON filename.fnid=mlink.fnid"
" WHERE mlink.mid=%d",
parent
);
while( db_step(&q3)==SQLITE_ROW ){
const char *zName = db_column_text(&q3,0);
int zNew = db_column_int(&q3,1);
int mPerm = db_column_int(&q3,2);
if( zNew==0)
printf("D %s\n", zName);
else if( bag_find(&blobs, zNew) )
printf("M %s :%d %s\n", mPerm ? "100755" : "100644", BLOBMARK(zNew), zName);
}
db_finalize(&q3);
}
db_finalize(&q2);
printf("\n");
}
db_finalize(&q);
|
| ︙ | ︙ | |||
244 245 246 247 248 249 250 |
if( rid==0 || !bag_find(&vers, rid) ) continue;
zTagname += 4;
zEncoded = mprintf("%s", zTagname);
for(i=0; zEncoded[i]; i++){
if( !fossil_isalnum(zEncoded[i]) ) zEncoded[i] = '_';
}
printf("tag %s\n", zEncoded);
| | | 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
if( rid==0 || !bag_find(&vers, rid) ) continue;
zTagname += 4;
zEncoded = mprintf("%s", zTagname);
for(i=0; zEncoded[i]; i++){
if( !fossil_isalnum(zEncoded[i]) ) zEncoded[i] = '_';
}
printf("tag %s\n", zEncoded);
printf("from :%d\n", COMMITMARK(rid));
printf("tagger <tagger> %s +0000\n", zSecSince1970);
printf("data 0\n");
fossil_free(zEncoded);
}
db_finalize(&q);
bag_clear(&vers);
}
|