Fossil SCM
Use stable marks derived from the rid in preparation for optional incremental exports.
Commit
22d414e517b5846de1a0849f69f385ea015d3c6f
Parent
b71b32d131fe71f…
1 file changed
+11
-11
+11
-11
| --- src/export.c | ||
| +++ src/export.c | ||
| @@ -78,10 +78,12 @@ | ||
| 78 | 78 | free(zName); |
| 79 | 79 | free(zEmail); |
| 80 | 80 | db_reset(&q); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | +#define BLOBMARK(rid) ((rid) * 2) | |
| 84 | +#define COMMITMARK(rid) ((rid) * 2 + 1) | |
| 83 | 85 | |
| 84 | 86 | /* |
| 85 | 87 | ** COMMAND: export |
| 86 | 88 | ** |
| 87 | 89 | ** Usage: %fossil export --git ?REPOSITORY? |
| @@ -99,11 +101,10 @@ | ||
| 99 | 101 | ** or wiki or events or attachments, so none of those are exported. |
| 100 | 102 | */ |
| 101 | 103 | void export_cmd(void){ |
| 102 | 104 | Stmt q; |
| 103 | 105 | int i; |
| 104 | - int firstCkin; /* Integer offset to check-in marks */ | |
| 105 | 106 | Bag blobs, vers; |
| 106 | 107 | bag_init(&blobs); |
| 107 | 108 | bag_init(&vers); |
| 108 | 109 | |
| 109 | 110 | find_option("git", 0, 0); /* Ignore the --git option for now */ |
| @@ -118,21 +119,20 @@ | ||
| 118 | 119 | db_prepare(&q, "SELECT DISTINCT fid FROM mlink WHERE fid>0"); |
| 119 | 120 | while( db_step(&q)==SQLITE_ROW ){ |
| 120 | 121 | int rid = db_column_int(&q, 0); |
| 121 | 122 | Blob content; |
| 122 | 123 | content_get(rid, &content); |
| 123 | - printf("blob\nmark :%d\ndata %d\n", rid, blob_size(&content)); | |
| 124 | + printf("blob\nmark :%d\ndata %d\n", BLOBMARK(rid), blob_size(&content)); | |
| 124 | 125 | bag_insert(&blobs, rid); |
| 125 | 126 | fwrite(blob_buffer(&content), 1, blob_size(&content), stdout); |
| 126 | 127 | printf("\n"); |
| 127 | 128 | blob_reset(&content); |
| 128 | 129 | } |
| 129 | 130 | db_finalize(&q); |
| 130 | 131 | |
| 131 | 132 | /* Output the commit records. |
| 132 | 133 | */ |
| 133 | - firstCkin = db_int(0, "SELECT max(rid) FROM blob")+1; | |
| 134 | 134 | db_prepare(&q, |
| 135 | 135 | "SELECT strftime('%%s',mtime), objid, coalesce(comment,ecomment)," |
| 136 | 136 | " coalesce(user,euser)," |
| 137 | 137 | " (SELECT value FROM tagxref WHERE rid=objid AND tagid=%d)" |
| 138 | 138 | " FROM event" |
| @@ -153,11 +153,11 @@ | ||
| 153 | 153 | if( zBranch==0 ) zBranch = "trunk"; |
| 154 | 154 | zBr = mprintf("%s", zBranch); |
| 155 | 155 | for(i=0; zBr[i]; i++){ |
| 156 | 156 | if( !fossil_isalnum(zBr[i]) ) zBr[i] = '_'; |
| 157 | 157 | } |
| 158 | - printf("commit refs/heads/%s\nmark :%d\n", zBr, ckinId+firstCkin); | |
| 158 | + printf("commit refs/heads/%s\nmark :%d\n", zBr, COMMITMARK(ckinId)); | |
| 159 | 159 | free(zBr); |
| 160 | 160 | printf("committer"); |
| 161 | 161 | print_person(zUser); |
| 162 | 162 | printf(" %s +0000\n", zSecondsSince1970); |
| 163 | 163 | if( zComment==0 ) zComment = "null comment"; |
| @@ -171,11 +171,11 @@ | ||
| 171 | 171 | zFromType = "from"; |
| 172 | 172 | p = manifest_get(ckinId, CFTYPE_ANY); |
| 173 | 173 | for(i=0; i<p->nParent; i++){ |
| 174 | 174 | int pid = fast_uuid_to_rid(p->azParent[i]); |
| 175 | 175 | if( pid==0 || !bag_find(&vers, pid) ) continue; |
| 176 | - printf("%s :%d\n", zFromType, fast_uuid_to_rid(p->azParent[i])+firstCkin); | |
| 176 | + printf("%s :%d\n", zFromType, COMMITMARK(fast_uuid_to_rid(p->azParent[i]))); | |
| 177 | 177 | zFromType = "merge"; |
| 178 | 178 | } |
| 179 | 179 | printf("deleteall\n"); |
| 180 | 180 | manifest_file_rewind(p); |
| 181 | 181 | while( (pFile=manifest_file_next(p, 0))!=0 ){ |
| @@ -182,27 +182,27 @@ | ||
| 182 | 182 | int fid = fast_uuid_to_rid(pFile->zUuid); |
| 183 | 183 | const char *zPerm = "100644"; |
| 184 | 184 | if( fid==0 ) continue; |
| 185 | 185 | if( pFile->zPerm && strstr(pFile->zPerm,"x") ) zPerm = "100755"; |
| 186 | 186 | if( !bag_find(&blobs, fid) ) continue; |
| 187 | - printf("M %s :%d %s\n", zPerm, fid, pFile->zName); | |
| 187 | + printf("M %s :%d %s\n", zPerm, BLOBMARK(fid), pFile->zName); | |
| 188 | 188 | } |
| 189 | 189 | manifest_cache_insert(p); |
| 190 | 190 | }else{ |
| 191 | 191 | Stmt q3; |
| 192 | 192 | int parent; |
| 193 | 193 | |
| 194 | 194 | parent = db_column_int(&q2, 0); |
| 195 | - printf("from :%d\n", parent+firstCkin); | |
| 195 | + printf("from :%d\n", COMMITMARK(parent)); | |
| 196 | 196 | db_prepare(&q3, |
| 197 | 197 | "SELECT pid FROM plink" |
| 198 | 198 | " WHERE cid=%d AND NOT isprim" |
| 199 | 199 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)" |
| 200 | 200 | " ORDER BY pid", |
| 201 | 201 | ckinId); |
| 202 | 202 | while( db_step(&q3)==SQLITE_ROW ){ |
| 203 | - printf("merge :%d\n", db_column_int(&q3,0)+firstCkin); | |
| 203 | + printf("merge :%d\n", COMMITMARK(db_column_int(&q3,0))); | |
| 204 | 204 | } |
| 205 | 205 | db_finalize(&q3); |
| 206 | 206 | |
| 207 | 207 | db_prepare(&q3, |
| 208 | 208 | "SELECT filename.name, mlink.fid, mlink.mperm FROM mlink" |
| @@ -214,12 +214,12 @@ | ||
| 214 | 214 | const char *zName = db_column_text(&q3,0); |
| 215 | 215 | int zNew = db_column_int(&q3,1); |
| 216 | 216 | int mPerm = db_column_int(&q3,2); |
| 217 | 217 | if( zNew==0) |
| 218 | 218 | printf("D %s\n", zName); |
| 219 | - else | |
| 220 | - printf("M %s :%d %s\n", mPerm ? "100755" : "100644", zNew, zName); | |
| 219 | + else if( bag_find(&blobs, zNew) ) | |
| 220 | + printf("M %s :%d %s\n", mPerm ? "100755" : "100644", BLOBMARK(zNew), zName); | |
| 221 | 221 | } |
| 222 | 222 | db_finalize(&q3); |
| 223 | 223 | } |
| 224 | 224 | db_finalize(&q2); |
| 225 | 225 | printf("\n"); |
| @@ -246,13 +246,13 @@ | ||
| 246 | 246 | zEncoded = mprintf("%s", zTagname); |
| 247 | 247 | for(i=0; zEncoded[i]; i++){ |
| 248 | 248 | if( !fossil_isalnum(zEncoded[i]) ) zEncoded[i] = '_'; |
| 249 | 249 | } |
| 250 | 250 | printf("tag %s\n", zEncoded); |
| 251 | - printf("from :%d\n", rid+firstCkin); | |
| 251 | + printf("from :%d\n", COMMITMARK(rid)); | |
| 252 | 252 | printf("tagger <tagger> %s +0000\n", zSecSince1970); |
| 253 | 253 | printf("data 0\n"); |
| 254 | 254 | fossil_free(zEncoded); |
| 255 | 255 | } |
| 256 | 256 | db_finalize(&q); |
| 257 | 257 | bag_clear(&vers); |
| 258 | 258 | } |
| 259 | 259 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -78,10 +78,12 @@ | |
| 78 | free(zName); |
| 79 | free(zEmail); |
| 80 | db_reset(&q); |
| 81 | } |
| 82 | |
| 83 | |
| 84 | /* |
| 85 | ** COMMAND: export |
| 86 | ** |
| 87 | ** Usage: %fossil export --git ?REPOSITORY? |
| @@ -99,11 +101,10 @@ | |
| 99 | ** or wiki or events or attachments, so none of those are exported. |
| 100 | */ |
| 101 | void export_cmd(void){ |
| 102 | Stmt q; |
| 103 | int i; |
| 104 | int firstCkin; /* Integer offset to check-in marks */ |
| 105 | Bag blobs, vers; |
| 106 | bag_init(&blobs); |
| 107 | bag_init(&vers); |
| 108 | |
| 109 | find_option("git", 0, 0); /* Ignore the --git option for now */ |
| @@ -118,21 +119,20 @@ | |
| 118 | db_prepare(&q, "SELECT DISTINCT fid FROM mlink WHERE fid>0"); |
| 119 | while( db_step(&q)==SQLITE_ROW ){ |
| 120 | int rid = db_column_int(&q, 0); |
| 121 | Blob content; |
| 122 | content_get(rid, &content); |
| 123 | printf("blob\nmark :%d\ndata %d\n", rid, blob_size(&content)); |
| 124 | bag_insert(&blobs, rid); |
| 125 | fwrite(blob_buffer(&content), 1, blob_size(&content), stdout); |
| 126 | printf("\n"); |
| 127 | blob_reset(&content); |
| 128 | } |
| 129 | db_finalize(&q); |
| 130 | |
| 131 | /* Output the commit records. |
| 132 | */ |
| 133 | firstCkin = db_int(0, "SELECT max(rid) FROM blob")+1; |
| 134 | db_prepare(&q, |
| 135 | "SELECT strftime('%%s',mtime), objid, coalesce(comment,ecomment)," |
| 136 | " coalesce(user,euser)," |
| 137 | " (SELECT value FROM tagxref WHERE rid=objid AND tagid=%d)" |
| 138 | " FROM event" |
| @@ -153,11 +153,11 @@ | |
| 153 | if( zBranch==0 ) zBranch = "trunk"; |
| 154 | zBr = mprintf("%s", zBranch); |
| 155 | for(i=0; zBr[i]; i++){ |
| 156 | if( !fossil_isalnum(zBr[i]) ) zBr[i] = '_'; |
| 157 | } |
| 158 | printf("commit refs/heads/%s\nmark :%d\n", zBr, ckinId+firstCkin); |
| 159 | free(zBr); |
| 160 | printf("committer"); |
| 161 | print_person(zUser); |
| 162 | printf(" %s +0000\n", zSecondsSince1970); |
| 163 | if( zComment==0 ) zComment = "null comment"; |
| @@ -171,11 +171,11 @@ | |
| 171 | zFromType = "from"; |
| 172 | p = manifest_get(ckinId, CFTYPE_ANY); |
| 173 | for(i=0; i<p->nParent; i++){ |
| 174 | int pid = fast_uuid_to_rid(p->azParent[i]); |
| 175 | if( pid==0 || !bag_find(&vers, pid) ) continue; |
| 176 | printf("%s :%d\n", zFromType, fast_uuid_to_rid(p->azParent[i])+firstCkin); |
| 177 | zFromType = "merge"; |
| 178 | } |
| 179 | printf("deleteall\n"); |
| 180 | manifest_file_rewind(p); |
| 181 | while( (pFile=manifest_file_next(p, 0))!=0 ){ |
| @@ -182,27 +182,27 @@ | |
| 182 | int fid = fast_uuid_to_rid(pFile->zUuid); |
| 183 | const char *zPerm = "100644"; |
| 184 | if( fid==0 ) continue; |
| 185 | if( pFile->zPerm && strstr(pFile->zPerm,"x") ) zPerm = "100755"; |
| 186 | if( !bag_find(&blobs, fid) ) continue; |
| 187 | printf("M %s :%d %s\n", zPerm, fid, pFile->zName); |
| 188 | } |
| 189 | manifest_cache_insert(p); |
| 190 | }else{ |
| 191 | Stmt q3; |
| 192 | int parent; |
| 193 | |
| 194 | parent = db_column_int(&q2, 0); |
| 195 | printf("from :%d\n", parent+firstCkin); |
| 196 | db_prepare(&q3, |
| 197 | "SELECT pid FROM plink" |
| 198 | " WHERE cid=%d AND NOT isprim" |
| 199 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)" |
| 200 | " ORDER BY pid", |
| 201 | ckinId); |
| 202 | while( db_step(&q3)==SQLITE_ROW ){ |
| 203 | printf("merge :%d\n", db_column_int(&q3,0)+firstCkin); |
| 204 | } |
| 205 | db_finalize(&q3); |
| 206 | |
| 207 | db_prepare(&q3, |
| 208 | "SELECT filename.name, mlink.fid, mlink.mperm FROM mlink" |
| @@ -214,12 +214,12 @@ | |
| 214 | const char *zName = db_column_text(&q3,0); |
| 215 | int zNew = db_column_int(&q3,1); |
| 216 | int mPerm = db_column_int(&q3,2); |
| 217 | if( zNew==0) |
| 218 | printf("D %s\n", zName); |
| 219 | else |
| 220 | printf("M %s :%d %s\n", mPerm ? "100755" : "100644", zNew, zName); |
| 221 | } |
| 222 | db_finalize(&q3); |
| 223 | } |
| 224 | db_finalize(&q2); |
| 225 | printf("\n"); |
| @@ -246,13 +246,13 @@ | |
| 246 | zEncoded = mprintf("%s", zTagname); |
| 247 | for(i=0; zEncoded[i]; i++){ |
| 248 | if( !fossil_isalnum(zEncoded[i]) ) zEncoded[i] = '_'; |
| 249 | } |
| 250 | printf("tag %s\n", zEncoded); |
| 251 | printf("from :%d\n", rid+firstCkin); |
| 252 | printf("tagger <tagger> %s +0000\n", zSecSince1970); |
| 253 | printf("data 0\n"); |
| 254 | fossil_free(zEncoded); |
| 255 | } |
| 256 | db_finalize(&q); |
| 257 | bag_clear(&vers); |
| 258 | } |
| 259 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -78,10 +78,12 @@ | |
| 78 | free(zName); |
| 79 | free(zEmail); |
| 80 | db_reset(&q); |
| 81 | } |
| 82 | |
| 83 | #define BLOBMARK(rid) ((rid) * 2) |
| 84 | #define COMMITMARK(rid) ((rid) * 2 + 1) |
| 85 | |
| 86 | /* |
| 87 | ** COMMAND: export |
| 88 | ** |
| 89 | ** Usage: %fossil export --git ?REPOSITORY? |
| @@ -99,11 +101,10 @@ | |
| 101 | ** or wiki or events or attachments, so none of those are exported. |
| 102 | */ |
| 103 | void export_cmd(void){ |
| 104 | Stmt q; |
| 105 | int i; |
| 106 | Bag blobs, vers; |
| 107 | bag_init(&blobs); |
| 108 | bag_init(&vers); |
| 109 | |
| 110 | find_option("git", 0, 0); /* Ignore the --git option for now */ |
| @@ -118,21 +119,20 @@ | |
| 119 | db_prepare(&q, "SELECT DISTINCT fid FROM mlink WHERE fid>0"); |
| 120 | while( db_step(&q)==SQLITE_ROW ){ |
| 121 | int rid = db_column_int(&q, 0); |
| 122 | Blob content; |
| 123 | content_get(rid, &content); |
| 124 | printf("blob\nmark :%d\ndata %d\n", BLOBMARK(rid), blob_size(&content)); |
| 125 | bag_insert(&blobs, rid); |
| 126 | fwrite(blob_buffer(&content), 1, blob_size(&content), stdout); |
| 127 | printf("\n"); |
| 128 | blob_reset(&content); |
| 129 | } |
| 130 | db_finalize(&q); |
| 131 | |
| 132 | /* Output the commit records. |
| 133 | */ |
| 134 | db_prepare(&q, |
| 135 | "SELECT strftime('%%s',mtime), objid, coalesce(comment,ecomment)," |
| 136 | " coalesce(user,euser)," |
| 137 | " (SELECT value FROM tagxref WHERE rid=objid AND tagid=%d)" |
| 138 | " FROM event" |
| @@ -153,11 +153,11 @@ | |
| 153 | if( zBranch==0 ) zBranch = "trunk"; |
| 154 | zBr = mprintf("%s", zBranch); |
| 155 | for(i=0; zBr[i]; i++){ |
| 156 | if( !fossil_isalnum(zBr[i]) ) zBr[i] = '_'; |
| 157 | } |
| 158 | printf("commit refs/heads/%s\nmark :%d\n", zBr, COMMITMARK(ckinId)); |
| 159 | free(zBr); |
| 160 | printf("committer"); |
| 161 | print_person(zUser); |
| 162 | printf(" %s +0000\n", zSecondsSince1970); |
| 163 | if( zComment==0 ) zComment = "null comment"; |
| @@ -171,11 +171,11 @@ | |
| 171 | zFromType = "from"; |
| 172 | p = manifest_get(ckinId, CFTYPE_ANY); |
| 173 | for(i=0; i<p->nParent; i++){ |
| 174 | int pid = fast_uuid_to_rid(p->azParent[i]); |
| 175 | if( pid==0 || !bag_find(&vers, pid) ) continue; |
| 176 | printf("%s :%d\n", zFromType, COMMITMARK(fast_uuid_to_rid(p->azParent[i]))); |
| 177 | zFromType = "merge"; |
| 178 | } |
| 179 | printf("deleteall\n"); |
| 180 | manifest_file_rewind(p); |
| 181 | while( (pFile=manifest_file_next(p, 0))!=0 ){ |
| @@ -182,27 +182,27 @@ | |
| 182 | int fid = fast_uuid_to_rid(pFile->zUuid); |
| 183 | const char *zPerm = "100644"; |
| 184 | if( fid==0 ) continue; |
| 185 | if( pFile->zPerm && strstr(pFile->zPerm,"x") ) zPerm = "100755"; |
| 186 | if( !bag_find(&blobs, fid) ) continue; |
| 187 | printf("M %s :%d %s\n", zPerm, BLOBMARK(fid), pFile->zName); |
| 188 | } |
| 189 | manifest_cache_insert(p); |
| 190 | }else{ |
| 191 | Stmt q3; |
| 192 | int parent; |
| 193 | |
| 194 | parent = db_column_int(&q2, 0); |
| 195 | printf("from :%d\n", COMMITMARK(parent)); |
| 196 | db_prepare(&q3, |
| 197 | "SELECT pid FROM plink" |
| 198 | " WHERE cid=%d AND NOT isprim" |
| 199 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)" |
| 200 | " ORDER BY pid", |
| 201 | ckinId); |
| 202 | while( db_step(&q3)==SQLITE_ROW ){ |
| 203 | printf("merge :%d\n", COMMITMARK(db_column_int(&q3,0))); |
| 204 | } |
| 205 | db_finalize(&q3); |
| 206 | |
| 207 | db_prepare(&q3, |
| 208 | "SELECT filename.name, mlink.fid, mlink.mperm FROM mlink" |
| @@ -214,12 +214,12 @@ | |
| 214 | const char *zName = db_column_text(&q3,0); |
| 215 | int zNew = db_column_int(&q3,1); |
| 216 | int mPerm = db_column_int(&q3,2); |
| 217 | if( zNew==0) |
| 218 | printf("D %s\n", zName); |
| 219 | else if( bag_find(&blobs, zNew) ) |
| 220 | printf("M %s :%d %s\n", mPerm ? "100755" : "100644", BLOBMARK(zNew), zName); |
| 221 | } |
| 222 | db_finalize(&q3); |
| 223 | } |
| 224 | db_finalize(&q2); |
| 225 | printf("\n"); |
| @@ -246,13 +246,13 @@ | |
| 246 | zEncoded = mprintf("%s", zTagname); |
| 247 | for(i=0; zEncoded[i]; i++){ |
| 248 | if( !fossil_isalnum(zEncoded[i]) ) zEncoded[i] = '_'; |
| 249 | } |
| 250 | printf("tag %s\n", zEncoded); |
| 251 | printf("from :%d\n", COMMITMARK(rid)); |
| 252 | printf("tagger <tagger> %s +0000\n", zSecSince1970); |
| 253 | printf("data 0\n"); |
| 254 | fossil_free(zEncoded); |
| 255 | } |
| 256 | db_finalize(&q); |
| 257 | bag_clear(&vers); |
| 258 | } |
| 259 |