Fossil SCM

Add the sym-trunk and newbranch tags to the root check-in when rebuilding. Also add the newbranch tag to the root check-in when creating a new repository.

drh 2009-01-21 02:47 trunk
Commit 7c7edde1169340698ada867fcd31df6b11ad4d55
+1
--- src/db.c
+++ src/db.c
@@ -940,10 +940,11 @@
940940
blob_appendf(&manifest, "D %s\n", zDate);
941941
blob_appendf(&manifest, "P\n");
942942
md5sum_init();
943943
blob_appendf(&manifest, "R %s\n", md5sum_finish(0));
944944
blob_appendf(&manifest, "T *sym-trunk *\n");
945
+ blob_appendf(&manifest, "T +newbranch *\n");
945946
blob_appendf(&manifest, "U %F\n", g.zLogin);
946947
md5sum_blob(&manifest, &hash);
947948
blob_appendf(&manifest, "Z %b\n", &hash);
948949
blob_reset(&hash);
949950
content_put(&manifest, 0, 0);
950951
--- src/db.c
+++ src/db.c
@@ -940,10 +940,11 @@
940 blob_appendf(&manifest, "D %s\n", zDate);
941 blob_appendf(&manifest, "P\n");
942 md5sum_init();
943 blob_appendf(&manifest, "R %s\n", md5sum_finish(0));
944 blob_appendf(&manifest, "T *sym-trunk *\n");
 
