Fossil

Check-in [ac392fbb]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:
  • Rename subcommand tag delete to tag cancel.
  • New branching behavior. Now if subcommand tag branch is used, a new copy of manifest UUID with the same parent will be created, thereby creating a fork. A propagating symbolic tag with TAGNAME is assigned to the UUID of the new copy. Furthermore all other propagating symbolic tags that the fork did inherited by the original manifest, are cancelled.

    However, if the option --raw was given, the old tag branch behavior is used. That means, no creation of a fork by copying the manifest UUID, no cancelling of inherited propagating symbolic tags. The tag will be applied to the given UUID directly.

    For instance
            fossil tag branch fix-12345 cfcfcfee
            fossil tag branch --raw bgcolor fix-12345 yellow
          
    will create a fork by copiying manifest cfcfcfee, apply a tag fix-12345 that will propagate to its children and set the propagating property bgcolor to yellow.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:ac392fbba614c6ce552e3dc15f01b4101f8188e5
User & Date: cle 2008-08-11 04:03:37
Original Comment:
  • Rename subcommand tag delete to tag cancel.
  • New branching behavior. Now if subcommand tag branch is used, a new copy of manifest UUID with the same parent will be created, thereby forming a fork. A propagating symbolic tag with TAGNAME is assigned to the UUID of the new copy. Furthermore all other propagating symbolic tags that the fork did inherited by the original manifest, are cancelled.

    However, if the option --raw was given, the old tag branch behavior is used. That means, no creation of a fork by copying the manifest UUID, no cancelling of inherited propagating symbolic tags. The tag will be applied to the given <UUID> directly.

    For instance
            fossil tag branch fix-12345 cfcfcfee
            fossil tag branch --raw bgcolor tag:cfcfcfee yellow
          
    will create a fork by copiying manifest cfcfcfee, apply a tag fix-12345 that will propagate to its children and set the propagating property bgcolor too.
References
2008-08-14
10:51 New ticket [c858c417] Potential wrong commit comment shown at anchestors at /vinfo page.. artifact: 206a24f1 user: chi
Context
2008-08-11
05:30
Fix a spelling: replace 'delete' -> 'cancel' in usage for 'tag'. check-in: 91ec6982 user: hintze tags: trunk
04:03
  • Rename subcommand tag delete to tag cancel.
  • New branching behavior. Now if subcommand tag branch is used, a new copy of manifest UUID with the same parent will be created, thereby creating a fork. A propagating symbolic tag with TAGNAME is assigned to the UUID of the new copy. Furthermore all other propagating symbolic tags that the fork did inherited by the original manifest, are cancelled.

    However, if the option --raw was given, the old tag branch behavior is used. That means, no creation of a fork by copying the manifest UUID, no cancelling of inherited propagating symbolic tags. The tag will be applied to the given UUID directly.

    For instance
            fossil tag branch fix-12345 cfcfcfee
            fossil tag branch --raw bgcolor fix-12345 yellow
          
    will create a fork by copiying manifest cfcfcfee, apply a tag fix-12345 that will propagate to its children and set the propagating property bgcolor to yellow.
check-in: ac392fbb user: cle tags: trunk
2008-08-03
16:47
Users unconditionally inherit capabilities of "anonymous". New capability "v" means to inherit capabilities of user "developer". Login is prohibited if the password is empty. check-in: 1f1d9652 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/tag.c.

243
244
245
246
247
248
249






















































250
251
252
253
254
255
256
257
258
259

260
261
262
263
264
265
266
...
276
277
278
279
280
281
282



283
284
285
286

287
288
289
290
291
292
293
...
307
308
309
310
311
312
313
314
315
316
317
318

319
320










321
322
323
324
325
326
327
328
329
330
...
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388




389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
...
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
...
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
    fossil_fatal("no such object: %s", g.argv[3]);
  }
  zValue = g.argc==5 ? g.argv[4] : 0;
  db_begin_transaction();
  tag_insert(zTag, tagtype, zValue, -1, 0.0, rid);
  db_end_transaction(0); 
}























































