Fossil SCM

Bug fixes in the TICKETCHNG update mechanism.

drh 2012-11-24 23:54 UTC ticket-enhancements
Commit 7136ff4c65754f081adc86139ae68c5569183c5d
1 file changed +13 -8
+13 -8
--- src/tkt.c
+++ src/tkt.c
@@ -194,11 +194,10 @@
194194
*/
195195
static int ticket_insert(const Manifest *p, int rid, int tktid){
196196
Blob sql1, sql2, sql3;
197197
Stmt q;
198198
int i, j;
199
- const char *zSep = "(";
200199
201200
if( tktid==0 ){
202201
db_multi_exec("INSERT INTO ticket(tkt_uuid, tkt_mtime) "
203202
"VALUES(%Q, 0)", p->zTicketUuid);
204203
tktid = db_last_insert_rowid();
@@ -216,16 +215,17 @@
216215
blob_appendf(&sql1,", %s=coalesce(%s,'') || %Q",
217216
zName, zName, p->aField[i].zValue);
218217
}
219218
}else{
220219
if( (j = fieldId(zName))<0 ) continue;
221
- blob_appendf(&sql1,", %s=%Q", zName, p->aField[i].zValue);
220
+ if( aField[j].mUsed & USEDBY_TICKET ){
221
+ blob_appendf(&sql1,", %s=%Q", zName, p->aField[i].zValue);
222
+ }
222223
}
223224
if( aField[j].mUsed & USEDBY_TICKETCHNG ){
224
- blob_appendf(&sql2, "%s%s", zSep, zName);
225
- blob_appendf(&sql3, "%s%Q", p->aField[i].zValue);
226
- zSep = ",";
225
+ blob_appendf(&sql2, ",%s", zName);
226
+ blob_appendf(&sql3, ",%Q", p->aField[i].zValue);
227227
}
228228
if( rid>0 ){
229229
wiki_extract_links(p->aField[i].zValue, rid, 1, p->rDate, i==0, 0);
230230
}
231231
}
@@ -234,12 +234,16 @@
234234
db_bind_double(&q, ":mtime", p->rDate);
235235
db_step(&q);
236236
db_finalize(&q);
237237
blob_reset(&sql1);
238238
if( blob_size(&sql2)>0 ){
239
- db_multi_exec("INSERT INTO ticketchng %s) VALUES %s)",
240
- blob_str(&sql2), blob_str(&sql3));
239
+ db_prepare(&q, "INSERT INTO ticketchng(tkt_id,tkt_mtime%s)"
240
+ "VALUES(%d,:mtime%s)",
241
+ blob_str(&sql2), tktid, blob_str(&sql3));
242
+ db_bind_double(&q, ":mtime", p->rDate);
243
+ db_step(&q);
244
+ db_finalize(&q);
241245
}
242246
blob_reset(&sql2);
243247
blob_reset(&sql3);
244248
return tktid;
245249
}
@@ -508,11 +512,12 @@
508512
int nValue;
509513
if( aField[i].zAppend ) continue;
510514
zValue = Th_Fetch(aField[i].zName, &nValue);
511515
if( zValue ){
512516
while( nValue>0 && fossil_isspace(zValue[nValue-1]) ){ nValue--; }
513
- if( memcmp(zValue, aField[i].zValue, nValue)!=0
517
+ if( ((aField[i].mUsed & USEDBY_TICKETCHNG)!=0 && nValue>0)
518
+ || memcmp(zValue, aField[i].zValue, nValue)!=0
514519
|| strlen(aField[i].zValue)!=nValue
515520
){
516521
if( memcmp(aField[i].zName, "private_", 8)==0 ){
517522
zValue = db_conceal(zValue, nValue);
518523
blob_appendf(&tktchng, "J %s %s\n", aField[i].zName, zValue);
519524
--- src/tkt.c
+++ src/tkt.c
@@ -194,11 +194,10 @@
194 */
195 static int ticket_insert(const Manifest *p, int rid, int tktid){
196 Blob sql1, sql2, sql3;
197 Stmt q;
198 int i, j;
199 const char *zSep = "(";
200
201 if( tktid==0 ){
202 db_multi_exec("INSERT INTO ticket(tkt_uuid, tkt_mtime) "
203 "VALUES(%Q, 0)", p->zTicketUuid);
204 tktid = db_last_insert_rowid();
@@ -216,16 +215,17 @@
216 blob_appendf(&sql1,", %s=coalesce(%s,'') || %Q",
217 zName, zName, p->aField[i].zValue);
218 }
219 }else{
220 if( (j = fieldId(zName))<0 ) continue;
221 blob_appendf(&sql1,", %s=%Q", zName, p->aField[i].zValue);
 
 
222 }
223 if( aField[j].mUsed & USEDBY_TICKETCHNG ){
224 blob_appendf(&sql2, "%s%s", zSep, zName);
225 blob_appendf(&sql3, "%s%Q", p->aField[i].zValue);
226 zSep = ",";
227 }
228 if( rid>0 ){
229 wiki_extract_links(p->aField[i].zValue, rid, 1, p->rDate, i==0, 0);
230 }
231 }
@@ -234,12 +234,16 @@
234 db_bind_double(&q, ":mtime", p->rDate);
235 db_step(&q);
236 db_finalize(&q);
237 blob_reset(&sql1);
238 if( blob_size(&sql2)>0 ){
239 db_multi_exec("INSERT INTO ticketchng %s) VALUES %s)",
240 blob_str(&sql2), blob_str(&sql3));
 
 
 
 
241 }
242 blob_reset(&sql2);
243 blob_reset(&sql3);
244 return tktid;
245 }
@@ -508,11 +512,12 @@
508 int nValue;
509 if( aField[i].zAppend ) continue;
510 zValue = Th_Fetch(aField[i].zName, &nValue);
511 if( zValue ){
512 while( nValue>0 && fossil_isspace(zValue[nValue-1]) ){ nValue--; }
513 if( memcmp(zValue, aField[i].zValue, nValue)!=0
 
514 || strlen(aField[i].zValue)!=nValue
515 ){
516 if( memcmp(aField[i].zName, "private_", 8)==0 ){
517 zValue = db_conceal(zValue, nValue);
518 blob_appendf(&tktchng, "J %s %s\n", aField[i].zName, zValue);
519
--- src/tkt.c
+++ src/tkt.c
@@ -194,11 +194,10 @@
194 */
195 static int ticket_insert(const Manifest *p, int rid, int tktid){
196 Blob sql1, sql2, sql3;
197 Stmt q;
198 int i, j;
 
199
200 if( tktid==0 ){
201 db_multi_exec("INSERT INTO ticket(tkt_uuid, tkt_mtime) "
202 "VALUES(%Q, 0)", p->zTicketUuid);
203 tktid = db_last_insert_rowid();
@@ -216,16 +215,17 @@
215 blob_appendf(&sql1,", %s=coalesce(%s,'') || %Q",
216 zName, zName, p->aField[i].zValue);
217 }
218 }else{
219 if( (j = fieldId(zName))<0 ) continue;
220 if( aField[j].mUsed & USEDBY_TICKET ){
221 blob_appendf(&sql1,", %s=%Q", zName, p->aField[i].zValue);
222 }
223 }
224 if( aField[j].mUsed & USEDBY_TICKETCHNG ){
225 blob_appendf(&sql2, ",%s", zName);
226 blob_appendf(&sql3, ",%Q", p->aField[i].zValue);
 
227 }
228 if( rid>0 ){
229 wiki_extract_links(p->aField[i].zValue, rid, 1, p->rDate, i==0, 0);
230 }
231 }
@@ -234,12 +234,16 @@
234 db_bind_double(&q, ":mtime", p->rDate);
235 db_step(&q);
236 db_finalize(&q);
237 blob_reset(&sql1);
238 if( blob_size(&sql2)>0 ){
239 db_prepare(&q, "INSERT INTO ticketchng(tkt_id,tkt_mtime%s)"
240 "VALUES(%d,:mtime%s)",
241 blob_str(&sql2), tktid, blob_str(&sql3));
242 db_bind_double(&q, ":mtime", p->rDate);
243 db_step(&q);
244 db_finalize(&q);
245 }
246 blob_reset(&sql2);
247 blob_reset(&sql3);
248 return tktid;
249 }
@@ -508,11 +512,12 @@
512 int nValue;
513 if( aField[i].zAppend ) continue;
514 zValue = Th_Fetch(aField[i].zName, &nValue);
515 if( zValue ){
516 while( nValue>0 && fossil_isspace(zValue[nValue-1]) ){ nValue--; }
517 if( ((aField[i].mUsed & USEDBY_TICKETCHNG)!=0 && nValue>0)
518 || memcmp(zValue, aField[i].zValue, nValue)!=0
519 || strlen(aField[i].zValue)!=nValue
520 ){
521 if( memcmp(aField[i].zName, "private_", 8)==0 ){
522 zValue = db_conceal(zValue, nValue);
523 blob_appendf(&tktchng, "J %s %s\n", aField[i].zName, zValue);
524

Keyboard Shortcuts

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