Changes On Branch fix artifact checkout
Not logged in

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

Changes In Branch fix artifact checkout Excluding Merge-Ins

This is equivalent to a diff from 879e8c5f32 to 5d49162a31

2009-04-29
03:59
checkpoints for the is_ticket() function Leaf check-in: 5d49162a31 user: bch tags: fix artifact checkout
03:51
test recycling "is_ticket()" from wikiformat.c as a way to avoid trying to checkout a ticket check-in: 695b1c7563 user: bch tags: fix artifact checkout
2009-04-24
18:40
There is some bug in the new HTTP transport layer. The easiest solution is to close the TCP connection after each round trip, which is what this check-in does. check-in: 767ae79c3d user: drh tags: trunk
2009-04-19
05:48
branch, start committing hacking that will hopefully yield fix to this problem: one is allowed to checkout "artifacts" that should not be checkout-able (ie: changes to tickets); trying to check this out is permitted, but results in a segfault check-in: 4fff366109 user: bch tags: fix artifact checkout
2009-04-13
09:50
Update to version SQLite 3.6.13 check-in: 879e8c5f32 user: drh tags: trunk
2009-04-11
13:07
Actually get the "file:" transport working this time. check-in: a742cfa292 user: drh tags: trunk

Changes to src/checkout.c.

    41     41     db_must_be_within_tree();
    42     42     vid = db_lget_int("checkout",0);
    43     43     if( vid==0 ) return 2;
    44     44     vfile_check_signature(vid);
    45     45     return db_exists("SELECT 1 FROM vfile WHERE chnged"
    46     46                      " OR coalesce(origname!=pathname,0)");
    47     47   }
           48  +
           49  +
           50  +/*
           51  +** zTarget is guaranteed to be a UUID.  It might be the UUID of a ticket.
           52  +** If it is, store in *pClosed a true or false depending on whether or not
           53  +** the ticket is closed and return true. If zTarget
           54  +** is not the UUID of a ticket, return false.
           55  +*/
           56  +static int is_ticket(
           57  +  const char *zTarget,    /* Ticket UUID */
           58  +  int *pClosed            /* True if the ticket is closed */
           59  +){
           60  +  fprintf(stderr,"I'm in is_ticket\n");
           61  +
           62  +  static Stmt q;
           63  +  static int once = 1;
           64  +  int n;
           65  +  int rc;
           66  +  char zLower[UUID_SIZE+1];
           67  +  char zUpper[UUID_SIZE+1];
           68  +  n = strlen(zTarget);
           69  +  memcpy(zLower, zTarget, n+1);
           70  +  canonical16(zLower, n+1);
           71  +  memcpy(zUpper, zLower, n+1);
           72  +  zUpper[n-1]++;
           73  +  if( once ){
           74  +    const char *zClosedExpr = db_get("ticket-closed-expr", "status='Closed'");
           75  +    db_static_prepare(&q, 
           76  +      "SELECT %s FROM ticket "
           77  +      " WHERE tkt_uuid>=:lwr AND tkt_uuid<:upr",
           78  +      zClosedExpr
           79  +    );
           80  +    once = 0;
           81  +  }
           82  +  db_bind_text(&q, ":lwr", zLower);
           83  +  db_bind_text(&q, ":upr", zUpper);
           84  +  if( db_step(&q)==SQLITE_ROW ){
           85  +    rc = 1;
           86  +    *pClosed = db_column_int(&q, 0);
           87  +  }else{
           88  +    rc = 0;
           89  +  }
           90  +  db_reset(&q);
           91  +  return rc;
           92  +}
           93  +
           94  +/*
           95  +** Check to see if the requested co is in fact "checkout-able"
           96  +** Return values:
           97  +**   0: Not checkout-able (does not exist, or is not an on-disk artifact)
           98  +**   1: Is checkout-able.
           99  +*/
          100  +int checkoutable(const char *zName){
          101  +  int rc; /* return code */
          102  +  int throwaway;
          103  +
          104  +  rc = !is_ticket(zName, &throwaway);
          105  +  fprintf(stderr,"rc is: %d\n", rc);
          106  +  return(rc);
          107  +
          108  +  Blob uuid;
          109  +  const char *rid=(char *)NULL;
          110  +  Stmt q; // db query
          111  +  char *zSQL; //build-up sql
          112  +
          113  +  //  zSQL = mprintf();
          114  +
          115  +  // [create sql statement]
          116  +  // db_prepare(&q,sqlstmt);
          117  +
          118  +  blob_init(&uuid, zName, -1);
          119  +  if( name_to_uuid(&uuid, 1) ){
          120  +    fossil_panic(g.zErrMsg);
          121  +  }
          122  +
          123  +  /*  nParent=db_text(0,"select rid from blob where uuid=%s",uuid.nameofobj); */
          124  +
          125  +  /*  int nParent = db_column_int(q, somenum); */
          126  +  return rc;
          127  +}
          128  +
    48    129   
    49    130   /*
    50    131   ** Undo the current check-out.  Unlink all files from the disk.
    51    132   ** Clear the VFILE table.
    52    133   */
    53    134   void uncheckout(int vid){
    54    135     if( vid==0 ) return;
................................................................................
   155    236     db_begin_transaction();
   156    237     forceFlag = find_option("force","f",0)!=0;
   157    238     noWrite = find_option("dontwrite",0,0)!=0;
   158    239     if( g.argc!=3 ) usage("?--force? VERSION");
   159    240     if( !forceFlag && unsaved_changes()==1 ){
   160    241       fossil_fatal("there are unsaved changes in the current checkout");
   161    242     }
          243  +  if(!checkoutable(g.argv[2])){
          244  +    fossil_fatal("the VERSION you requested is not a checkout-able artifact");
          245  +  }
   162    246     if( forceFlag ){
   163    247       db_multi_exec("DELETE FROM vfile");
   164    248       prior = 0;
   165    249     }else{
   166    250       prior = db_lget_int("checkout",0);
   167    251     }
   168    252     vid = load_vfile(g.argv[2]);