/*
** Add a control record to the repository that either creates
** or cancels a tag.
*/
static void tag_add_artifact(
  const char *zTagname,       /* The tag to add or cancel */
  const char *zObjName,       /* Name of object attached to */
  const char *zValue,         /* Value for the tag.  Might be NULL */
  int tagtype                 /* 0:cancel 1:singleton 2:propagated */

){
  int rid;
  int nrid;
  char *zDate;
  Blob uuid;
  Blob ctrl;
  Blob cksum;
................................................................................
  rid = name_to_rid(blob_str(&uuid));
  blob_zero(&ctrl);

  if( validate16(zTagname, strlen(zTagname)) ){
    fossil_fatal("invalid tag name \"%s\" - might be confused with a UUID",
                 zTagname);
  }



  zDate = db_text(0, "SELECT datetime('now')");
  zDate[10] = 'T';
  blob_appendf(&ctrl, "D %s\n", zDate);
  blob_appendf(&ctrl, "T %c%F %b", zTagtype[tagtype], zTagname, &uuid);

  if( tagtype && zValue && zValue[0] ){
    blob_appendf(&ctrl, " %F\n", zValue);
  }else{
    blob_appendf(&ctrl, "\n");
  }
  blob_appendf(&ctrl, "U %F\n", g.zLogin);
  md5sum_blob(&ctrl, &cksum);
................................................................................
**
** Run various subcommands to control tags and properties
**
**     %fossil tag add ?--raw? TAGNAME UUID ?VALUE?
**
**         Add a new tag or property to UUID. The tag will
**         be usable instead of a UUID in commands like
**         update and the like.
**
**     %fossil tag branch ?--raw? TAGNAME UUID ?VALUE?
**
**         Add a new tag or property to UUID and make that

**         tag propagate to all direct children.
**










**     %fossil tag delete ?--raw? TAGNAME UUID
**
**         Delete the tag TAGNAME from UUID
**
**     %fossil tag find ?--raw? TAGNAME
**
**         List all baselines that use TAGNAME
**
**     %fossil tag list ?--raw? ?UUID?
**
................................................................................
  }

  blob_set(&tagname, prefix);

  if( strncmp(g.argv[2],"add",n)==0 ){
    char *zValue;
    if( g.argc!=5 && g.argc!=6 ){
      usage("add TAGNAME UUID ?VALUE?");
    }
    blob_append(&tagname, g.argv[3], strlen(g.argv[3]));
    zValue = g.argc==6 ? g.argv[5] : 0;
    tag_add_artifact(blob_str(&tagname), g.argv[4], zValue, 1);
  }else

  if( strncmp(g.argv[2],"branch",n)==0 ){
    char *zValue;
    if( g.argc!=5 && g.argc!=6 ){
      usage("branch TAGNAME UUID ?VALUE?");
    }
    blob_append(&tagname, g.argv[3], strlen(g.argv[3]));
    zValue = g.argc==6 ? g.argv[5] : 0;
    tag_add_artifact(blob_str(&tagname), g.argv[4], zValue, 2);




  }else

  if( strncmp(g.argv[2],"delete",n)==0 ){
    if( g.argc!=5 ){
      usage("delete TAGNAME UUID");
    }
    blob_append(&tagname, g.argv[3], strlen(g.argv[3]));
    tag_add_artifact(blob_str(&tagname), g.argv[4], 0, 0);
  }else

  if( strncmp(g.argv[2],"find",n)==0 ){
    Stmt q;
    if( g.argc!=4 ){
      usage("find TAGNAME");
    }
    blob_append(&tagname, g.argv[3], strlen(g.argv[3]));
    db_prepare(&q,
      "SELECT blob.uuid FROM tagxref, blob"
      " WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%B)"
      "   AND blob.rid=tagxref.rid", &tagname
    );
................................................................................
    db_finalize(&q);
  }else

  if( strncmp(g.argv[2],"list",n)==0 ){
    Stmt q;
    if( g.argc==3 ){
      db_prepare(&q, 
        "SELECT tagname"
        "  FROM tag"
        " WHERE EXISTS(SELECT 1 FROM tagxref"
        "               WHERE tagid=tag.tagid"
        "                 AND tagtype>0)"
        " ORDER BY tagname"
      );
      while( db_step(&q)==SQLITE_ROW ){
        const char *name = db_column_text(&q, 0);
................................................................................
          printf("%s\n", name+preflen);
        }
      }
      db_finalize(&q);
    }else if( g.argc==4 ){
      int rid = name_to_rid(g.argv[3]);
      db_prepare(&q,
        "SELECT tagname, value"
        "  FROM tagxref, tag"
        " WHERE tagxref.rid=%d AND tagxref.tagid=tag.tagid"
        "   AND tagtype>0"
        " ORDER BY tagname",
        rid
      );
      while( db_step(&q)==SQLITE_ROW ){
        const char *zName = db_column_text(&q, 0);







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









|
>







 







>
>
>
|
|
|
|
>







 







|



|
>
|

>
>
>
>
>
>
>
>
>
>
|

|







 







|



|





|



|
>
>
>
>


|

|


|





|







 







|
<







 







|
<







243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
...
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
...
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
...
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
...
487
488
489
490
491
492
493
494

495
496
497
498
499
500
501
...
503
504
505
506
507
508
509
510

511
512
513
514
515
516
517
    fossil_fatal("no such object: %s", g.argv[3]);
  }
  zValue = g.argc==5 ? g.argv[4] : 0;
  db_begin_transaction();
  tag_insert(zTag, tagtype, zValue, -1, 0.0, rid);
  db_end_transaction(0); 
}