945 blob_appendf(&manifest, "U %F\n", g.zLogin);
946 md5sum_blob(&manifest, &hash);
947 blob_appendf(&manifest, "Z %b\n", &hash);
948 blob_reset(&hash);
949 content_put(&manifest, 0, 0);
950
--- src/db.c
+++ src/db.c
@@ -940,10 +940,11 @@
940 blob_appendf(&manifest, "D %s\n", zDate);
941 blob_appendf(&manifest, "P\n");
942 md5sum_init();
943 blob_appendf(&manifest, "R %s\n", md5sum_finish(0));
944 blob_appendf(&manifest, "T *sym-trunk *\n");
945 blob_appendf(&manifest, "T +newbranch *\n");
946 blob_appendf(&manifest, "U %F\n", g.zLogin);
947 md5sum_blob(&manifest, &hash);
948 blob_appendf(&manifest, "Z %b\n", &hash);
949 blob_reset(&hash);
950 content_put(&manifest, 0, 0);
951
--- src/rebuild.c
+++ src/rebuild.c
@@ -164,10 +164,42 @@
164164
}
165165
}
166166
bag_clear(&children);
167167
rebuild_step_done(rid);
168168
}
169
+
170
+/*
171
+** Check to see if the the "sym-trunk" tag exists. If not, create it
172
+** and attach it to the very first check-in.
173
+*/
174
+static void rebuild_tag_trunk(void){
175
+ int tagid = db_int(0, "SELECT 1 FROM tag WHERE tagname='sym-trunk'");
176
+ int rid;
177
+ char *zUuid;
178
+ Stmt q;
179
+
180
+ if( tagid>0 ) return;
181
+ rid = db_int(0, "SELECT pid FROM plink AS x WHERE NOT EXISTS("
182
+ " SELECT 1 FROM plink WHERE cid=x.pid)");
183
+ if( rid==0 ) return;
184
+ db_prepare(&q, "SELECT uuid FROM tagxref, blob"
185
+ " WHERE tagid=%d AND tagtype>0 AND blob.rid=tagxref.rid",
186
+ TAG_NEWBRANCH);
187
+
188
+ /* Block the trunk tag at all branches */
189
+ while( db_step(&q)==SQLITE_ROW ){
190
+ const char *z = db_column_text(&q, 0);
191
+ tag_add_artifact("sym-", "trunk", z, 0, 0);
192
+ }
193
+ db_finalize(&q);
194
+
195
+ /* Add the trunk tag to the root of the whole tree */
196
+ zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
197
+ if( zUuid==0 ) return;
198
+ tag_add_artifact("sym-", "trunk", zUuid, 0, 2);
199
+ tag_add_artifact("", "newbranch", zUuid, 0, 1);
200
+}
169201
170202
/*
171203
** Core function to rebuild the infomration in the derived tables of a
172204
** fossil repository from the blobs. This function is shared between
173205
** 'rebuild_database' ('rebuild') and 'reconstruct_cmd'
@@ -248,10 +280,11 @@
248280
db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid);
249281
rebuild_step_done(rid);
250282
}
251283
}
252284
db_finalize(&s);
285
+ rebuild_tag_trunk();
253286
if( ttyOutput ){
254287
printf("\n");
255288
}
256289
return errCnt;
257290
}
258291
--- src/rebuild.c
+++ src/rebuild.c
@@ -164,10 +164,42 @@
164 }
165 }
166 bag_clear(&children);
167 rebuild_step_done(rid);
168 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
170 /*
171 ** Core function to rebuild the infomration in the derived tables of a
172 ** fossil repository from the blobs. This function is shared between
173 ** 'rebuild_database' ('rebuild') and 'reconstruct_cmd'
@@ -248,10 +280,11 @@
248 db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid);
249 rebuild_step_done(rid);
250 }
251 }
252 db_finalize(&s);
 
253 if( ttyOutput ){
254 printf("\n");
255 }
256 return errCnt;
257 }
258
--- src/rebuild.c
+++ src/rebuild.c
@@ -164,10 +164,42 @@
164 }
165 }
166 bag_clear(&children);
167 rebuild_step_done(rid);
168 }
169
170 /*
171 ** Check to see if the the "sym-trunk" tag exists. If not, create it
172 ** and attach it to the very first check-in.
173 */
174 static void rebuild_tag_trunk(void){
175 int tagid = db_int(0, "SELECT 1 FROM tag WHERE tagname='sym-trunk'");
176 int rid;
177 char *zUuid;
178 Stmt q;
179
180 if( tagid>0 ) return;
181 rid = db_int(0, "SELECT pid FROM plink AS x WHERE NOT EXISTS("
182 " SELECT 1 FROM plink WHERE cid=x.pid)");
183 if( rid==0 ) return;
184 db_prepare(&q, "SELECT uuid FROM tagxref, blob"
185 " WHERE tagid=%d AND tagtype>0 AND blob.rid=tagxref.rid",
186 TAG_NEWBRANCH);
187
188 /* Block the trunk tag at all branches */
189 while( db_step(&q)==SQLITE_ROW ){
190 const char *z = db_column_text(&q, 0);
191 tag_add_artifact("sym-", "trunk", z, 0, 0);
192 }
193 db_finalize(&q);
194
195 /* Add the trunk tag to the root of the whole tree */
196 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
197 if( zUuid==0 ) return;
198 tag_add_artifact("sym-", "trunk", zUuid, 0, 2);
199 tag_add_artifact("", "newbranch", zUuid, 0, 1);
200 }
201
202 /*
203 ** Core function to rebuild the infomration in the derived tables of a
204 ** fossil repository from the blobs. This function is shared between
205 ** 'rebuild_database' ('rebuild') and 'reconstruct_cmd'
@@ -248,10 +280,11 @@
280 db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid);
281 rebuild_step_done(rid);
282 }
283 }
284 db_finalize(&s);
285 rebuild_tag_trunk();
286 if( ttyOutput ){
287 printf("\n");
288 }
289 return errCnt;
290 }
291
+5 -6
--- src/tag.c
+++ src/tag.c
@@ -246,11 +246,11 @@
246246
247247
/*
248248
** Add a control record to the repository that either creates
249249
** or cancels a tag.
250250
*/
251
-static void tag_add_artifact(
251
+void tag_add_artifact(
252252
const char *zPrefix, /* Prefix to prepend to tag name */
253253
const char *zTagname, /* The tag to add or cancel */
254254
const char *zObjName, /* Name of object attached to */
255255
const char *zValue, /* Value for the tag. Might be NULL */
256256
int tagtype /* 0:cancel 1:singleton 2:propagated */
@@ -293,17 +293,12 @@
293293
blob_appendf(&ctrl, "\n");
294294
}
295295
blob_appendf(&ctrl, "U %F\n", g.zLogin);
296296
md5sum_blob(&ctrl, &cksum);
297297
blob_appendf(&ctrl, "Z %b\n", &cksum);
298
- db_begin_transaction();
299298
nrid = content_put(&ctrl, 0, 0);
300299
manifest_crosslink(nrid, &ctrl);
301
- db_end_transaction(0);
302
-
303
- /* Do an autosync push if requested */
304
- autosync(AUTOSYNC_PUSH);
305300
}
306301
307302
/*
308303
** COMMAND: tag
309304
** Usage: %fossil tag SUBCOMMAND ...
@@ -370,11 +365,13 @@
370365
char *zValue;
371366
if( g.argc!=5 && g.argc!=6 ){
372367
usage("add ?--raw? ?--propagate? TAGNAME CHECK-IN ?VALUE?");
373368
}
374369
zValue = g.argc==6 ? g.argv[5] : 0;
370
+ db_begin_transaction();
375371
tag_add_artifact(zPrefix, g.argv[3], g.argv[4], zValue, 1+fPropagate);
372
+ db_end_transaction(0);
376373
}else
377374
378375
if( strncmp(g.argv[2],"branch",n)==0 ){
379376
fossil_fatal("the \"fossil tag branch\" command is discontinued\n"
380377
"Use the \"fossil branch new\" command instead.");
@@ -382,11 +379,13 @@
382379
383380
if( strncmp(g.argv[2],"cancel",n)==0 ){
384381
if( g.argc!=5 ){
385382
usage("cancel ?--raw? TAGNAME CHECK-IN");
386383
}
384
+ db_begin_transaction();
387385
tag_add_artifact(zPrefix, g.argv[3], g.argv[4], 0, 0);
386
+ db_end_transaction(0);
388387
}else
389388
390389
if( strncmp(g.argv[2],"find",n)==0 ){
391390
Stmt q;
392391
if( g.argc!=4 ){
393392
--- src/tag.c
+++ src/tag.c
@@ -246,11 +246,11 @@
246
247 /*
248 ** Add a control record to the repository that either creates
249 ** or cancels a tag.
250 */
251 static void tag_add_artifact(
252 const char *zPrefix, /* Prefix to prepend to tag name */
253 const char *zTagname, /* The tag to add or cancel */
254 const char *zObjName, /* Name of object attached to */
255 const char *zValue, /* Value for the tag. Might be NULL */
256 int tagtype /* 0:cancel 1:singleton 2:propagated */
@@ -293,17 +293,12 @@
293 blob_appendf(&ctrl, "\n");
294 }
295 blob_appendf(&ctrl, "U %F\n", g.zLogin);
296 md5sum_blob(&ctrl, &cksum);
297 blob_appendf(&ctrl, "Z %b\n", &cksum);
298 db_begin_transaction();
299 nrid = content_put(&ctrl, 0, 0);
300 manifest_crosslink(nrid, &ctrl);
301 db_end_transaction(0);
302
303 /* Do an autosync push if requested */
304 autosync(AUTOSYNC_PUSH);
305 }
306
307 /*
308 ** COMMAND: tag
309 ** Usage: %fossil tag SUBCOMMAND ...
@@ -370,11 +365,13 @@
370 char *zValue;
371 if( g.argc!=5 && g.argc!=6 ){
372 usage("add ?--raw? ?--propagate? TAGNAME CHECK-IN ?VALUE?");
373 }
374 zValue = g.argc==6 ? g.argv[5] : 0;
 
375 tag_add_artifact(zPrefix, g.argv[3], g.argv[4], zValue, 1+fPropagate);
 
376 }else
377
378 if( strncmp(g.argv[2],"branch",n)==0 ){
379 fossil_fatal("the \"fossil tag branch\" command is discontinued\n"
380 "Use the \"fossil branch new\" command instead.");
@@ -382,11 +379,13 @@
382
383 if( strncmp(g.argv[2],"cancel",n)==0 ){
384 if( g.argc!=5 ){
385 usage("cancel ?--raw? TAGNAME CHECK-IN");
386 }
 
387 tag_add_artifact(zPrefix, g.argv[3], g.argv[4], 0, 0);
 
388 }else
389
390 if( strncmp(g.argv[2],"find",n)==0 ){
391 Stmt q;
392 if( g.argc!=4 ){
393
--- src/tag.c
+++ src/tag.c
@@ -246,11 +246,11 @@
246
247 /*
248 ** Add a control record to the repository that either creates
249 ** or cancels a tag.
250 */
251 void tag_add_artifact(
252 const char *zPrefix, /* Prefix to prepend to tag name */
253 const char *zTagname, /* The tag to add or cancel */
254 const char *zObjName, /* Name of object attached to */
255 const char *zValue, /* Value for the tag. Might be NULL */
256 int tagtype /* 0:cancel 1:singleton 2:propagated */
@@ -293,17 +293,12 @@
293 blob_appendf(&ctrl, "\n");
294 }
295 blob_appendf(&ctrl, "U %F\n", g.zLogin);
296 md5sum_blob(&ctrl, &cksum);
297 blob_appendf(&ctrl, "Z %b\n", &cksum);
 
