Fossil SCM

For the git-fast-export interchange format, make sure labels for blobs and labels for check-ins do not collide since git cannot deal with that. Ticket [536c3399075d06]

drh 2010-12-18 23:59 trunk
Commit d45502b066b03052682e723d0e03e0bf12960483
1 file changed +5 -3
+5 -3
--- src/export.c
+++ src/export.c
@@ -99,10 +99,11 @@
9999
** or wiki or events or attachments, so none of those are exported.
100100
*/
101101
void export_cmd(void){
102102
Stmt q;
103103
int i;
104
+ int firstCkin; /* Integer offset to check-in marks */
104105
Bag blobs, vers;
105106
bag_init(&blobs);
106107
bag_init(&vers);
107108
108109
find_option("git", 0, 0); /* Ignore the --git option for now */
@@ -127,10 +128,11 @@
127128
}
128129
db_finalize(&q);
129130
130131
/* Output the commit records.
131132
*/
133
+ firstCkin = db_int(0, "SELECT max(rid) FROM blob")+1;
132134
db_prepare(&q,
133135
"SELECT strftime('%%s',mtime), objid, coalesce(comment,ecomment),"
134136
" coalesce(user,euser),"
135137
" (SELECT value FROM tagxref WHERE rid=objid AND tagid=%d)"
136138
" FROM event"
@@ -153,11 +155,11 @@
153155
if( zBranch==0 ) zBranch = "trunk";
154156
zBr = mprintf("%s", zBranch);
155157
for(i=0; zBr[i]; i++){
156158
if( !fossil_isalnum(zBr[i]) ) zBr[i] = '_';
157159
}
158
- printf("commit refs/heads/%s\nmark :%d\n", zBr, ckinId);
160
+ printf("commit refs/heads/%s\nmark :%d\n", zBr, ckinId+firstCkin);
159161
free(zBr);
160162
printf("committer");
161163
print_person(zUser);
162164
printf(" %lld +0000\n", secondsSince1970);
163165
if( zComment==0 ) zComment = "null comment";
@@ -165,11 +167,11 @@
165167
p = manifest_get(ckinId, CFTYPE_ANY);
166168
zFromType = "from";
167169
for(i=0; i<p->nParent; i++){
168170
int pid = fast_uuid_to_rid(p->azParent[i]);
169171
if( pid==0 || !bag_find(&vers, pid) ) continue;
170
- printf("%s :%d\n", zFromType, fast_uuid_to_rid(p->azParent[i]));
172
+ printf("%s :%d\n", zFromType, fast_uuid_to_rid(p->azParent[i])+firstCkin);
171173
zFromType = "merge";
172174
}
173175
printf("deleteall\n");
174176
manifest_file_rewind(p);
175177
while( (pFile=manifest_file_next(p, 0))!=0 ){
@@ -198,12 +200,12 @@
198200
int rid = db_column_int(&q, 1);
199201
sqlite3_int64 secSince1970 = db_column_int64(&q, 2);
200202
if( rid==0 || !bag_find(&vers, rid) ) continue;
201203
zTagname += 4;
202204
printf("tag %s\n", zTagname);
203
- printf("from :%d\n", rid);
205
+ printf("from :%d\n", rid+firstCkin);
204206
printf("tagger <tagger> %lld +0000\n", secSince1970);
205207
printf("data 0\n");
206208
}
207209
db_finalize(&q);
208210
bag_clear(&vers);
209211
}
210212
--- src/export.c
+++ src/export.c
@@ -99,10 +99,11 @@
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 Bag blobs, vers;
105 bag_init(&blobs);
106 bag_init(&vers);
107
108 find_option("git", 0, 0); /* Ignore the --git option for now */
@@ -127,10 +128,11 @@
127 }
128 db_finalize(&q);
129
130 /* Output the commit records.
131 */
 
132 db_prepare(&q,
133 "SELECT strftime('%%s',mtime), objid, coalesce(comment,ecomment),"
134 " coalesce(user,euser),"
135 " (SELECT value FROM tagxref WHERE rid=objid AND tagid=%d)"
136 " FROM event"
@@ -153,11 +155,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);
159 free(zBr);
160 printf("committer");
161 print_person(zUser);
162 printf(" %lld +0000\n", secondsSince1970);
163 if( zComment==0 ) zComment = "null comment";
@@ -165,11 +167,11 @@
165 p = manifest_get(ckinId, CFTYPE_ANY);
166 zFromType = "from";
167 for(i=0; i<p->nParent; i++){
168 int pid = fast_uuid_to_rid(p->azParent[i]);
169 if( pid==0 || !bag_find(&vers, pid) ) continue;
170 printf("%s :%d\n", zFromType, fast_uuid_to_rid(p->azParent[i]));
171 zFromType = "merge";
172 }
173 printf("deleteall\n");
174 manifest_file_rewind(p);
175 while( (pFile=manifest_file_next(p, 0))!=0 ){
@@ -198,12 +200,12 @@
198 int rid = db_column_int(&q, 1);
199 sqlite3_int64 secSince1970 = db_column_int64(&q, 2);
200 if( rid==0 || !bag_find(&vers, rid) ) continue;
201 zTagname += 4;
202 printf("tag %s\n", zTagname);
203 printf("from :%d\n", rid);
204 printf("tagger <tagger> %lld +0000\n", secSince1970);
205 printf("data 0\n");
206 }
207 db_finalize(&q);
208 bag_clear(&vers);
209 }
210
--- src/export.c
+++ src/export.c
@@ -99,10 +99,11 @@
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 */
@@ -127,10 +128,11 @@
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 +155,11 @@
155 if( zBranch==0 ) zBranch = "trunk";
156 zBr = mprintf("%s", zBranch);
157 for(i=0; zBr[i]; i++){
158 if( !fossil_isalnum(zBr[i]) ) zBr[i] = '_';
159 }
160 printf("commit refs/heads/%s\nmark :%d\n", zBr, ckinId+firstCkin);
161 free(zBr);
162 printf("committer");
163 print_person(zUser);
164 printf(" %lld +0000\n", secondsSince1970);
165 if( zComment==0 ) zComment = "null comment";
@@ -165,11 +167,11 @@
167 p = manifest_get(ckinId, CFTYPE_ANY);
168 zFromType = "from";
169 for(i=0; i<p->nParent; i++){
170 int pid = fast_uuid_to_rid(p->azParent[i]);
171 if( pid==0 || !bag_find(&vers, pid) ) continue;
172 printf("%s :%d\n", zFromType, fast_uuid_to_rid(p->azParent[i])+firstCkin);
173 zFromType = "merge";
174 }
175 printf("deleteall\n");
176 manifest_file_rewind(p);
177 while( (pFile=manifest_file_next(p, 0))!=0 ){
@@ -198,12 +200,12 @@
200 int rid = db_column_int(&q, 1);
201 sqlite3_int64 secSince1970 = db_column_int64(&q, 2);
202 if( rid==0 || !bag_find(&vers, rid) ) continue;
203 zTagname += 4;
204 printf("tag %s\n", zTagname);
205 printf("from :%d\n", rid+firstCkin);
206 printf("tagger <tagger> %lld +0000\n", secSince1970);
207 printf("data 0\n");
208 }
209 db_finalize(&q);
210 bag_clear(&vers);
211 }
212

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button