Fossil

Changes On Branch venks-emacs
Login

Changes On Branch venks-emacs

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

Changes In Branch venks-emacs Excluding Merge-Ins

This is equivalent to a diff from b120bc8b to 374920b2

2011-09-01
22:00
Merge in support for the "fossil ticket history" command from the venks-emacs branch. ... (check-in: 98a855c5 user: drh tags: trunk)
2011-08-31
14:34
Improvements to artifact descriptions merged into trunk. ... (check-in: 49402fc7 user: drh tags: trunk)
09:55
Merge latest trunk. ... (check-in: 40ed431c user: dmitry tags: symlinks)
08:24
Trying to improve the ui artifact description to something easier to parse by the human eye.

I'd still like to have the branch name of every checkin, but I still don't know how to get it. ... (check-in: d34a1b9f user: viriketo tags: artifact_description)

07:50
Improve formatting for fossil ticket history. Make small fields print on same line, and make longer ones look better. ... (Closed-Leaf check-in: 374920b2 user: venkat tags: venks-emacs)
2011-08-30
21:50
Add ability to show ticket history from command line. fossil ticket now takes a new history option, which prints the history of a ticket - somewhat like what the history button does on the ticket web GUI. ... (check-in: 73e363ea user: venkat tags: venks-emacs)
21:46
merge trunk before changes ... (check-in: ffa3b1ea user: venkat tags: venks-emacs)
18:04
Print an error message and quite if the --user option appears on a "fossil commit" command but specifies a username not found in the database. Ticket [3ed2e994e1750b] ... (check-in: b120bc8b user: drh tags: trunk)
17:39
Display the last modification time of tickets using either localtime or UTC according to user preferences. ... (check-in: 839f1050 user: drh tags: trunk)

Changes to src/tkt.c.

897
898
899
900
901
902
903




904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
**         in "ticket show". So it's possible, to set multiline text or
**         text with special characters.
**
**     %fossil ticket add FIELD VALUE ?FIELD VALUE .. ? ?-q|--quote?
**
**         like set, but create a new ticket with the given values.
**




