Fossil

Check-in [092d763028]
Login

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

Overview
Comment:filter on ticket show working, report code moved to report.c
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | wolfgangTicketCmd
Files: files | file ages | folders
SHA1: 092d7630280b66a89e4edfea271038f551f7ae1a
User & Date: wolfgang 2010-10-05 10:43:28.000
References
2010-10-08
17:10 New ticket [c8c0b78c84] Windows 7: "fossil ui" and "fossil server" fail. ... (artifact: d35c9759bc user: anonymous)
2010-10-06
12:50 New ticket [44002a7760] cannot locate home directory - please set the HOMEPATH environment variable. ... (artifact: b9038f62ad user: anonymous)
Context
2010-10-05
13:46
implemented add/set ticket commands ... (check-in: 9d3b9d653a user: wolfgang tags: wolfgangTicketCmd)
10:43
filter on ticket show working, report code moved to report.c ... (check-in: 092d763028 user: wolfgang tags: wolfgangTicketCmd)
09:56
merge from trunk and extending Makefile.dmc with event ... (check-in: a6dd0bf3e1 user: wolfgang tags: wolfgangTicketCmd)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/report.c.
940
941
942
943
944
945
946


























































































  }else{
    sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)&zErr1);
    sqlite3_exec(g.db, zSql, output_tab_separated, &count, &zErr2);
    sqlite3_set_authorizer(g.db, 0, 0);
    cgi_set_content_type("text/plain");
  }
}

































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
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
  }else{
    sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)&zErr1);
    sqlite3_exec(g.db, zSql, output_tab_separated, &count, &zErr2);
    sqlite3_set_authorizer(g.db, 0, 0);
    cgi_set_content_type("text/plain");
  }
}

/*
** user defined separator used by ticket show command
*/
static const char *zSep = 0;

/*
** Output the text given in the argument.  Convert tabs and newlines into
** spaces.
*/
static void output_no_tabs_file(const char *z){
  while( z && z[0] ){
    int i, j;
    for(i=0; z[i] && (!isspace(z[i]) || z[i]==' '); i++){}
    if( i>0 ){
      printf("%.*s", i, z);
    }
    for(j=i; isspace(z[j]); j++){}
    if( j>i ){
      printf("%*s", j-i, "");
    }
    z += j;
  }
}

/*
** Output a row as a tab-separated line of text.
*/
int output_separated_file(
  void *pUser,     /* Pointer to row-count integer */
  int nArg,        /* Number of columns in this result row */
  char **azArg,    /* Text of data in all columns */
  char **azName    /* Names of the columns */
){
  int *pCount = (int*)pUser;
  int i;

  if( *pCount==0 ){
    for(i=0; i<nArg; i++){
      output_no_tabs_file(azName[i]);
      printf("%s", i<nArg-1 ? (zSep?zSep:"\t") : "\n");
    }
  }
  ++*pCount;
  for(i=0; i<nArg; i++){
    output_no_tabs_file(azArg[i]);
    printf("%s", i<nArg-1 ? (zSep?zSep:"\t") : "\n");
  }
  return 0;
}

/*
** Generate a report.  The rn query parameter is the report number.
** The output is written to stdout as flat file. The zFilter paramater
** is a full WHERE-condition.
*/
void rptshow( int rn, const char *zSep, const char *zFilter ){
  Stmt q;
  char *zSql;
  char *zTitle;
  char *zOwner;
  char *zClrKey;
  char *zErr1 = 0;
  char *zErr2 = 0;
  int count = 0;

  /* view_add_functions(tabs); */
  db_prepare(&q,
    "SELECT title, sqlcode, owner, cols FROM reportfmt WHERE rn=%d", rn);
  if( db_step(&q)!=SQLITE_ROW ){
    db_finalize(&q);
    fossil_fatal("unkown report format(%d)!",rn);
  }
  zTitle = db_column_malloc(&q, 0);
  zSql = db_column_malloc(&q, 1);
  zOwner = db_column_malloc(&q, 2);
  zClrKey = db_column_malloc(&q, 3);
  db_finalize(&q);
  if( zFilter ){
    zSql = mprintf("SELECT * FROM (%s) WHERE %s",zSql,zFilter);
  }
  count = 0;
  sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)&zErr1);
  sqlite3_exec(g.db, zSql, output_separated_file, &count, &zErr2);
  sqlite3_set_authorizer(g.db, 0, 0);
  if( zFilter ){
    free(zSql);
  }
}

