1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
|
*/
void tkthistory_page(void){
Stmt q;
char *zTitle;
const char *zUuid;
int tagid;
int nChng = 0;
login_check_credentials();
if( !g.perm.Hyperlink || !g.perm.RdTkt ){
login_needed(g.anon.Hyperlink && g.anon.RdTkt);
return;
}
zUuid = PD("name","");
|
>
|
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
|
*/
void tkthistory_page(void){
Stmt q;
char *zTitle;
const char *zUuid;
int tagid;
int nChng = 0;
Blob *aLastVal = 0;
login_check_credentials();
if( !g.perm.Hyperlink || !g.perm.RdTkt ){
login_needed(g.anon.Hyperlink && g.anon.RdTkt);
return;
}
zUuid = PD("name","");
|
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
|
style_finish_page();
return;
}
if( P("raw")!=0 ){
@ <h2>Raw Artifacts Associated With Ticket %h(zUuid)</h2>
}else{
@ <h2>Artifacts Associated With Ticket %h(zUuid)</h2>
}
db_prepare(&q,
"SELECT datetime(mtime,toLocal()), objid, uuid, NULL, NULL, NULL"
" FROM event, blob"
" WHERE objid IN (SELECT rid FROM tagxref WHERE tagid=%d)"
" AND blob.rid=event.objid"
" UNION "
|
>
>
|
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
|
style_finish_page();
return;
}
if( P("raw")!=0 ){
@ <h2>Raw Artifacts Associated With Ticket %h(zUuid)</h2>
}else{
@ <h2>Artifacts Associated With Ticket %h(zUuid)</h2>
getAllTicketFields();
aLastVal = blobarray_new(nField);
}
db_prepare(&q,
"SELECT datetime(mtime,toLocal()), objid, uuid, NULL, NULL, NULL"
" FROM event, blob"
" WHERE objid IN (SELECT rid FROM tagxref WHERE tagid=%d)"
" AND blob.rid=event.objid"
" UNION "
|
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
|
Blob c;
content_get(rid, &c);
@ <blockquote><pre>
@ %h(blob_str(&c))
@ </pre></blockquote>
blob_reset(&c);
}else{
ticket_output_change_artifact(pTicket, "a", nChng);
}
}
manifest_destroy(pTicket);
}
@ </li>
}
db_finalize(&q);
if( nChng ){
@ </ol>
}
style_finish_page();
}
/*
** Return TRUE if the given BLOB contains a newline character.
*/
static int contains_newline(Blob *p){
const char *z = blob_str(p);
|
|
>
|
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
|
Blob c;
content_get(rid, &c);
@ <blockquote><pre>
@ %h(blob_str(&c))
@ </pre></blockquote>
blob_reset(&c);
}else{
ticket_output_change_artifact(pTicket, "a", nChng, aLastVal);
}
}
manifest_destroy(pTicket);
}
@ </li>
}
db_finalize(&q);
if( nChng ){
@ </ol>
}
style_finish_page();
if( aLastVal ) blobarray_delete(aLastVal, nField);
}
/*
** Return TRUE if the given BLOB contains a newline character.
*/
static int contains_newline(Blob *p){
const char *z = blob_str(p);
|
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
|
/*
** The pTkt object is a ticket change artifact. Output a detailed
** description of this object.
*/
void ticket_output_change_artifact(
Manifest *pTkt, /* Parsed artifact for the ticket change */
const char *zListType, /* Which type of list */
int n /* Which ticket change is this */
){
int i;
if( zListType==0 ) zListType = "1";
getAllTicketFields();
@ <ol type="%s(zListType)">
for(i=0; i<pTkt->nField; i++){
Blob val;
const char *z, *zX;
int id;
z = pTkt->aField[i].zName;
blob_set(&val, pTkt->aField[i].zValue);
zX = z[0]=='+' ? z+1 : z;
id = fieldId(zX);
@ <li>\
if( id<0 ){
@ Untracked field %h(zX):
}else if( aField[id].mUsed==USEDBY_TICKETCHNG ){
@ %h(zX):
}else if( n==0 ){
@ %h(zX) initialized to:
}else if( z[0]=='+' && (aField[id].mUsed&USEDBY_TICKET)!=0 ){
@ Appended to %h(zX):
}else{
@ %h(zX) changed to:
}
if( blob_size(&val)>50 || contains_newline(&val) ){
@ <blockquote><pre class='verbatim'>
@ %h(blob_str(&val))
@ </pre></blockquote></li>
}else{
@ "%h(blob_str(&val))"</li>
}
blob_reset(&val);
}
@ </ol>
}
/*
** COMMAND: ticket*
**
|
|
>
<
<
<
|
<
|
|
>
>
>
>
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
|
|
|
|
>
>
>
|
|
>
>
>
>
|
>
>
>
>
>
>
>
>
>
|
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
|
/*
** The pTkt object is a ticket change artifact. Output a detailed
** description of this object.
*/
void ticket_output_change_artifact(
Manifest *pTkt, /* Parsed artifact for the ticket change */
const char *zListType, /* Which type of list */
int n, /* Which ticket change is this */
Blob *aLastVal /* Array of latest values for the diffs */
){
int i;
if( zListType==0 ) zListType = "1";
getAllTicketFields();
@ <ol type="%s(zListType)">
for(i=0; i<pTkt->nField; i++){
const char *z = pTkt->aField[i].zName;
const char *zX = z[0]=='+' ? z+1 : z;
const int id = fieldId(zX);
const char *zValue = pTkt->aField[i].zValue;
const size_t nValue = strlen(zValue);
const int bLong = nValue>50 || memchr(zValue,'\n',nValue)!=NULL;
const int bCanDiff = aLastVal && id>=0 && aField[id].zBsln;
int bAppend = 0, bRegular = 0;
@ <li>\
if( id<0 ){
@ Untracked field %h(zX):
}else if( aField[id].mUsed==USEDBY_TICKETCHNG ){
@ %h(zX):
}else if( n==0 ){
@ %h(zX) initialized to:
}else if( z[0]=='+' && (aField[id].mUsed&USEDBY_TICKET)!=0 ){
@ Appended to %h(zX):
bAppend = 1;
}else{
if( !bCanDiff ){
@ %h(zX) changed to: \
}
bRegular = 1;
}
if( bCanDiff ){
Blob *prev = aLastVal+id;
Blob val = BLOB_INITIALIZER;
if( nValue ){
blob_init(&val, zValue, nValue+1);
val.nUsed--; /* makes blob_str() faster */
}
if( bRegular && nValue && blob_buffer(prev) && blob_size(prev) ){
Blob d = BLOB_INITIALIZER;
DiffConfig DCfg;
construct_diff_flags(1, &DCfg);
DCfg.diffFlags |= DIFF_HTML | DIFF_LINENO;
text_diff(prev, &val, &d, &DCfg);
@ %h(zX) changed as:
@ %s(blob_str(&d))
@ </li>
blob_reset(&d);
}else if( bLong ){
if( bRegular ){
@ %h(zX) changed to:
}
@ <blockquote><pre class='verbatim'>
@ %h(zValue)
@ </pre></blockquote></li>
}else{
if( bRegular ){
@ %h(zX) changed to: \
}
@ "%h(zValue)"</li>
}
if( blob_buffer(prev) && blob_size(prev) && !bAppend ){
blob_truncate(prev,0);
}
if( nValue ) blob_appendb(prev, &val);
blob_reset(&val);
}else{
if( bLong ){
@ <blockquote><pre class='verbatim'>
@ %h(zValue)
@ </pre></blockquote></li>
}else{
@ "%h(zValue)"</li>
}
}
}
@ </ol>
}
/*
** COMMAND: ticket*
**
|