** The values in set|add are not validated against the definitions
** given in "Ticket Common Script".
*/
void ticket_cmd(void){
  int n;

  /* do some ints, we want to be inside a checkout */
  db_find_and_open_repository(0, 0);
  user_select();
  /*
  ** Check that the user exists.
  */
  if( !db_exists("SELECT 1 FROM user WHERE login=%Q", g.zLogin) ){
    fossil_fatal("no such user: %s", g.zLogin);
  }

  if( g.argc<3 ){
    usage("add|fieldlist|set|show");
  }else{
    n = strlen(g.argv[2]);
    if( n==1 && g.argv[2][0]=='s' ){
      /* set/show cannot be distinguished, so show the usage */
      usage("add|fieldlist|set|show");
    }else if( strncmp(g.argv[2],"list",n)==0 ){
      if( g.argc==3 ){
        usage("list fields|reports");
      }else{
        n = strlen(g.argv[3]);
        if( !strncmp(g.argv[3],"fields",n) ){
          /* simply show all field names */







>
>
>
>

















|




|







897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
**         in "ticket show". So it's possible, to set multiline text or
**         text with special characters.
**
**     %fossil ticket add FIELD VALUE ?FIELD VALUE .. ? ?-q|--quote?
**
**         like set, but create a new ticket with the given values.
**
**     %fossil ticket history TICKETUUID
**
**         Show the complete change history for the ticket
**
** The values in set|add are not validated against the definitions
** given in "Ticket Common Script".
*/
void ticket_cmd(void){
  int n;

  /* do some ints, we want to be inside a checkout */
  db_find_and_open_repository(0, 0);
  user_select();
  /*
  ** Check that the user exists.
  */
  if( !db_exists("SELECT 1 FROM user WHERE login=%Q", g.zLogin) ){
    fossil_fatal("no such user: %s", g.zLogin);
  }

  if( g.argc<3 ){
    usage("add|fieldlist|set|show|history");
  }else{
    n = strlen(g.argv[2]);
    if( n==1 && g.argv[2][0]=='s' ){
      /* set/show cannot be distinguished, so show the usage */
      usage("add|fieldlist|set|show|history");
    }else if( strncmp(g.argv[2],"list",n)==0 ){
      if( g.argc==3 ){
        usage("list fields|reports");
      }else{
        n = strlen(g.argv[3]);
        if( !strncmp(g.argv[3],"fields",n) ){
          /* simply show all field names */
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982




983

984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003













































































1004
1005
1006
1007
1008
1009
1010
          }

          rptshow( zRep, zSep, zFilterUuid, tktEncoding );

        }
      }else{
        /* add a new ticket or update an existing ticket */
        enum { set,add,err } eCmd = err;
        int i = 0;
        int rid;
        const char *zTktUuid = 0;
        Blob tktchng, cksum;

        /* get command type (set/add) and get uuid, if needed for set */
        if( strncmp(g.argv[2],"set",n)==0 || strncmp(g.argv[2],"change",n)==0 ){




          eCmd = set;

          if( g.argc==3 ){
            usage("set TICKETUUID");
          }
          zTktUuid = db_text(0, 
            "SELECT tkt_uuid FROM ticket WHERE tkt_uuid GLOB '%s*'", g.argv[3]
          );
          if( !zTktUuid ){
            fossil_fatal("unknown ticket: '%s'!",g.argv[3]);
          }
          i=4;
        }else if( strncmp(g.argv[2],"add",n)==0 ){
          eCmd = add;
          i = 3;
          zTktUuid = db_text(0, "SELECT lower(hex(randomblob(20)))");
        }
        /* none of set/add, so show the usage! */
        if( eCmd==err ){
          usage("add|fieldlist|set|show");
        }
        













































































        /* read all given ticket field/value pairs from command line */
        if( i==g.argc ){
          fossil_fatal("empty %s command aborted!",g.argv[2]);
        }
        getAllTicketFields();
        /* read commandline and assign fields in the azValue array */
        while( i<g.argc ){







|






|
>
>
>
>
|
>

















|

|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
          }

          rptshow( zRep, zSep, zFilterUuid, tktEncoding );

        }
      }else{
        /* add a new ticket or update an existing ticket */
        enum { set,add,history,err } eCmd = err;
        int i = 0;
        int rid;
        const char *zTktUuid = 0;
        Blob tktchng, cksum;

        /* get command type (set/add) and get uuid, if needed for set */
        if( strncmp(g.argv[2],"set",n)==0 || strncmp(g.argv[2],"change",n)==0 ||
           strncmp(g.argv[2],"history",n)==0 ){
          if( strncmp(g.argv[2],"history",n)==0 ){
            eCmd = history;
          }else{
            eCmd = set;
          }
          if( g.argc==3 ){
            usage("set TICKETUUID");
          }
          zTktUuid = db_text(0, 
            "SELECT tkt_uuid FROM ticket WHERE tkt_uuid GLOB '%s*'", g.argv[3]
          );
          if( !zTktUuid ){
            fossil_fatal("unknown ticket: '%s'!",g.argv[3]);
          }
          i=4;
        }else if( strncmp(g.argv[2],"add",n)==0 ){
          eCmd = add;
          i = 3;
          zTktUuid = db_text(0, "SELECT lower(hex(randomblob(20)))");
        }
        /* none of set/add, so show the usage! */
        if( eCmd==err ){
          usage("add|fieldlist|set|show|history");
        }

        /* we just handle history separately here, does not get out */
        if( eCmd==history ){
          Stmt q;
          char *zTitle;
          int tagid;

          if ( i != g.argc ){
            fossil_fatal("no other parameters expected to %s!",g.argv[2]);
          }
          tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname GLOB 'tkt-%q*'",zTktUuid);
          if( tagid==0 ){
            fossil_fatal("no such ticket %h", zTktUuid);
          }  
          db_prepare(&q,
            "SELECT datetime(mtime,'localtime'), objid, uuid, NULL, NULL, NULL"
            "  FROM event, blob"
            " WHERE objid IN (SELECT rid FROM tagxref WHERE tagid=%d)"
            "   AND blob.rid=event.objid"
            " UNION "
            "SELECT datetime(mtime,'localtime'), attachid, uuid, src, filename, user"
            "  FROM attachment, blob"
            " WHERE target=(SELECT substr(tagname,5) FROM tag WHERE tagid=%d)"
            "   AND blob.rid=attachid"
            " ORDER BY 1 DESC",
            tagid, tagid
          );
          while( db_step(&q)==SQLITE_ROW ){
            Manifest *pTicket;
            char zShort[12];
            const char *zDate = db_column_text(&q, 0);
            int rid = db_column_int(&q, 1);
            const char *zChngUuid = db_column_text(&q, 2);
            const char *zFile = db_column_text(&q, 4);
            memcpy(zShort, zChngUuid, 10);
            zShort[10] = 0;
            if( zFile!=0 ){
              const char *zSrc = db_column_text(&q, 3);
              const char *zUser = db_column_text(&q, 5);
              if( zSrc==0 || zSrc[0]==0 ){
                fossil_print("Delete attachment %h\n", zFile);
              }else{
                fossil_print("Add attachment %h\n", zFile);
              }
              fossil_print(" by %h on %h\n", zUser, zDate);
            }else{
              pTicket = manifest_get(rid, CFTYPE_TICKET);
              if( pTicket ){
                int i;

                fossil_print("Ticket Change by %h on %h:\n", pTicket->zUser, zDate);
                for(i=0; i<pTicket->nField; i++){
                  Blob val;
                  const char *z;
                  z = pTicket->aField[i].zName;
                  blob_set(&val, pTicket->aField[i].zValue);
                  if( z[0]=='+' ){
                    fossil_print("  Append to ");
		    z++;
		  }else{
		    fossil_print("  Change ");
                  }
		  fossil_print("%h: ",z);
		  if( blob_size(&val)>50 || contains_newline(&val)) {
                    fossil_print("\n    ",blob_str(&val));
                    comment_print(blob_str(&val),4,79);
                  }else{
                    fossil_print("%s\n",blob_str(&val));
                  }
                  blob_reset(&val);
                }
              }
              manifest_destroy(pTicket);
            }
          }
          db_finalize(&q);
          return;
        }
        /* read all given ticket field/value pairs from command line */
        if( i==g.argc ){
          fossil_fatal("empty %s command aborted!",g.argv[2]);
        }
        getAllTicketFields();
        /* read commandline and assign fields in the azValue array */
        while( i<g.argc ){