Fossil

Check-in Differences
Login

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

Difference From 0dd5451d7f531a68 To b2049d643b6a3a3a

2022-09-20
14:13
On the [/help?cmd=/tkthistory|/tkthistory page] supply each ticket change item with a corresponding id attribute and make the 'History' button within a submenu of a [/help?cmd=/tinfo|/tinfo page] to link back to that particular element on the <code>/tkthistory</code> page. ... (check-in: 4bb91f38a8 user: george tags: deltify-tkt-blobs)
13:56
Minor optimization and refactoring. ... (check-in: b2049d643b user: george tags: deltify-tkt-blobs)
2022-09-15
13:40
Improve <code>/tkthistory</code> page: render selected ticket fields as unified diffs. ... (check-in: b75a9d0fa3 user: george tags: deltify-tkt-blobs)
2022-09-14
13:12
Remove redundant PRE tags on the <code>/wdiff</code> pages. ... (check-in: 0dd5451d7f user: george tags: deltify-tkt-blobs)
2022-08-29
14:27
Add a missing closing LI tag for the /tkthistory page. ... (check-in: 2d0b2bda87 user: george tags: deltify-tkt-blobs)

Changes to src/blob.c.

925
926
927
928
929
930
931



















932
933
934
935
936
937
938
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  int i;
  for(i=0; i<n; i++) blob_zero(&aBlob[i]);
}
void blobarray_reset(Blob *aBlob, int n){
  int i;
  for(i=0; i<n; i++) blob_reset(&aBlob[i]);
}
/*
** Allocate array of n blobs and initialize each element with `empty_blob`
*/
Blob* blobarray_new(int n){
  int i;
  Blob *aBlob = fossil_malloc(sizeof(Blob)*n);
  for(i=0; i<n; i++) aBlob[i] = empty_blob;
  return aBlob;
}
/*
** Free array of n blobs some of which may be empty (have NULL buffer)
*/
void blobarray_delete(Blob *aBlob, int n){
  int i;
  for(i=0; i<n; i++){
    if( blob_buffer(aBlob+i) ) blob_reset(aBlob+i);
  }
  fossil_free(aBlob);
}

/*
** Parse a blob into space-separated tokens.  Store each token in
** an element of the blobarray aToken[].  aToken[] is nToken elements in
** size.  Return the number of tokens seen.
*/
int blob_tokenize(Blob *pIn, Blob *aToken, int nToken){

Changes to src/default.css.

701
702
703
704
705
706
707



708

709
710
711
712
713
714
715
701
702
703
704
705
706
707
708
709
710

711
712
713
714
715
716
717
718







+
+
+
-
+







  font-weight: bold;
}
td.difftxt ins > ins.edit {
  background-color: #c0c0ff;
  text-decoration: none;
  font-weight: bold;
}
body.tkt div.content li > table.udiff {
  margin-left: 1.5em;
  margin-top: 0.5em;

}

span.modpending {
  color: #b03800;
  font-style: italic;
}
pre.th1result {
  white-space: pre-wrap;

Changes to src/info.c.

2826
2827
2828
2829
2830
2831
2832
2833

2834
2835
2836
2837
2838
2839
2840
2826
2827
2828
2829
2830
2831
2832

2833
2834
2835
2836
2837
2838
2839
2840







-
+







    @ <input type="submit" value="Submit">
    @ </form>
    @ </blockquote>
  }

  @ <div class="section">Changes</div>
  @ <p>
  ticket_output_change_artifact(pTktChng, 0, 1);
  ticket_output_change_artifact(pTktChng, 0, 1, 0);
  manifest_destroy(pTktChng);
  style_finish_page();
}


/*
** WEBPAGE: info

Changes to src/tkt.c.

1202
1203
1204
1205
1206
1207
1208

1209
1210
1211
1212
1213
1214
1215
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
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249







+
+
+
+







    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();
    if( nTicketBslns ){
      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
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
1317
1318







-
+











+







          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);
          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
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
1414







-
+
+






-
-
-
-
+
-
-
-
+
+
+
+
+
+
+









+

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







/*
** 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 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++){
    Blob val;
    const char *z, *zX;
    int id;
    z = pTkt->aField[i].zName;
    const char *z  = pTkt->aField[i].zName;
    blob_set(&val, pTkt->aField[i].zValue);
    zX = z[0]=='+' ? z+1 : z;
    id = fieldId(zX);
    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( bRegular ){
      @ %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);
          @ %h(zX) changed to:
        }
        if( bLong ){
          @ <blockquote><pre class='verbatim'>
          @ %h(zValue)
          @ </pre></blockquote></li>
        }else{
          @ "%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*
**