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

Overview
Comment:implemented add/set ticket commands
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wolfgangTicketCmd
Files: files | file ages | folders
SHA1:9d3b9d653a11eaaecec0409e88de3b65e6655b95
User & Date: wolfgang 2010-10-05 13:46:39
Context
2010-10-05
15:44
check for valid UUID on ticket set command check-in: 1e1512f5 user: wolfgang tags: wolfgangTicketCmd
13:46
implemented add/set ticket commands check-in: 9d3b9d65 user: wolfgang tags: wolfgangTicketCmd
10:43
filter on ticket show working, report code moved to report.c check-in: 092d7630 user: wolfgang tags: wolfgangTicketCmd
Changes

Changes to src/tkt.c.

846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
...
865
866
867
868
869
870
871

872
873









874
875
876
877


878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894








895


896



897
898







































































899
900
901
**         using "," as separator. The seperator "," can be changed using
**         the -l or --limit option.
**         If TICKETFILTER is given on the commandline, the query is
**         limited with a new WHERE-condition.
**           example:  Report lists a column # with the uuid
**                     TICKETFILTER= [#]='uuuuuuuuu'
**
**     %fossil ticket set FIELD VALUE ?FIELD VALUE ... ? TICKETUUID
**
**         change ticket identified by TICKETUUID and set the value of
**         field FIELD to VALUE. Valid field descriptions are:
**            status, type, severity, priority, resolution,
**            foundin, private_contact, resolution, title or comment
**         Field names given above are the ones, defined in a standard
**         fossil environment. If you have added, deleted columns, you
................................................................................
**
**         like set, but create a new ticket with the given values.
**
*/
void ticket_cmd(void){
  int n;


  db_find_and_open_repository(1);










  if( g.argc<3 ){
    usage("add|set|show");
  }else{
    n = strlen(g.argv[2]);


    if( strncmp(g.argv[2],"show",n)==0 ){
      if( g.argc==3 ){
        usage("ticket show REPORTNR");
      }else{
        int rn;
        const char *zSep = 0;
	const char *zFilterUuid = 0;

        zSep = find_option("limit","l",1);
        rn = atoi(g.argv[3]);
        if( g.argc>4 ){
          zFilterUuid = g.argv[4];
        }

	rptshow( rn, zSep, zFilterUuid );

      }








    }else if( strncmp(g.argv[2],"set",n)==0 ){


      fossil_fatal("set unimplemented");



    }else if( strncmp(g.argv[2],"add",n)==0 ){
      fossil_fatal("add unimplemented");







































































    }
  }
}







|







 







>


>
>
>
>
>
>
>
>
>




>
>
|





|







|


>
>
>
>
>
>
>
>
|
>
>
|
>
>
>
|
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
...
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
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
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
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
**         using "," as separator. The seperator "," can be changed using
**         the -l or --limit option.
**         If TICKETFILTER is given on the commandline, the query is
**         limited with a new WHERE-condition.
**           example:  Report lists a column # with the uuid
**                     TICKETFILTER= [#]='uuuuuuuuu'
**
**     %fossil ticket set TICKETUUID FIELD VALUE ?FIELD VALUE ... ?
**
**         change ticket identified by TICKETUUID and set the value of
**         field FIELD to VALUE. Valid field descriptions are:
**            status, type, severity, priority, resolution,
**            foundin, private_contact, resolution, title or comment
**         Field names given above are the ones, defined in a standard
**         fossil environment. If you have added, deleted columns, you
................................................................................
**
**         like set, but create a new ticket with the given values.
**
*/
void ticket_cmd(void){
  int n;

  db_must_be_within_tree();
  db_find_and_open_repository(1);

  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);
  }
fprintf(stdout,"%s\n",g.zLogin);

  if( g.argc<3 ){
    usage("add|set|show");
  }else{
    n = strlen(g.argv[2]);
    if( n==1 && g.argv[2][0]=='s' ){
      usage("ticket show|set|add");
    }else if( strncmp(g.argv[2],"show",n)==0 ){
      if( g.argc==3 ){
        usage("ticket show REPORTNR");
      }else{
        int rn;
        const char *zSep = 0;
        const char *zFilterUuid = 0;

        zSep = find_option("limit","l",1);
        rn = atoi(g.argv[3]);
        if( g.argc>4 ){
          zFilterUuid = g.argv[4];
        }

        rptshow( rn, zSep, zFilterUuid );

      }
    }else{
      enum { set,add,err } eCmd = err;
      int i;
      int rid;
      const char *zTktUuid;
      Blob tktchng, cksum;

      /* get command type (set/add) and get uuid, if needed for set */
      if( strncmp(g.argv[2],"set",n)==0 ){
        eCmd = add;
        if( g.argc==3 ){
          fossil_fatal("set: missing TICKETUUID!");
        }
        zTktUuid = g.argv[3];
        i=4;
      }else if( strncmp(g.argv[2],"add",n)==0 ){

        eCmd = set;
        zTktUuid = 0;
        i = 3;
      }
      if( eCmd==err ){
        fossil_fatal("%s: unknown ticket command",g.argv[2]);
      }
      if( i==g.argc ){
        fossil_fatal("empty %s command aborted!",g.argv[2]);
      }
      /* read all available ticket fields */
      getAllTicketFields();
      /* read commandline and assign fields in the azValue array */
      while( i<g.argc ){
        char *zFName;
        char *zFValue;
        int j;

        zFName = g.argv[i++];
        if( i==g.argc ){
          fossil_fatal("missing value for '%s'!",zFName);
        }
        zFValue = g.argv[i++];
        j = fieldId(zFName);
        if( j == -1 ){
          fossil_fatal("unknown field name '%s'!",zFName);
        }else{
          azValue[j] = zFValue;
        }
      }
      blob_zero(&tktchng);
      { /* add the time to the ticket manifest */
        char *zDate;

        zDate = db_text(0, "SELECT datetime('now')");
        zDate[10] = 'T';
        blob_appendf(&tktchng, "D %s\n", zDate);
        free(zDate);
      }
      /* append defined elements */
      for(i=0; i<nField; i++){
        char *zValue;

        zValue = azValue[i];
        if( azValue[i] && azValue[i][0] ){
          if( strncmp(azField[i], "private_", 8)==0 ){
            zValue = db_conceal(zValue, strlen(zValue));
            blob_appendf(&tktchng, "J %s %s\n", azField[i], zValue);
          }else{
            blob_appendf(&tktchng, "J %s %#F\n", azField[i], strlen(zValue), zValue);
          }
        }
      }
      if( zTktUuid ){
        zTktUuid = db_text(0, 
          "SELECT tkt_uuid FROM ticket WHERE tkt_uuid GLOB '%s*'", zTktUuid
        );
      }else{
        zTktUuid = db_text(0, "SELECT lower(hex(randomblob(20)))");
      }
      blob_appendf(&tktchng, "K %s\n", zTktUuid);
      blob_appendf(&tktchng, "U %F\n", g.zLogin);
      md5sum_blob(&tktchng, &cksum);
      blob_appendf(&tktchng, "Z %b\n", &cksum);
      rid = content_put(&tktchng, 0, 0);
      if( rid==0 ){
        fossil_panic("trouble committing ticket: %s", g.zErrMsg);
      }
      manifest_crosslink_begin();
      manifest_crosslink(rid, &tktchng);
      manifest_crosslink_end();
    }
  }
}