Fossil

Check-in [70365348]
Login

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

Overview
Comment:Always show diffs for added and deleted files in the web UI. Show added and deleted files in diffs with -N and the --from and --to options to the command-line diff command. Ticket [e90d38c2054e9b44792]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:703653489ee450dad4ddac0c010f03d343ff32a2
User & Date: drh 2010-10-14 20:28:49
References
2010-10-15
11:28 Ticket [c8c0b78c] Windows 7: "fossil ui" and "fossil server" fail status still Open with 2 other changes artifact: 0846b17d user: anonymous
Context
2010-10-15
13:55
On commit, check the repository for changes before starting the write transaction, so that a diff can be run during the check-in comment editing. Ticket [014ac374123d9a6ab6894]. check-in: 59f68585 user: drh tags: trunk
2010-10-14
20:28
Always show diffs for added and deleted files in the web UI. Show added and deleted files in diffs with -N and the --from and --to options to the command-line diff command. Ticket [e90d38c2054e9b44792] check-in: 70365348 user: drh tags: trunk
19:48
Reverse the direction of conflict markers. Ticket [e3a1beef67c97eb2e4d5a] check-in: 93984e2d user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/diffcmd.c.

310
311
312
313
314
315
316
































317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345



346
347
348



349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
  historical_version_of_file(zFrom, zName, &v1, 0);
  historical_version_of_file(zTo, zName, &v2, 0);
  diff_file_mem(&v1, &v2, zName, zDiffCmd, ignoreEolWs);
  blob_reset(&v1);
  blob_reset(&v2);
  blob_reset(&fname);
}

































/*
** Output the differences between two check-ins.
*/
static void diff_all_two_versions(
  const char *zFrom,
  const char *zTo,
  const char *zDiffCmd,
  int diffFlags
){
  Manifest mFrom, mTo;
  int iFrom, iTo;
  int ignoreEolWs = (diffFlags & DIFF_NOEOLWS)!=0 ? 1 : 0;
  /* int asNewFlag = (diffFlags & DIFF_NEWFILE)!=0 ? 1 : 0; */

  manifest_from_name(zFrom, &mFrom);
  manifest_from_name(zTo, &mTo);
  iFrom = iTo = 0;
  while( iFrom<mFrom.nFile && iTo<mTo.nFile ){
    int cmp;
    if( iFrom>=mFrom.nFile ){
      cmp = +1;
    }else if( iTo>=mTo.nFile ){
      cmp = -1;
    }else{
      cmp = strcmp(mFrom.aFile[iFrom].zName, mTo.aFile[iTo].zName);
    }
    if( cmp<0 ){
      printf("DELETED %s\n", mFrom.aFile[iFrom].zName);



      iFrom++;
    }else if( cmp>0 ){
      printf("ADDED   %s\n", mTo.aFile[iTo].zName);



      iTo++;
    }else if( strcmp(mFrom.aFile[iFrom].zUuid, mTo.aFile[iTo].zUuid)==0 ){
      /* No changes */
      iFrom++;
      iTo++;
    }else{
      Blob f1, f2;
      int rid;
      printf("CHANGED %s\n", mFrom.aFile[iFrom].zName);
      printf("Index: %s\n======================================="
             "============================\n",
             mFrom.aFile[iFrom].zName
      );
      rid = uuid_to_rid(mFrom.aFile[iFrom].zUuid, 0);
      content_get(rid, &f1);
      rid = uuid_to_rid(mTo.aFile[iTo].zUuid, 0);
      content_get(rid, &f2);
      diff_file_mem(&f1, &f2, mFrom.aFile[iFrom].zName, zDiffCmd, ignoreEolWs);
      blob_reset(&f1);
      blob_reset(&f2);
      iFrom++;
      iTo++;
    }
  }
  manifest_clear(&mFrom);
  manifest_clear(&mTo);
}







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>













|




|










>
>
>



>
>
>






<
<

<
<
|
<
<
<
<
<
|
<
<







310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392


393


394





395


396
397
398
399
400
401
402
  historical_version_of_file(zFrom, zName, &v1, 0);
  historical_version_of_file(zTo, zName, &v2, 0);
  diff_file_mem(&v1, &v2, zName, zDiffCmd, ignoreEolWs);
  blob_reset(&v1);
  blob_reset(&v2);
  blob_reset(&fname);
}