Changes to src/tkt.c.
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
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
      @ <li>Change %h(z) to "%h(blob_str(&val))"</li>
    }
    blob_reset(&val);
  }
  @ </ol>
}

/*
** user defined separator used by ticket show command
*/
static const char *zSep = 0;

/*
** Output the text given in the argument.  Convert tabs and newlines into
** spaces.
*/
static void output_no_tabs(const char *z){
  while( z && z[0] ){
    int i, j;
    for(i=0; z[i] && (!isspace(z[i]) || z[i]==' '); i++){}
    if( i>0 ){
      printf("%.*s", i, z);
    }
    for(j=i; isspace(z[j]); j++){}
    if( j>i ){
      printf("%*s", j-i, "");
    }
    z += j;
  }
}

/*
** Output a row as a tab-separated line of text.
*/
int output_separated(
  void *pUser,     /* Pointer to row-count integer */
  int nArg,        /* Number of columns in this result row */
  char **azArg,    /* Text of data in all columns */
  char **azName    /* Names of the columns */
){
  int *pCount = (int*)pUser;
  int i;

  if( *pCount==0 ){
    for(i=0; i<nArg; i++){
      output_no_tabs(azName[i]);
      printf("%s", i<nArg-1 ? (zSep?zSep:"\t") : "\n");
    }
  }
  ++*pCount;
  for(i=0; i<nArg; i++){
    output_no_tabs(azArg[i]);
    printf("%s", i<nArg-1 ? (zSep?zSep:"\t") : "\n");
  }
  return 0;
}

/*
** COMMAND: ticket
** Usage: %fossil ticket SUBCOMMAND ...
**
** Run various subcommands to control tickets
**
**     %fossil ticket show REPORTNR ?TICKETUUID? ?-l|--limit LIMITCHAR?
**
**         Run the the ticket report, identified by the report number
**         used in the gui. The data is written as flat file on stdout,
**         using "," as separator. The seperator "," can be changed using
**         the -l or --limit option.
**         If TICKETUUID is given on the commandline, only this ticket
**         is shown, if the report delivers the uuid, otherwise the

**         argument is ignored.
**
**     %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








<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<





|





|
|
>
|







829
830
831
832
833
834
835
836


















































837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
      @ <li>Change %h(z) to "%h(blob_str(&val))"</li>
    }
    blob_reset(&val);
  }
  @ </ol>
}

/*


















































** COMMAND: ticket
** Usage: %fossil ticket SUBCOMMAND ...
**
** Run various subcommands to control tickets
**
**     %fossil ticket show REPORTNR ?TICKETFILTER? ?-l|--limit LIMITCHAR?
**
**         Run the the ticket report, identified by the report number
**         used in the gui. The data is written as flat file on stdout,
**         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
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
  }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;
        Stmt q;
        char *zSql;
        char *zTitle;
        char *zOwner;
        char *zClrKey;
        char *zErr1 = 0;
        char *zErr2 = 0;
        int count = 0;

        zSep = find_option("limit","l",1);

if( g.argc>4 ){
  fossil_fatal("show filter not implemented yet");
}

        rn = atoi(g.argv[3]);
        /* view_add_functions(tabs); */
        db_prepare(&q,
          "SELECT title, sqlcode, owner, cols FROM reportfmt WHERE rn=%d", rn);
        if( db_step(&q)!=SQLITE_ROW ){
          db_finalize(&q);
          fossil_fatal("unkown report format(%d)!",rn);

        }
        zTitle = db_column_malloc(&q, 0);
        zSql = db_column_malloc(&q, 1);
        zOwner = db_column_malloc(&q, 2);
        zClrKey = db_column_malloc(&q, 3);
        db_finalize(&q);
        count = 0;
        sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)&zErr1);
        sqlite3_exec(g.db, zSql, output_separated, &count, &zErr2);
        sqlite3_set_authorizer(g.db, 0, 0);
        cgi_set_content_type("text/plain");
      }
    }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");
    }
  }
}







<
|
|
<
<
<
<
<


>
|
|
|

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








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
  }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");
    }
  }
}