Overview
SHA1 Hash: | 695b1c756336a28bfb45f16e6efc49cee613a09c |
---|---|
Date: | 2009-04-29 03:51:02 |
User: | bch |
Comment: | test recycling "is_ticket()" from wikiformat.c as a way to avoid trying to checkout a ticket |
Timelines: | ancestors | descendants | both | fix artifact checkout |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- bgcolor=#ffaa22 inherited from [4fff366109]
- branch=fix artifact checkout inherited from [4fff366109]
- sym-fix artifact checkout inherited from [4fff366109]
Changes
[hide diffs]Modified src/checkout.c from [0c75447b9b] to [e9bf03b432].
@@ -44,18 +44,66 @@ vfile_check_signature(vid); return db_exists("SELECT 1 FROM vfile WHERE chnged" " OR coalesce(origname!=pathname,0)"); } + +/* +** zTarget is guaranteed to be a UUID. It might be the UUID of a ticket. +** If it is, store in *pClosed a true or false depending on whether or not +** the ticket is closed and return true. If zTarget +** is not the UUID of a ticket, return false. +*/ +static int is_ticket( + const char *zTarget, /* Ticket UUID */ + int *pClosed /* True if the ticket is closed */ +){ + static Stmt q; + static int once = 1; + int n; + int rc; + char zLower[UUID_SIZE+1]; + char zUpper[UUID_SIZE+1]; + n = strlen(zTarget); + memcpy(zLower, zTarget, n+1); + canonical16(zLower, n+1); + memcpy(zUpper, zLower, n+1); + zUpper[n-1]++; + if( once ){ + const char *zClosedExpr = db_get("ticket-closed-expr", "status='Closed'"); + db_static_prepare(&q, + "SELECT %s FROM ticket " + " WHERE tkt_uuid>=:lwr AND tkt_uuid<:upr", + zClosedExpr + ); + once = 0; + } + db_bind_text(&q, ":lwr", zLower); + db_bind_text(&q, ":upr", zUpper); + if( db_step(&q)==SQLITE_ROW ){ + rc = 1; + *pClosed = db_column_int(&q, 0); + }else{ + rc = 0; + } + db_reset(&q); + return rc; +} + /* ** Check to see if the requested co is in fact "checkout-able" ** Return values: ** 0: Not checkout-able (does not exist, or is not an on-disk artifact) ** 1: Is checkout-able. */ int checkoutable(const char *zName){ - int rc=1; /* assuming is checkout-able */ + int rc; /* return code */ + int throwaway; + + rc = !is_ticket(zName, &throwaway); + return(rc); + Blob uuid; const char *rid=(char *)NULL; Stmt q; // db query char *zSQL; //build-up sql