/*
** Prepare an artifact that describes a fork from a certain UUID.
** Furthermore a propagating symbolic tag will be inserted and
** all other propagating symbolic tags will be cancelled.
**
** The changes are appended at the Blob pCtrl. However the manifest
** is not complete at that stage.
*/
static void tag_prepare_fork(
  Blob *pCtrl, 
  const char *zTagname,
  int rid
){
  Stmt q;
  Manifest origin;
  Blob originContent;
  char *zDate;
  int i;

  blob_appendf(pCtrl, "C Create\\snamed\\sfork\\s%s\n", zTagname+4);
  content_get(rid, &originContent);
  manifest_parse(&origin, &originContent);
  zDate = db_text(0, "SELECT datetime('now')");
  zDate[10] = 'T';
  blob_appendf(pCtrl, "D %s\n", zDate);
  for(i=0; i<origin.nFile; ++i){
    blob_appendf(pCtrl, "F %s %s %s\n",
                 origin.aFile[i].zName,
                 origin.aFile[i].zUuid,
                 origin.aFile[i].zPerm);
  }
  if( origin.nParent>0 ){
    blob_appendf(pCtrl, "P %s\n", origin.azParent[0]);
  }
  blob_appendf(pCtrl, "R %s\n", origin.zRepoCksum);
  blob_appendf(pCtrl, "T *%F *", zTagname);

  /* Cancel any sym- tags that propagate */
  db_prepare(&q,
      "SELECT tagname FROM tagxref, tag"
      " WHERE tagxref.rid=%d AND tagxref.tagid=tag.tagid"
      "   AND tagtype>0 AND tagname LIKE 'sym-%%'"
      " ORDER BY tagname",
      rid);
  while( db_step(&q)==SQLITE_ROW ){
    const char *zTag = db_column_text(&q, 0);
    blob_appendf(pCtrl, "\nT -%s *", zTag);
  }
  db_finalize(&q);

  /* Cleanup */
  manifest_clear(&origin);
}