/*
** Show the difference between two files identified by ManifestFile
** entries.
*/
static void diff_manifest_entry(
  struct ManifestFile *pFrom,
  struct ManifestFile *pTo,
  const char *zDiffCmd,
  int ignoreEolWs
){
  Blob f1, f2;
  int rid;
  const char *zName =  pFrom ? pFrom->zName : pTo->zName;
  printf("Index: %s\n======================================="
         "============================\n", zName);
  if( pFrom ){
    rid = uuid_to_rid(pFrom->zUuid, 0);
    content_get(rid, &f1);
  }else{
    blob_zero(&f1);
  }
  if( pTo ){
    rid = uuid_to_rid(pTo->zUuid, 0);
    content_get(rid, &f2);
  }else{
    blob_zero(&f2);
  }
  diff_file_mem(&f1, &f2, zName, zDiffCmd, ignoreEolWs);
  blob_reset(&f1);
  blob_reset(&f2);
}

/*
** Output the differences between two check-ins.
*/
static void diff_all_two_versions(
  const char *zFrom,
  const char *zTo,
  const char *zDiffCmd,
  int diffFlags
){
  Manifest mFrom, mTo;
  int iFrom, iTo;
  int ignoreEolWs = (diffFlags & DIFF_NOEOLWS)!=0 ? 1 : 0;
  int asNewFlag = (diffFlags & DIFF_NEWFILE)!=0 ? 1 : 0;

  manifest_from_name(zFrom, &mFrom);
  manifest_from_name(zTo, &mTo);
  iFrom = iTo = 0;
  while( iFrom<mFrom.nFile || iTo<mTo.nFile ){
    int cmp;
    if( iFrom>=mFrom.nFile ){
      cmp = +1;
    }else if( iTo>=mTo.nFile ){
      cmp = -1;
    }else{
      cmp = strcmp(mFrom.aFile[iFrom].zName, mTo.aFile[iTo].zName);
    }
    if( cmp<0 ){
      printf("DELETED %s\n", mFrom.aFile[iFrom].zName);
      if( asNewFlag ){
        diff_manifest_entry(&mFrom.aFile[iFrom], 0, zDiffCmd, ignoreEolWs);
      }
      iFrom++;
    }else if( cmp>0 ){
      printf("ADDED   %s\n", mTo.aFile[iTo].zName);
      if( asNewFlag ){
        diff_manifest_entry(0, &mTo.aFile[iTo], zDiffCmd, ignoreEolWs);
      }
      iTo++;
    }else if( strcmp(mFrom.aFile[iFrom].zUuid, mTo.aFile[iTo].zUuid)==0 ){
      /* No changes */
      iFrom++;
      iTo++;
    }else{


      printf("CHANGED %s\n", mFrom.aFile[iFrom].zName);


      diff_manifest_entry(&mFrom.aFile[iFrom], &mTo.aFile[iTo],





                          zDiffCmd, ignoreEolWs);


      iFrom++;
      iTo++;
    }
  }
  manifest_clear(&mFrom);
  manifest_clear(&mTo);
}

Changes to src/info.c.

232
233
234
235
236
237
238
239


240


241





242



243
244
245
246
247
248
249
...
261
262
263
264
265
266
267

268
269
270
271
272
273
274
275

276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296










297
298
299
300
301
302
303
  }
}


/*
** Append the difference between two RIDs to the output
*/
static void append_diff(int fromid, int toid){


  Blob from, to, out;


  content_get(fromid, &from);





  content_get(toid, &to);



  blob_zero(&out);
  text_diff(&from, &to, &out, 5, 1);
  @ %h(blob_str(&out))
  blob_reset(&from);
  blob_reset(&to);
  blob_reset(&out);  
}
................................................................................
  if( !g.okHistory ){
    if( zNew==0 ){
      @ <p>Deleted %h(zName)</p>
    }else if( zOld==0 ){
      @ <p>Added %h(zName)</p>
    }else{
      @ <p>Changes to %h(zName)</p>

      if( showDiff ){
        int rid1 = uuid_to_rid(zOld, 0);
        int rid2 = uuid_to_rid(zNew, 0);
        @ <blockquote><pre>
        append_diff(rid1, rid2);
        @ </pre></blockquote>
      }
    }

  }else if( zOld && zNew ){
    @ <p>Modified <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>
    @ from <a href="%s(g.zTop)/artifact/%s(zOld)">[%S(zOld)]</a>
    @ to <a href="%s(g.zTop)/artifact/%s(zNew)">[%S(zNew)].</a>
    if( !showDiff ){
      @ &nbsp;&nbsp;
      @ <a href="%s(g.zTop)/fdiff?v1=%S(zOld)&amp;v2=%S(zNew)">[diff]</a>
    }else{
      int rid1 = uuid_to_rid(zOld, 0);
      int rid2 = uuid_to_rid(zNew, 0);
      @ <blockquote><pre>
      append_diff(rid1, rid2);
      @ </pre></blockquote>
    }
    @ </p>
  }else if( zOld ){
    @ <p>Deleted <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>
    @ version <a href="%s(g.zTop)/artifact/%s(zOld)">[%S(zOld)]</a></p>
  }else{
    @ <p>Added <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>
    @ version <a href="%s(g.zTop)/artifact/%s(zNew)">[%S(zNew)]</a></p>










  }
}


