Fossil

Artifact [ea997f95]
Login

Artifact [ea997f95]

Artifact ea997f95e764be7af9f12adde5cbd05532c3d7d4:

Attachment "fossil-uuid-override.patch" to ticket [c2efdd64] added by rmax 2012-08-07 15:25:49.
Index: src/tkt.c
==================================================================
--- src/tkt.c
+++ src/tkt.c
@@ -923,10 +923,11 @@
 */
 void ticket_cmd(void){
   int n;
   const char *zUser;
   const char *zDate;
+  const char *zTktUuid;
 
   /* do some ints, we want to be inside a checkout */
   db_find_and_open_repository(0, 0);
   user_select();
 
@@ -933,10 +934,14 @@
   zUser = find_option("user-override",0,1);
   if( zUser==0 ) zUser = g.zLogin;
   zDate = find_option("date-override",0,1);
   if( zDate==0 ) zDate = "now";
   zDate = date_in_standard_format(zDate);
+  zTktUuid = find_option("uuid-override",0,1);
+  if ( zTktUuid && strlen(zTktUuid) != UUID_SIZE ) {
+      fossil_fatal("UUID must have exacly %d characters.\n", UUID_SIZE);
+  }
 
   /*
   ** Check that the user exists.
   */
   if( !db_exists("SELECT 1 FROM user WHERE login=%Q", zUser) ){
@@ -997,11 +1002,10 @@
     }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 ){
@@ -1021,11 +1025,11 @@
         }
         i=4;
       }else if( strncmp(g.argv[2],"add",n)==0 ){
         eCmd = add;
         i = 3;
-        zTktUuid = db_text(0, "SELECT lower(hex(randomblob(20)))");
+        if ( !zTktUuid ) 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");
       }