Fossil SCM

Add a --nofork option to "tag branch" so that --raw is not being used for two different purposes. Modify and tidy up the corresponding help text.

eric 2008-10-22 19:35 trunk
Commit c887b2b66e643ef09989ecfda62733f9b274066a
1 file changed +45 -42
+45 -42
--- src/tag.c
+++ src/tag.c
@@ -257,19 +257,20 @@
257257
** is not complete at that stage.
258258
*/
259259
static void tag_prepare_fork(
260260
Blob *pCtrl,
261261
const char *zTagname,
262
- int rid
262
+ int rid,
263
+ int preflen /* Tag prefix length to adjust name if reqd */
263264
){
264265
Stmt q;
265266
Manifest origin;
266267
Blob originContent;
267268
char *zDate;
268269
int i;
269270
270
- blob_appendf(pCtrl, "C Create\\snamed\\sfork\\s%s\n", zTagname+4);
271
+ blob_appendf(pCtrl, "C Create\\snamed\\sfork\\s%s\n", zTagname+preflen);
271272
content_get(rid, &originContent);
272273
manifest_parse(&origin, &originContent);
273274
zDate = db_text(0, "SELECT datetime('now')");
274275
zDate[10] = 'T';
275276
blob_appendf(pCtrl, "D %s\n", zDate);
@@ -309,11 +310,12 @@
309310
static void tag_add_artifact(
310311
const char *zTagname, /* The tag to add or cancel */
311312
const char *zObjName, /* Name of object attached to */
312313
const char *zValue, /* Value for the tag. Might be NULL */
313314
int tagtype, /* 0:cancel 1:singleton 2:propagated */
314
- int fork /* Should a fork created from zObjName? */
315
+ int fork, /* Should a fork created from zObjName? */
316
+ int preflen /* Tag prefix length to adjust name if reqd */
315317
){
316318
int rid;
317319
int nrid;
318320
char *zDate;
319321
Blob uuid;
@@ -334,11 +336,11 @@
334336
if( validate16(zTagname, strlen(zTagname)) ){
335337
fossil_fatal("invalid tag name \"%s\" - might be confused with a UUID",
336338
zTagname);
337339
}
338340
if( fork ){
339
- tag_prepare_fork(&ctrl, zTagname, rid);
341
+ tag_prepare_fork(&ctrl, zTagname, rid, preflen);
340342
}else{
341343
zDate = db_text(0, "SELECT datetime('now')");
342344
zDate[10] = 'T';
343345
blob_appendf(&ctrl, "D %s\n", zDate);
344346
blob_appendf(&ctrl, "T %c%F %b", zTagtype[tagtype], zTagname, &uuid);
@@ -367,32 +369,31 @@
367369
** Run various subcommands to control tags and properties
368370
**
369371
** %fossil tag add ?--raw? TAGNAME UUID ?VALUE?
370372
**
371373
** Add a new tag or property to UUID. The tag will
372
-** be usable instead of a UUID in commands like
373
-** update and such.
374
-**
375
-** %fossil tag branch ?--raw? TAGNAME UUID ?VALUE?
376
-**
377
-** A fork of UUID will be created. Then the new tag
378
-** or property will be added to the fork that
379
-** propagate to all direct children.
380
-**
381
-** Additionally all symbolic tags of that fork
382
-** inherited from UUID will be cancelled.
383
-**
384
-** However, if the option '--raw' was given, no
385
-** fork will be created but the tag/property will be
386
-** added to UUID directly and no tag will be
387
-** canceled.
388
-**
389
-** Please see the description of '--raw' below too.
374
+** be usable instead of a UUID in commands such as
375
+** update and merge.
376
+**
377
+** %fossil tag branch ?--raw? ?--nofork? TAGNAME UUID ?VALUE?
378
+**
379
+** A fork will be created so that the new checkin
380
+** is a sibling of UUID and identical to it except
381
+** for a generated comment. Then the new tag will
382
+** be added to the new checkin and propagated to
383
+** all direct children. Additionally all symbolic
384
+** tags of that checkin inherited from UUID will
385
+** be cancelled.
386
+**
387
+** However, if the option --nofork is given, no
388
+** fork will be created and the tag/property will be
389
+** added to UUID directly. No tags will be canceled.
390390
**
391391
** %fossil tag cancel ?--raw? TAGNAME UUID
392392
**
393
-** Cancel the tag TAGNAME from UUID
393
+** Remove the tag TAGNAME from UUID, and also remove
394
+** the propagation of the tag to any descendants.
394395
**
395396
** %fossil tag find ?--raw? TAGNAME
396397
**
397398
** List all baselines that use TAGNAME
398399
**
@@ -399,32 +400,33 @@
399400
** %fossil tag list ?--raw? ?UUID?
400401
**
401402
** List all tags, or if UUID is supplied, list
402403
** all tags and their values for UUID.
403404
**
404
-** The option ?--raw? is to expose the internal interface
405
-** for tag handling. This option is not necessary for the
406
-** normal use.
407
-**
408
-** If you use a tagname that might be confused with a UUID,
409
-** you have to explicitly disambiguate it by prefixing it
410
-** with "tag:". For instance:
411
-**
412
-** fossil update cfcfcfee
413
-**
414
-** is not the same as:
405
+** The option --raw allows the manipulation of all types of
406
+** tags used for various internal purposes in fossil. You
407
+** should not use this option to make changes unless you are
408
+** sure what you are doing.
409
+**
410
+** If you need to use a tagname that might be confused with
411
+** a UUID, you can explicitly disambiguate it by prefixing
412
+** it with "tag:". For instance:
413
+**
414
+** fossil update decaf
415
+**
416
+** will be taken as a UUID and fossil will probably complain
417
+** that no such revision was found. However
415418
**
416419
** fossil update tag:cfcfcfee
417420
**
418
-** The first will be taken as UUID and fossil will complain
419
-** if no such revision was found, and the second one expect
420
-** "cfcfcfee" to be a tag/branch name!
421
+** will assume that "decaf" is a tag/branch name.
421422
**
422423
*/
423424
void tag_cmd(void){
424425
int n;
425426
int raw = find_option("raw","",0)!=0;
427
+ int fork = find_option("nofork","",0)==0;
426428
const char *prefix = raw ? "" : "sym-";
427429
int preflen = strlen(prefix);
428430
Blob tagname;
429431
430432
db_find_and_open_repository(1);
@@ -443,22 +445,23 @@
443445
if( g.argc!=5 && g.argc!=6 ){
444446
usage("add ?--raw? TAGNAME UUID ?VALUE?");
445447
}
446448
blob_append(&tagname, g.argv[3], strlen(g.argv[3]));
447449
zValue = g.argc==6 ? g.argv[5] : 0;
448
- tag_add_artifact(blob_str(&tagname), g.argv[4], zValue, 1, 0);
450
+ tag_add_artifact(blob_str(&tagname), g.argv[4], zValue, 1, 0, 0);
449451
}else
450452
451453
if( strncmp(g.argv[2],"branch",n)==0 ){
452454
char *zValue;
453455
if( g.argc!=5 && g.argc!=6 ){
454
- usage("branch ?--raw? TAGNAME UUID ?VALUE?");
456
+ usage("branch ?--raw? ?--nofork? TAGNAME UUID ?VALUE?");
455457
}
456458
blob_append(&tagname, g.argv[3], strlen(g.argv[3]));
457459
zValue = g.argc==6 ? g.argv[5] : 0;
458
- tag_add_artifact(blob_str(&tagname), g.argv[4], zValue, 2, raw==0);
459
- if( !raw ){
460
+ tag_add_artifact(blob_str(&tagname), g.argv[4], zValue, 2, fork!=0,
461
+ preflen);
462
+ if( fork ){
460463
const char *zUuid = db_text(0, "SELECT uuid, MAX(rowid) FROM blob");
461464
printf("New_Fork \"%s\": %s\n", g.argv[3], zUuid);
462465
}
463466
}else
464467
@@ -465,11 +468,11 @@
465468
if( strncmp(g.argv[2],"cancel",n)==0 ){
466469
if( g.argc!=5 ){
467470
usage("cancel ?--raw? TAGNAME UUID");
468471
}
469472
blob_append(&tagname, g.argv[3], strlen(g.argv[3]));
470
- tag_add_artifact(blob_str(&tagname), g.argv[4], 0, 0, 0);
473
+ tag_add_artifact(blob_str(&tagname), g.argv[4], 0, 0, 0, 0);
471474
}else
472475
473476
if( strncmp(g.argv[2],"find",n)==0 ){
474477
Stmt q;
475478
if( g.argc!=4 ){
476479
--- src/tag.c
+++ src/tag.c
@@ -257,19 +257,20 @@
257 ** is not complete at that stage.
258 */
259 static void tag_prepare_fork(
260 Blob *pCtrl,
261 const char *zTagname,
262 int rid
 
263 ){
264 Stmt q;
265 Manifest origin;
266 Blob originContent;
267 char *zDate;
268 int i;
269
270 blob_appendf(pCtrl, "C Create\\snamed\\sfork\\s%s\n", zTagname+4);
271 content_get(rid, &originContent);
272 manifest_parse(&origin, &originContent);
273 zDate = db_text(0, "SELECT datetime('now')");
274 zDate[10] = 'T';
275 blob_appendf(pCtrl, "D %s\n", zDate);
@@ -309,11 +310,12 @@
309 static void tag_add_artifact(
310 const char *zTagname, /* The tag to add or cancel */
311 const char *zObjName, /* Name of object attached to */
312 const char *zValue, /* Value for the tag. Might be NULL */
313 int tagtype, /* 0:cancel 1:singleton 2:propagated */
314 int fork /* Should a fork created from zObjName? */
 
315 ){
316 int rid;
317 int nrid;
318 char *zDate;
319 Blob uuid;
@@ -334,11 +336,11 @@
334 if( validate16(zTagname, strlen(zTagname)) ){
335 fossil_fatal("invalid tag name \"%s\" - might be confused with a UUID",
336 zTagname);
337 }
338 if( fork ){
339 tag_prepare_fork(&ctrl, zTagname, rid);
340 }else{
341 zDate = db_text(0, "SELECT datetime('now')");
342 zDate[10] = 'T';
343 blob_appendf(&ctrl, "D %s\n", zDate);
344 blob_appendf(&ctrl, "T %c%F %b", zTagtype[tagtype], zTagname, &uuid);
@@ -367,32 +369,31 @@
367 ** Run various subcommands to control tags and properties
368 **
369 ** %fossil tag add ?--raw? TAGNAME UUID ?VALUE?
370 **
371 ** Add a new tag or property to UUID. The tag will
372 ** be usable instead of a UUID in commands like
373 ** update and such.
374 **
375 ** %fossil tag branch ?--raw? TAGNAME UUID ?VALUE?
376 **
377 ** A fork of UUID will be created. Then the new tag
378 ** or property will be added to the fork that
379 ** propagate to all direct children.
380 **
381 ** Additionally all symbolic tags of that fork
382 ** inherited from UUID will be cancelled.
383 **
384 ** However, if the option '--raw' was given, no
385 ** fork will be created but the tag/property will be
386 ** added to UUID directly and no tag will be
387 ** canceled.
388 **
389 ** Please see the description of '--raw' below too.
390 **
391 ** %fossil tag cancel ?--raw? TAGNAME UUID
392 **
393 ** Cancel the tag TAGNAME from UUID
 
394 **
395 ** %fossil tag find ?--raw? TAGNAME
396 **
397 ** List all baselines that use TAGNAME
398 **
@@ -399,32 +400,33 @@
399 ** %fossil tag list ?--raw? ?UUID?
400 **
401 ** List all tags, or if UUID is supplied, list
402 ** all tags and their values for UUID.
403 **
404 ** The option ?--raw? is to expose the internal interface
405 ** for tag handling. This option is not necessary for the
406 ** normal use.
407 **
408 ** If you use a tagname that might be confused with a UUID,
409 ** you have to explicitly disambiguate it by prefixing it
410 ** with "tag:". For instance:
411 **
412 ** fossil update cfcfcfee
413 **
414 ** is not the same as:
 
 
415 **
416 ** fossil update tag:cfcfcfee
417 **
418 ** The first will be taken as UUID and fossil will complain
419 ** if no such revision was found, and the second one expect
420 ** "cfcfcfee" to be a tag/branch name!
421 **
422 */
423 void tag_cmd(void){
424 int n;
425 int raw = find_option("raw","",0)!=0;
 
426 const char *prefix = raw ? "" : "sym-";
427 int preflen = strlen(prefix);
428 Blob tagname;
429
430 db_find_and_open_repository(1);
@@ -443,22 +445,23 @@
443 if( g.argc!=5 && g.argc!=6 ){
444 usage("add ?--raw? TAGNAME UUID ?VALUE?");
445 }
446 blob_append(&tagname, g.argv[3], strlen(g.argv[3]));
447 zValue = g.argc==6 ? g.argv[5] : 0;
448 tag_add_artifact(blob_str(&tagname), g.argv[4], zValue, 1, 0);
449 }else
450
451 if( strncmp(g.argv[2],"branch",n)==0 ){
452 char *zValue;
453 if( g.argc!=5 && g.argc!=6 ){
454 usage("branch ?--raw? TAGNAME UUID ?VALUE?");
455 }
456 blob_append(&tagname, g.argv[3], strlen(g.argv[3]));
457 zValue = g.argc==6 ? g.argv[5] : 0;
458 tag_add_artifact(blob_str(&tagname), g.argv[4], zValue, 2, raw==0);
459 if( !raw ){
 
460 const char *zUuid = db_text(0, "SELECT uuid, MAX(rowid) FROM blob");
461 printf("New_Fork \"%s\": %s\n", g.argv[3], zUuid);
462 }
463 }else
464
@@ -465,11 +468,11 @@
465 if( strncmp(g.argv[2],"cancel",n)==0 ){
466 if( g.argc!=5 ){
467 usage("cancel ?--raw? TAGNAME UUID");
468 }
469 blob_append(&tagname, g.argv[3], strlen(g.argv[3]));
470 tag_add_artifact(blob_str(&tagname), g.argv[4], 0, 0, 0);
471 }else
472
473 if( strncmp(g.argv[2],"find",n)==0 ){
474 Stmt q;
475 if( g.argc!=4 ){
476
--- src/tag.c
+++ src/tag.c
@@ -257,19 +257,20 @@
257 ** is not complete at that stage.
258 */
259 static void tag_prepare_fork(
260 Blob *pCtrl,
261 const char *zTagname,
262 int rid,
263 int preflen /* Tag prefix length to adjust name if reqd */
264 ){
265 Stmt q;
266 Manifest origin;
267 Blob originContent;
268 char *zDate;
269 int i;
270
271 blob_appendf(pCtrl, "C Create\\snamed\\sfork\\s%s\n", zTagname+preflen);
272 content_get(rid, &originContent);
273 manifest_parse(&origin, &originContent);
274 zDate = db_text(0, "SELECT datetime('now')");
275 zDate[10] = 'T';
276 blob_appendf(pCtrl, "D %s\n", zDate);
@@ -309,11 +310,12 @@
310 static void tag_add_artifact(
311 const char *zTagname, /* The tag to add or cancel */
312 const char *zObjName, /* Name of object attached to */
313 const char *zValue, /* Value for the tag. Might be NULL */
314 int tagtype, /* 0:cancel 1:singleton 2:propagated */
315 int fork, /* Should a fork created from zObjName? */
316 int preflen /* Tag prefix length to adjust name if reqd */
317 ){
318 int rid;
319 int nrid;
320 char *zDate;
321 Blob uuid;
@@ -334,11 +336,11 @@
336 if( validate16(zTagname, strlen(zTagname)) ){
337 fossil_fatal("invalid tag name \"%s\" - might be confused with a UUID",
338 zTagname);
339 }
340 if( fork ){
341 tag_prepare_fork(&ctrl, zTagname, rid, preflen);
342 }else{
343 zDate = db_text(0, "SELECT datetime('now')");
344 zDate[10] = 'T';
345 blob_appendf(&ctrl, "D %s\n", zDate);
346 blob_appendf(&ctrl, "T %c%F %b", zTagtype[tagtype], zTagname, &uuid);
@@ -367,32 +369,31 @@
369 ** Run various subcommands to control tags and properties
370 **
371 ** %fossil tag add ?--raw? TAGNAME UUID ?VALUE?
372 **
373 ** Add a new tag or property to UUID. The tag will
374 ** be usable instead of a UUID in commands such as
375 ** update and merge.
376 **
377 ** %fossil tag branch ?--raw? ?--nofork? TAGNAME UUID ?VALUE?
378 **
379 ** A fork will be created so that the new checkin
380 ** is a sibling of UUID and identical to it except
381 ** for a generated comment. Then the new tag will
382 ** be added to the new checkin and propagated to
383 ** all direct children. Additionally all symbolic
384 ** tags of that checkin inherited from UUID will
385 ** be cancelled.
386 **
387 ** However, if the option --nofork is given, no
388 ** fork will be created and the tag/property will be
389 ** added to UUID directly. No tags will be canceled.
 
 
390 **
391 ** %fossil tag cancel ?--raw? TAGNAME UUID
392 **
393 ** Remove the tag TAGNAME from UUID, and also remove
394 ** the propagation of the tag to any descendants.
395 **
396 ** %fossil tag find ?--raw? TAGNAME
397 **
398 ** List all baselines that use TAGNAME
399 **
@@ -399,32 +400,33 @@
400 ** %fossil tag list ?--raw? ?UUID?
401 **
402 ** List all tags, or if UUID is supplied, list
403 ** all tags and their values for UUID.
404 **
405 ** The option --raw allows the manipulation of all types of
406 ** tags used for various internal purposes in fossil. You
407 ** should not use this option to make changes unless you are
408 ** sure what you are doing.
409 **
410 ** If you need to use a tagname that might be confused with
411 ** a UUID, you can explicitly disambiguate it by prefixing
412 ** it with "tag:". For instance:
413 **
414 ** fossil update decaf
415 **
416 ** will be taken as a UUID and fossil will probably complain
417 ** that no such revision was found. However
418 **
419 ** fossil update tag:cfcfcfee
420 **
421 ** will assume that "decaf" is a tag/branch name.
 
 
422 **
423 */
424 void tag_cmd(void){
425 int n;
426 int raw = find_option("raw","",0)!=0;
427 int fork = find_option("nofork","",0)==0;
428 const char *prefix = raw ? "" : "sym-";
429 int preflen = strlen(prefix);
430 Blob tagname;
431
432 db_find_and_open_repository(1);
@@ -443,22 +445,23 @@
445 if( g.argc!=5 && g.argc!=6 ){
446 usage("add ?--raw? TAGNAME UUID ?VALUE?");
447 }
448 blob_append(&tagname, g.argv[3], strlen(g.argv[3]));
449 zValue = g.argc==6 ? g.argv[5] : 0;
450 tag_add_artifact(blob_str(&tagname), g.argv[4], zValue, 1, 0, 0);
451 }else
452
453 if( strncmp(g.argv[2],"branch",n)==0 ){
454 char *zValue;
455 if( g.argc!=5 && g.argc!=6 ){
456 usage("branch ?--raw? ?--nofork? TAGNAME UUID ?VALUE?");
457 }
458 blob_append(&tagname, g.argv[3], strlen(g.argv[3]));
459 zValue = g.argc==6 ? g.argv[5] : 0;
460 tag_add_artifact(blob_str(&tagname), g.argv[4], zValue, 2, fork!=0,
461 preflen);
462 if( fork ){
463 const char *zUuid = db_text(0, "SELECT uuid, MAX(rowid) FROM blob");
464 printf("New_Fork \"%s\": %s\n", g.argv[3], zUuid);
465 }
466 }else
467
@@ -465,11 +468,11 @@
468 if( strncmp(g.argv[2],"cancel",n)==0 ){
469 if( g.argc!=5 ){
470 usage("cancel ?--raw? TAGNAME UUID");
471 }
472 blob_append(&tagname, g.argv[3], strlen(g.argv[3]));
473 tag_add_artifact(blob_str(&tagname), g.argv[4], 0, 0, 0, 0);
474 }else
475
476 if( strncmp(g.argv[2],"find",n)==0 ){
477 Stmt q;
478 if( g.argc!=4 ){
479

Keyboard Shortcuts

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