Fossil

Check-in [e170afb9]
Login

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

Overview
Comment:Add --inverse|-v flag to tag ls, per discussion at https://fossil-scm.org/forum/forumpost/944e611710.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | tag-ls-inverse
Files: files | file ages | folders
SHA3-256: e170afb93626671811bbb3aa1f02225aa07eeeca392aa59ec08f8f5aee8039c3
User & Date: stephan 2020-01-03 16:39:27
Context
2020-01-03
16:39
Add --inverse|-v flag to tag ls, per discussion at https://fossil-scm.org/forum/forumpost/944e611710. Leaf check-in: e170afb9 user: stephan tags: tag-ls-inverse
2020-01-02
14:35
Fix the spelling of "legacy" in the "test-fingerprint" command. Also show the current Fossil version in the "test-fingerprint" command. check-in: 2af7fedd user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/tag.c.

421
422
423
424
425
426
427

428
429
430
431
432
433
434
...
546
547
548
549
550
551
552
553
554

555
556
557
558
559
560
561
...
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
...
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
**         List all tags, or if CHECK-IN is supplied, list
**         all tags and their values for CHECK-IN.  The tagtype option
**         takes one of: propagated, singleton, cancel.
**
**         Options:
**           --raw           List tags raw names of tags
**           --tagtype TYPE  List only tags of type TYPE

**
** The option --raw allows the manipulation of all types of tags
** used for various internal purposes in fossil. It also shows
** "cancel" tags for the "find" and "list" subcommands. You should
** not use this option to make changes unless you are sure what
** you are doing.
**
................................................................................
        db_finalize(&q);
      }
    }
  }else

  if(( strncmp(g.argv[2],"list",n)==0 )||( strncmp(g.argv[2],"ls",n)==0 )){
    Stmt q;
    int fRaw = find_option("raw","",0)!=0;
    const char *zTagType = find_option("tagtype","t",1);

    int nTagType = fRaw ? -1 : 0;
    if( zTagType!=0 ){
      int l = strlen(zTagType);
      if( strncmp(zTagType,"cancel",l)==0 ){
        nTagType = 0;
      }else if( strncmp(zTagType,"singleton",l)==0 ){ 
        nTagType = 1;
................................................................................
      }
    }
    if( g.argc==3 ){
      db_prepare(&q,
        "SELECT tagname FROM tag"
        " WHERE EXISTS(SELECT 1 FROM tagxref"
        "               WHERE tagid=tag.tagid"
        "                 AND tagtype%c%d)"
        " ORDER BY tagname",
        zTagType!=0 ? '=' : '>',
        nTagType
      );
      while( db_step(&q)==SQLITE_ROW ){
        const char *zName = db_column_text(&q, 0);
        if( fRaw ){
          fossil_print("%s\n", zName);
        }else if( strncmp(zName, "sym-", 4)==0 ){
................................................................................
      }
      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%c%d"
        " ORDER BY tagname",
        rid,
        zTagType!=0 ? '=' : '>',
        nTagType
      );
      while( db_step(&q)==SQLITE_ROW ){
        const char *zName = db_column_text(&q, 0);
        const char *zValue = db_column_text(&q, 1);
        if( fRaw==0 ){
          if( strncmp(zName, "sym-", 4)!=0 ) continue;







>







 







|

>







 







|

|







 







|


|







421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
...
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
...
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
...
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
**         List all tags, or if CHECK-IN is supplied, list
**         all tags and their values for CHECK-IN.  The tagtype option
**         takes one of: propagated, singleton, cancel.
**
**         Options:
**           --raw           List tags raw names of tags
**           --tagtype TYPE  List only tags of type TYPE
**           -v|--inverse    Inverse the meaning of --tagtype TYPE.
**
** The option --raw allows the manipulation of all types of tags
** used for various internal purposes in fossil. It also shows
** "cancel" tags for the "find" and "list" subcommands. You should
** not use this option to make changes unless you are sure what
** you are doing.
**
................................................................................
        db_finalize(&q);
      }
    }
  }else

  if(( strncmp(g.argv[2],"list",n)==0 )||( strncmp(g.argv[2],"ls",n)==0 )){
    Stmt q;
    const int fRaw = find_option("raw","",0)!=0;
    const char *zTagType = find_option("tagtype","t",1);
    const int fInverse = find_option("inverse","v",0)!=0;
    int nTagType = fRaw ? -1 : 0;
    if( zTagType!=0 ){
      int l = strlen(zTagType);
      if( strncmp(zTagType,"cancel",l)==0 ){
        nTagType = 0;
      }else if( strncmp(zTagType,"singleton",l)==0 ){ 
        nTagType = 1;
................................................................................
      }
    }
    if( g.argc==3 ){
      db_prepare(&q,
        "SELECT tagname FROM tag"
        " WHERE EXISTS(SELECT 1 FROM tagxref"
        "               WHERE tagid=tag.tagid"
        "                 AND tagtype%s%d)"
        " ORDER BY tagname",
        zTagType!=0 ? (fInverse!=0?"<>":"=") : ">"/*safe-for-%s*/,
        nTagType
      );
      while( db_step(&q)==SQLITE_ROW ){
        const char *zName = db_column_text(&q, 0);
        if( fRaw ){
          fossil_print("%s\n", zName);
        }else if( strncmp(zName, "sym-", 4)==0 ){
................................................................................
      }
      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%s%d"
        " ORDER BY tagname",
        rid,
        zTagType!=0 ? (fInverse!=0?"<>":"=") : ">"/*safe-for-%s*/,
        nTagType
      );
      while( db_step(&q)==SQLITE_ROW ){
        const char *zName = db_column_text(&q, 0);
        const char *zValue = db_column_text(&q, 1);
        if( fRaw==0 ){
          if( strncmp(zName, "sym-", 4)!=0 ) continue;