/*
** WEBPAGE: vinfo
** WEBPAGE: ci







|
>
>

>
>
|
>
>
>
>
>
|
>
>
>







 







>
|
<
<
|
|
|
|
<
>
|
|
|
|
<
<
<
<
<
<
<
<
<
<
<
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>







232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
...
273
274
275
276
277
278
279
280
281


282
283
284
285

286
287
288
289
290











291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
  }
}


/*
** Append the difference between two RIDs to the output
*/
static void append_diff(const char *zFrom, const char *zTo){
  int fromid;
  int toid;
  Blob from, to, out;
  if( zFrom ){
    fromid = uuid_to_rid(zFrom, 0);
    content_get(fromid, &from);
  }else{
    blob_zero(&from);
  }
  if( zTo ){
    toid = uuid_to_rid(zTo, 0);
    content_get(toid, &to);
  }else{
    blob_zero(&to);
  }
  blob_zero(&out);
  text_diff(&from, &to, &out, 5, 1);
  @ %h(blob_str(&out))
  blob_reset(&from);
  blob_reset(&to);
  blob_reset(&out);  
}
................................................................................
  if( !g.okHistory ){
    if( zNew==0 ){
      @ <p>Deleted %h(zName)</p>
    }else if( zOld==0 ){
      @ <p>Added %h(zName)</p>
    }else{
      @ <p>Changes to %h(zName)</p>
    }
    if( showDiff ){


      @ <blockquote><pre>
      append_diff(zOld, zNew);
      @ </pre></blockquote>
    }

  }else{
    if( zOld && zNew ){
      @ <p>Modified <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>
      @ from <a href="%s(g.zTop)/artifact/%s(zOld)">[%S(zOld)]</a>
      @ to <a href="%s(g.zTop)/artifact/%s(zNew)">[%S(zNew)].</a>











    }else if( zOld ){
      @ <p>Deleted <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>
      @ version <a href="%s(g.zTop)/artifact/%s(zOld)">[%S(zOld)]</a>
    }else{
      @ <p>Added <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>
      @ version <a href="%s(g.zTop)/artifact/%s(zNew)">[%S(zNew)]</a>
    }
    if( showDiff ){
      @ <blockquote><pre>
      append_diff(zOld, zNew);
      @ </pre></blockquote>
    }else if( zOld && zNew ){
      @ &nbsp;&nbsp;
      @ <a href="%s(g.zTop)/fdiff?v1=%S(zOld)&amp;v2=%S(zNew)">[diff]</a>
    }
    @ </p>
  }
}


/*
** WEBPAGE: vinfo
** WEBPAGE: ci

Changes to src/manifest.c.

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
  char *zEventId;       /* UUID for an event.  E card. */
  char *zTicketUuid;    /* UUID for a ticket. K card. */
  char *zAttachName;    /* Filename of an attachment. A card. */
  char *zAttachSrc;     /* UUID of document being attached. A card. */
  char *zAttachTarget;  /* Ticket or wiki that attachment applies to.  A card */
  int nFile;            /* Number of F cards */
  int nFileAlloc;       /* Slots allocated in aFile[] */
  struct { 
    char *zName;           /* Name of a file */
    char *zUuid;           /* UUID of the file */
    char *zPerm;           /* File permissions */
    char *zPrior;          /* Prior name if the name was changed */
    int iRename;           /* index of renamed name in prior/next manifest */
  } *aFile;             /* One entry for each F card */
  int nParent;          /* Number of parents. */







|







52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
  char *zEventId;       /* UUID for an event.  E card. */
  char *zTicketUuid;    /* UUID for a ticket. K card. */
  char *zAttachName;    /* Filename of an attachment. A card. */
  char *zAttachSrc;     /* UUID of document being attached. A card. */
  char *zAttachTarget;  /* Ticket or wiki that attachment applies to.  A card */
  int nFile;            /* Number of F cards */
  int nFileAlloc;       /* Slots allocated in aFile[] */
  struct ManifestFile { 
    char *zName;           /* Name of a file */
    char *zUuid;           /* UUID of the file */
    char *zPerm;           /* File permissions */
    char *zPrior;          /* Prior name if the name was changed */
    int iRename;           /* index of renamed name in prior/next manifest */
  } *aFile;             /* One entry for each F card */
  int nParent;          /* Number of parents. */