298 nrid = content_put(&ctrl, 0, 0);
299 manifest_crosslink(nrid, &ctrl);
 
 
 
 
300 }
301
302 /*
303 ** COMMAND: tag
304 ** Usage: %fossil tag SUBCOMMAND ...
@@ -370,11 +365,13 @@
365 char *zValue;
366 if( g.argc!=5 && g.argc!=6 ){
367 usage("add ?--raw? ?--propagate? TAGNAME CHECK-IN ?VALUE?");
368 }
369 zValue = g.argc==6 ? g.argv[5] : 0;
370 db_begin_transaction();
371 tag_add_artifact(zPrefix, g.argv[3], g.argv[4], zValue, 1+fPropagate);
372 db_end_transaction(0);
373 }else
374
375 if( strncmp(g.argv[2],"branch",n)==0 ){
376 fossil_fatal("the \"fossil tag branch\" command is discontinued\n"
377 "Use the \"fossil branch new\" command instead.");
@@ -382,11 +379,13 @@
379
380 if( strncmp(g.argv[2],"cancel",n)==0 ){
381 if( g.argc!=5 ){
382 usage("cancel ?--raw? TAGNAME CHECK-IN");
383 }
384 db_begin_transaction();
385 tag_add_artifact(zPrefix, g.argv[3], g.argv[4], 0, 0);
386 db_end_transaction(0);
387 }else
388
389 if( strncmp(g.argv[2],"find",n)==0 ){
390 Stmt q;
391 if( g.argc!=4 ){
392

Keyboard Shortcuts

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