/*
** Add a control record to the repository that either creates
** or cancels a tag.
*/
static void tag_add_artifact(
  const char *zTagname,       /* The tag to add or cancel */
  const char *zObjName,       /* Name of object attached to */
  const char *zValue,         /* Value for the tag.  Might be NULL */
  int tagtype,                /* 0:cancel 1:singleton 2:propagated */
  int fork                    /* Should a fork created from zObjName? */
){
  int rid;
  int nrid;
  char *zDate;
  Blob uuid;
  Blob ctrl;
  Blob cksum;
................................................................................
  rid = name_to_rid(blob_str(&uuid));
  blob_zero(&ctrl);

  if( validate16(zTagname, strlen(zTagname)) ){
    fossil_fatal("invalid tag name \"%s\" - might be confused with a UUID",
                 zTagname);
  }
  if( fork ){
    tag_prepare_fork(&ctrl, zTagname, rid);
  }else{
    zDate = db_text(0, "SELECT datetime('now')");
    zDate[10] = 'T';
    blob_appendf(&ctrl, "D %s\n", zDate);
    blob_appendf(&ctrl, "T %c%F %b", zTagtype[tagtype], zTagname, &uuid);
  }
  if( tagtype && zValue && zValue[0] ){
    blob_appendf(&ctrl, " %F\n", zValue);
  }else{
    blob_appendf(&ctrl, "\n");
  }
  blob_appendf(&ctrl, "U %F\n", g.zLogin);
  md5sum_blob(&ctrl, &cksum);
................................................................................
**
** Run various subcommands to control tags and properties
**
**     %fossil tag add ?--raw? TAGNAME UUID ?VALUE?
**
**         Add a new tag or property to UUID. The tag will
**         be usable instead of a UUID in commands like
**         update and such.
**
**     %fossil tag branch ?--raw? TAGNAME UUID ?VALUE?
**
**         A fork of UUID will be created. Then the new tag
**         or property will be added to the fork that
**         propagate to all direct children.
**
**         Additionally all symbolic tags of that fork
**         inherited from UUID will be cancelled.
**
**         However, if the option '--raw' was given, no
**         fork will be created but the tag/property will be
**         added to UUID directly and no tag will be
**         canceled.
**
**         Please see the description of '--raw' below too.
**
**     %fossil tag cancel ?--raw? TAGNAME UUID
**
**         Cancel the tag TAGNAME from UUID
**
**     %fossil tag find ?--raw? TAGNAME
**
**         List all baselines that use TAGNAME
**
**     %fossil tag list ?--raw? ?UUID?
**
................................................................................
  }

  blob_set(&tagname, prefix);

  if( strncmp(g.argv[2],"add",n)==0 ){
    char *zValue;
    if( g.argc!=5 && g.argc!=6 ){
      usage("add ?--raw? TAGNAME UUID ?VALUE?");
    }
    blob_append(&tagname, g.argv[3], strlen(g.argv[3]));
    zValue = g.argc==6 ? g.argv[5] : 0;
    tag_add_artifact(blob_str(&tagname), g.argv[4], zValue, 1, 0);
  }else

  if( strncmp(g.argv[2],"branch",n)==0 ){
    char *zValue;
    if( g.argc!=5 && g.argc!=6 ){
      usage("branch ?--raw? TAGNAME UUID ?VALUE?");
    }
    blob_append(&tagname, g.argv[3], strlen(g.argv[3]));
    zValue = g.argc==6 ? g.argv[5] : 0;
    tag_add_artifact(blob_str(&tagname), g.argv[4], zValue, 2, raw==0);
    if( !raw ){
      const char *zUuid = db_text(0, "SELECT uuid, MAX(rowid) FROM blob");
      printf("New_Fork \"%s\": %s\n", g.argv[3], zUuid);
    }
  }else

  if( strncmp(g.argv[2],"cancel",n)==0 ){
    if( g.argc!=5 ){
      usage("cancel ?--raw? TAGNAME UUID");
    }
    blob_append(&tagname, g.argv[3], strlen(g.argv[3]));
    tag_add_artifact(blob_str(&tagname), g.argv[4], 0, 0, 0);
  }else

  if( strncmp(g.argv[2],"find",n)==0 ){
    Stmt q;
    if( g.argc!=4 ){
      usage("find ?--raw? TAGNAME");
    }
    blob_append(&tagname, g.argv[3], strlen(g.argv[3]));
    db_prepare(&q,
      "SELECT blob.uuid FROM tagxref, blob"
      " WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%B)"
      "   AND blob.rid=tagxref.rid", &tagname
    );
................................................................................
    db_finalize(&q);
  }else

  if( strncmp(g.argv[2],"list",n)==0 ){
    Stmt q;
    if( g.argc==3 ){
      db_prepare(&q, 
        "SELECT tagname FROM tag"

        " WHERE EXISTS(SELECT 1 FROM tagxref"
        "               WHERE tagid=tag.tagid"
        "                 AND tagtype>0)"
        " ORDER BY tagname"
      );
      while( db_step(&q)==SQLITE_ROW ){
        const char *name = db_column_text(&q, 0);
................................................................................
          printf("%s\n", name+preflen);
        }
      }
      db_finalize(&q);
    }else if( g.argc==4 ){
      int rid = name_to_rid(g.argv[3]);
      db_prepare(&q,
        "SELECT tagname, value FROM tagxref, tag"

        " WHERE tagxref.rid=%d AND tagxref.tagid=tag.tagid"
        "   AND tagtype>0"
        " ORDER BY tagname",
        rid
      );
      while( db_step(&q)==SQLITE_ROW ){
        const char *zName = db_column_text(&q, 0);