Fossil

Check-in [86c8768475]
Login

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

Overview
Comment:Add the finfo web page.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 86c8768475f6eb0ec28329c4899e49a6ae09f2f3
User & Date: drh 2007-08-01 00:55:18.000
Context
2007-08-01
01:24
Added the vdiff webpage with links from vinfo. ... (check-in: 9df32e2808 user: drh tags: trunk)
00:55
Add the finfo web page. ... (check-in: 86c8768475 user: drh tags: trunk)
00:40
Improvements to the vinfo webpage. Show descendents, ancestors, and files changed. ... (check-in: 30d7afe328 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/info.c.
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
** Show information about descendents of a version.  Do this recursively
** to a depth of N.  Return true if descendents are shown and false if not.
*/
static int showDescendents(int pid, int depth){
  Stmt q;
  int cnt = 0;
  db_prepare(&q,
    "SELECT plink.cid, blob.uuid, datetime(plink.mtime),"
    "       event.user, event.comment"
    "  FROM plink, blob, event"
    " WHERE plink.pid=%d"
    "   AND blob.rid=plink.cid"
    "   AND event.objid=plink.cid"
    " ORDER BY plink.mtime ASC",
    pid







|







109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
** Show information about descendents of a version.  Do this recursively
** to a depth of N.  Return true if descendents are shown and false if not.
*/
static int showDescendents(int pid, int depth){
  Stmt q;
  int cnt = 0;
  db_prepare(&q,
    "SELECT plink.cid, blob.uuid, datetime(plink.mtime, 'localtime'),"
    "       event.user, event.comment"
    "  FROM plink, blob, event"
    " WHERE plink.pid=%d"
    "   AND blob.rid=plink.cid"
    "   AND event.objid=plink.cid"
    " ORDER BY plink.mtime ASC",
    pid
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
** Show information about ancestors of a version.  Do this recursively
** to a depth of N.  Return true if ancestors are shown and false if not.
*/
static int showAncestors(int pid, int depth){
  Stmt q;
  int cnt = 0;
  db_prepare(&q,
    "SELECT plink.pid, blob.uuid, datetime(event.mtime),"
    "       event.user, event.comment"
    "  FROM plink, blob, event"
    " WHERE plink.cid=%d"
    "   AND blob.rid=plink.pid"
    "   AND event.objid=plink.pid"
    " ORDER BY event.mtime DESC",
    pid
  );
  @ <ul>
  while( db_step(&q)==SQLITE_ROW ){
    int n;
    int cid = db_column_int(&q, 0);
    const char *zUuid = db_column_text(&q, 1);
    const char *zDate = db_column_text(&q, 2);
    const char *zUser = db_column_text(&q, 3);
    const char *zCom = db_column_text(&q, 4);
    cnt++;
    @ <li>







|










<







155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172

173
174
175
176
177
178
179
** Show information about ancestors of a version.  Do this recursively
** to a depth of N.  Return true if ancestors are shown and false if not.
*/
static int showAncestors(int pid, int depth){
  Stmt q;
  int cnt = 0;
  db_prepare(&q,
    "SELECT plink.pid, blob.uuid, datetime(event.mtime, 'localtime'),"
    "       event.user, event.comment"
    "  FROM plink, blob, event"
    " WHERE plink.cid=%d"
    "   AND blob.rid=plink.pid"
    "   AND event.objid=plink.pid"
    " ORDER BY event.mtime DESC",
    pid
  );
  @ <ul>
  while( db_step(&q)==SQLITE_ROW ){

    int cid = db_column_int(&q, 0);
    const char *zUuid = db_column_text(&q, 1);
    const char *zDate = db_column_text(&q, 2);
    const char *zUser = db_column_text(&q, 3);
    const char *zCom = db_column_text(&q, 4);
    cnt++;
    @ <li>
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
** Return information about a version.  The version number is contained
** in g.zExtra.
*/
void vinfo_page(void){
  Stmt q;
  int rid;
  int isLeaf;
  int cid, pid, n;

  login_check_credentials();
  if( !g.okHistory ){ login_needed(); return; }
  style_header("Version Information");
  rid = name_to_rid(g.zExtra);
  if( rid==0 ){
    @ No such object: %h(g.argv[2])
    style_footer();
    return;
  }
  isLeaf = !db_exists("SELECT 1 FROM plink WHERE pid=%d", rid);
  db_prepare(&q, 
     "SELECT uuid, datetime(mtime), user, comment"
     "  FROM blob, event"
     " WHERE blob.rid=%d"
     "   AND event.objid=%d",
     rid, rid
  );
  if( db_step(&q)==SQLITE_ROW ){
    @ <h2>Version %s(db_column_text(&q,0))</h2>







|












|







193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
** Return information about a version.  The version number is contained
** in g.zExtra.
*/
void vinfo_page(void){
  Stmt q;
  int rid;
  int isLeaf;
  int n;

  login_check_credentials();
  if( !g.okHistory ){ login_needed(); return; }
  style_header("Version Information");
  rid = name_to_rid(g.zExtra);
  if( rid==0 ){
    @ No such object: %h(g.argv[2])
    style_footer();
    return;
  }
  isLeaf = !db_exists("SELECT 1 FROM plink WHERE pid=%d", rid);
  db_prepare(&q, 
     "SELECT uuid, datetime(mtime, 'localtime'), user, comment"
     "  FROM blob, event"
     " WHERE blob.rid=%d"
     "   AND event.objid=%d",
     rid, rid
  );
  if( db_step(&q)==SQLITE_ROW ){
    @ <h2>Version %s(db_column_text(&q,0))</h2>
253
254
255
256
257
258
259
260
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
304
305
306
307
308
309
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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430

431
432
433
434
435
436
437
438
439
440
441
442
443
    if( pid && fid ){
      @ <b>Modified:</b>
    }else if( fid ){
      @ <b>Added:</b>
    }else{
      @ <b>Deleted:</b>
    }
    @ %h(zName)</li>
  }
  @ </ul>
  style_footer();
}


#if 0
/*
** WEB PAGE: vinfo
**
** Return information about a version.  The version number is contained
** in g.zExtra.
*/
void vinfo_page(void){
  Stmt q;
  int rid;
  char cType;
  char *zType;

  login_check_credentials();
  if( !g.okHistory ){ login_needed(); return; }
  style_header("Version Information");
  rid = name_to_rid(g.zExtra);
  if( rid==0 ){
    @ No such object: %h(g.argv[2])
    style_footer();
    return;
  }
  db_row_to_table("SELECT "
    "  blob.uuid               AS \"UUID\""
    ", datetime(rcvfrom.mtime) AS \"Created\""
    ", rcvfrom.uid             AS \"User Id\""
    ", blob.size               AS \"Size\""
    "FROM blob, rcvfrom "
    "WHERE rid=%d", rid
  );
  style_footer();
  return;

  db_prepare(&q,
    "SELECT "
      "uuid, "                                         /* 0 */
      "datetime(mtime,'unixepoch'),"                   /* 1 */
      "datetime(ctime,'unixepoch'),"                   /* 2 */
      "uid, size, cksum, branch, comment, type"        /* 3..8 */
    "FROM record WHERE rid=%d", rid
  );
  if( db_step(&q)==SQLITE_ROW ){
    const char *z;
    const char *zSignedBy = db_text("unknown",
                                     "SELECT login FROM repuser WHERE uid=%d",
                                     db_column_int(&q, 3));
    cType = db_column_text(&q,8)[0];
    switch( cType ){
      case 'f':  zType = "file";        break;
      case 'v':  zType = "version";     break;
      case 'c':  zType = "control";     break;
      case 'w':  zType = "wiki";        break;
      case 'a':  zType = "attachment";  break;
      case 't':  zType = "ticket";      break;
    }
    @ <table border="0" cellpadding="0" cellspacing="0">
    @ <tr><td align="right">%s(zType)&nbsp;UUID:</td><td width="10"></td>
    @ <td>%s(db_column_text(&q,0))</td></tr>
    z = db_column_text(&q, 7);
    if( z ){
      @ <tr><td align="right" valign="top">comment:</td><td></td>
      @ <td valign="top">%h(z)</td></tr>
    }
    @ <tr><td align="right">created:</td><td></td>
    @ <td>%s(db_column_text(&q,2))</td></tr>
    @ <tr><td align="right">received:</td><td></td>
    @ <td>%s(db_column_text(&q,1))</td></tr>
    @ <tr><td align="right">signed&nbsp;by:</td><td></td>
    @ <td>%h(zSignedBy)</td></tr>
    z = db_column_text(&q, 4);
    if( z && z[0] && (z[0]!='0' || z[1]!=0) ){
      @ <tr><td align="right">size:</td><td></td>
      @ <td>%s(z)</td></tr>
    }
    z = db_column_text(&q, 5);
    if( z ){
      @ <tr><td align="right">MD5&nbsp;checksum:</td><td></td>
      @ <td>%s(z)</td></tr>
    }
    z = db_column_text(&q, 6);
    if( z ){
      @ <tr><td align="right">branch:</td><td></td>
      @ <td>%h(z)</td></tr>
    }
  }
  db_finalize(&q);
  db_prepare(&q, "SELECT uuid, typecode FROM link JOIN record ON a=rid "
                 " WHERE b=%d", rid);
  while( db_step(&q)==SQLITE_ROW ){
    const char *zType = db_column_text(&q, 1);
    const char *zUuid = db_column_text(&q, 0);
    if( zType[0]=='P' ){
      @ <tr><td align="right">parent:</td><td></td><td>
      hyperlink_to_uuid(zUuid);
      if( cType=='f' || cType=='w' ){

        hyperlink_to_diff(zUuid, g.zExtra);
      }
      @ </td></tr>
    }else if( zType[0]=='M' ){
      @ <tr><td align="right">merge&nbsp;parent:</td><td></td><td>
      hyperlink_to_uuid(zUuid);
      if( cType=='f' || cType=='w' ){
        hyperlink_to_diff(zUuid, g.zExtra);
      }
      @ </td></tr>
    }
  }
  db_finalize(&q);
  db_prepare(&q, "SELECT uuid, typecode FROM link JOIN record ON b=rid "
                 " WHERE a=%d ORDER BY typecode DESC", rid);
  while( db_step(&q)==SQLITE_ROW ){
    const char *zType = db_column_text(&q, 1);
    const char *zUuid = db_column_text(&q, 0);
    if( zType[0]=='P' ){

      @ <tr><td align="right">child:</td><td></td><td>
      hyperlink_to_uuid(zUuid);
      if( cType=='f' || cType=='w' ){
        hyperlink_to_diff(g.zExtra, zUuid);
      }





      @ </td></tr>
    }else if( zType[0]=='M' ){
      @ <tr><td align="right">merge&nbsp;child:</td><td></td><td>
      hyperlink_to_uuid(zUuid);
      if( cType=='f' || cType=='w' ){
        hyperlink_to_diff(g.zExtra, zUuid);
      }
      @ </td></tr>
    }
  }
  db_finalize(&q);
  if( cType=='v' ){
    db_prepare(&q, "SELECT uuid, typecode, name "
                   " FROM link, record, fname"
                   " WHERE a=%d AND typecode IN ('D','E','I')"
                   "   AND b=record.rid AND fname.fnid=record.fnid"
                   " ORDER BY name", rid);
    while( db_step(&q)==SQLITE_ROW ){
      const char *zUuid = db_column_text(&q, 0);
      const char *zType = db_column_text(&q, 1);
      const char *zName = db_column_text(&q, 2);
      if( zType[0]=='D' ){
        @ <tr><td align="right">deleted&nbsp;file:</td><td></td><td>
        hyperlink_to_uuid(zUuid);
      }else if( zType[0]=='E' ){
        @ <tr><td align="right">changed&nbsp;file:</td><td></td><td>
        hyperlink_to_uuid(zUuid);
        hyperlink_to_diff(zUuid, 0);
      }else if( zType[0]=='I' ){
        @ <tr><td align="right">added&nbsp;file:</td><td></td><td>
        hyperlink_to_uuid(zUuid);
      }
      @ &nbsp;&nbsp;%h(zName)</td></tr>
    }
    db_finalize(&q);
  }else if( cType=='f' ){
    db_prepare(&q, "SELECT uuid"
                   " FROM link, record"
                   " WHERE b=%d AND typecode IN ('E','I')"
                   "   AND a=record.rid", rid);
    while( db_step(&q)==SQLITE_ROW ){
      const char *zUuid = db_column_text(&q, 0);
      @ <tr><td align="right">associated&nbsp;version:</td><td></td><td>
      hyperlink_to_uuid(zUuid);
      @ </td></tr>

    }
    db_finalize(&q);
  }
  style_footer();
}
#endif

#if 0
/*
** WEB PAGE: diff
**
** Display the difference between two files determined by the v1 and v2
** query parameters.  If only v2 is given compute v1 as the parent of v2.







|





<
<

|

|
|

|

<
|
<
<


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

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


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







252
253
254
255
256
257
258
259
260
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













304


305



306
307

308
309
310









311
312
313

314

315

316
317
318
319
320
321
322
    if( pid && fid ){
      @ <b>Modified:</b>
    }else if( fid ){
      @ <b>Added:</b>
    }else{
      @ <b>Deleted:</b>
    }
    @ <a href="%s(g.zBaseURL)/finfo/%T(zName)">%h(zName)</a></li>
  }
  @ </ul>
  style_footer();
}



/*
** WEBPAGE: finfo
**
** Show the complete change history for a single file.  The name
** of the file is in g.zExtra
*/
void finfo_page(void){
  Stmt q;

  char zPrevDate[20];


  login_check_credentials();
  if( !g.okHistory ){ login_needed(); return; }
  style_header("File History");





































































  zPrevDate[0] = 0;
  db_prepare(&q,
    "SELECT blob.uuid, datetime(event.mtime,'localtime'),"
    "       event.comment, event.user"
    "  FROM mlink, blob, event"
    " WHERE mlink.fnid=(SELECT fnid FROM filename WHERE name=%Q)"
    "   AND blob.rid=mlink.mid"

    "   AND event.objid=mlink.mid"

    " ORDER BY event.mtime DESC",
    g.zExtra




  );

  @ <h2>History of %h(g.zExtra)</h2>

  @ <table cellspacing=0 border=0 cellpadding=0>





  while( db_step(&q)==SQLITE_ROW ){
    const char *zDate = db_column_text(&q, 1);

    if( memcmp(zDate, zPrevDate, 10) ){
      sprintf(zPrevDate, "%.10s", zDate);
      @ <tr><td colspan=3>




      @ <table cellpadding=2 border=0>
      @ <tr><td bgcolor="#a0b5f4" class="border1">
      @ <table cellpadding=2 cellspacing=0 border=0><tr>
      @ <td bgcolor="#d0d9f4" class="bkgnd1">%s(zPrevDate)</td>
      @ </tr></table>
      @ </td></tr></table>






      @ </td></tr>
    }













    @ <tr><td valign="top">%s(&zDate[11])</td>


    @ <td width="20"></td>



    @ <td valign="top" align="left">
    hyperlink_to_uuid(db_column_text(&q,0));

    @ %h(db_column_text(&q,2)) (by %h(db_column_text(&q,3)))</td>
  }
  db_finalize(&q);









  @ </table>
  style_footer();
}






#if 0
/*
** WEB PAGE: diff
**
** Display the difference between two files determined by the v1 and v2
** query parameters.  If only v2 is given compute v1 as the parent of v2.