Fossil SCM

Add the --uuid-override option to the "fossil ticket add" command. Ticket [c2efdd64bff166c3]

drh 2012-08-08 13:13 trunk
Commit 294cddf3ba6bc43fa024b82adbcc8250a51e497f
1 file changed +8 -2
+8 -2
--- src/tkt.c
+++ src/tkt.c
@@ -923,10 +923,11 @@
923923
*/
924924
void ticket_cmd(void){
925925
int n;
926926
const char *zUser;
927927
const char *zDate;
928
+ const char *zTktUuid;
928929
929930
/* do some ints, we want to be inside a checkout */
930931
db_find_and_open_repository(0, 0);
931932
user_select();
932933
@@ -933,10 +934,14 @@
933934
zUser = find_option("user-override",0,1);
934935
if( zUser==0 ) zUser = g.zLogin;
935936
zDate = find_option("date-override",0,1);
936937
if( zDate==0 ) zDate = "now";
937938
zDate = date_in_standard_format(zDate);
939
+ zTktUuid = find_option("uuid-override",0,1);
940
+ if( zTktUuid && (strlen(zTktUuid)!=40 || !validate16(zTktUuid,40)) ){
941
+ fossil_fatal("invalid --uuid-override: must be 40 characters of hex");
942
+ }
938943
939944
/*
940945
** Check that the user exists.
941946
*/
942947
if( !db_exists("SELECT 1 FROM user WHERE login=%Q", zUser) ){
@@ -997,11 +1002,10 @@
9971002
}else{
9981003
/* add a new ticket or update an existing ticket */
9991004
enum { set,add,history,err } eCmd = err;
10001005
int i = 0;
10011006
int rid;
1002
- const char *zTktUuid = 0;
10031007
Blob tktchng, cksum;
10041008
10051009
/* get command type (set/add) and get uuid, if needed for set */
10061010
if( strncmp(g.argv[2],"set",n)==0 || strncmp(g.argv[2],"change",n)==0 ||
10071011
strncmp(g.argv[2],"history",n)==0 ){
@@ -1021,11 +1025,13 @@
10211025
}
10221026
i=4;
10231027
}else if( strncmp(g.argv[2],"add",n)==0 ){
10241028
eCmd = add;
10251029
i = 3;
1026
- zTktUuid = db_text(0, "SELECT lower(hex(randomblob(20)))");
1030
+ if( zTktUuid==0 ){
1031
+ zTktUuid = db_text(0, "SELECT lower(hex(randomblob(20)))");
1032
+ }
10271033
}
10281034
/* none of set/add, so show the usage! */
10291035
if( eCmd==err ){
10301036
usage("add|fieldlist|set|show|history");
10311037
}
10321038
--- src/tkt.c
+++ src/tkt.c
@@ -923,10 +923,11 @@
923 */
924 void ticket_cmd(void){
925 int n;
926 const char *zUser;
927 const char *zDate;
 
928
929 /* do some ints, we want to be inside a checkout */
930 db_find_and_open_repository(0, 0);
931 user_select();
932
@@ -933,10 +934,14 @@
933 zUser = find_option("user-override",0,1);
934 if( zUser==0 ) zUser = g.zLogin;
935 zDate = find_option("date-override",0,1);
936 if( zDate==0 ) zDate = "now";
937 zDate = date_in_standard_format(zDate);
 
 
 
 
938
939 /*
940 ** Check that the user exists.
941 */
942 if( !db_exists("SELECT 1 FROM user WHERE login=%Q", zUser) ){
@@ -997,11 +1002,10 @@
997 }else{
998 /* add a new ticket or update an existing ticket */
999 enum { set,add,history,err } eCmd = err;
1000 int i = 0;
1001 int rid;
1002 const char *zTktUuid = 0;
1003 Blob tktchng, cksum;
1004
1005 /* get command type (set/add) and get uuid, if needed for set */
1006 if( strncmp(g.argv[2],"set",n)==0 || strncmp(g.argv[2],"change",n)==0 ||
1007 strncmp(g.argv[2],"history",n)==0 ){
@@ -1021,11 +1025,13 @@
1021 }
1022 i=4;
1023 }else if( strncmp(g.argv[2],"add",n)==0 ){
1024 eCmd = add;
1025 i = 3;
1026 zTktUuid = db_text(0, "SELECT lower(hex(randomblob(20)))");
 
 
1027 }
1028 /* none of set/add, so show the usage! */
1029 if( eCmd==err ){
1030 usage("add|fieldlist|set|show|history");
1031 }
1032
--- src/tkt.c
+++ src/tkt.c
@@ -923,10 +923,11 @@
923 */
924 void ticket_cmd(void){
925 int n;
926 const char *zUser;
927 const char *zDate;
928 const char *zTktUuid;
929
930 /* do some ints, we want to be inside a checkout */
931 db_find_and_open_repository(0, 0);
932 user_select();
933
@@ -933,10 +934,14 @@
934 zUser = find_option("user-override",0,1);
935 if( zUser==0 ) zUser = g.zLogin;
936 zDate = find_option("date-override",0,1);
937 if( zDate==0 ) zDate = "now";
938 zDate = date_in_standard_format(zDate);
939 zTktUuid = find_option("uuid-override",0,1);
940 if( zTktUuid && (strlen(zTktUuid)!=40 || !validate16(zTktUuid,40)) ){
941 fossil_fatal("invalid --uuid-override: must be 40 characters of hex");
942 }
943
944 /*
945 ** Check that the user exists.
946 */
947 if( !db_exists("SELECT 1 FROM user WHERE login=%Q", zUser) ){
@@ -997,11 +1002,10 @@
1002 }else{
1003 /* add a new ticket or update an existing ticket */
1004 enum { set,add,history,err } eCmd = err;
1005 int i = 0;
1006 int rid;
 
1007 Blob tktchng, cksum;
1008
1009 /* get command type (set/add) and get uuid, if needed for set */
1010 if( strncmp(g.argv[2],"set",n)==0 || strncmp(g.argv[2],"change",n)==0 ||
1011 strncmp(g.argv[2],"history",n)==0 ){
@@ -1021,11 +1025,13 @@
1025 }
1026 i=4;
1027 }else if( strncmp(g.argv[2],"add",n)==0 ){
1028 eCmd = add;
1029 i = 3;
1030 if( zTktUuid==0 ){
1031 zTktUuid = db_text(0, "SELECT lower(hex(randomblob(20)))");
1032 }
1033 }
1034 /* none of set/add, so show the usage! */
1035 if( eCmd==err ){
1036 usage("add|fieldlist|set|show|history");
1037 }
1038

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button