Fossil

Check-in [0066d6c6]
Login

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

Overview
Comment:Show short UUID collisions also for tickets and not just ticket changes. Reported on ML.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | short-uuid
Files: files | file ages | folders
SHA1:0066d6c6a9afe510e3b26ae4c123e692b1717496
User & Date: andybradford 2014-04-06 04:51:41
Context
2014-04-08
04:32
Use function more specific to detecting collisions to catch events, tickets and other types in blob. check-in: ae6f2700 user: andybradford tags: short-uuid
2014-04-06
04:51
Show short UUID collisions also for tickets and not just ticket changes. Reported on ML. check-in: 0066d6c6 user: andybradford tags: short-uuid
2014-04-04
12:11
Update to SQLite 3.8.4.3 check-in: b37a2822 user: jan.nijtmans tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/info.c.

1891
1892
1893
1894
1895
1896
1897



1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914

1915
1916
1917
1918





1919
1920
1921
1922
1923
1924
1925
  const char *zName;
  Blob uuid;
  int rid;
  int rc;

  zName = P("name");
  if( zName==0 ) fossil_redirect_home();



  if( validate16(zName, strlen(zName)) ){
    if( db_exists("SELECT 1 FROM ticket WHERE tkt_uuid GLOB '%q*'", zName) ){
      tktview_page();
      return;
    }
    if( db_exists("SELECT 1 FROM tag WHERE tagname GLOB 'event-%q*'", zName) ){
      event_page();
      return;
    }
  }
  blob_set(&uuid, zName);
  rc = name_to_uuid(&uuid, -1, "*");
  if( rc==1 ){
    style_header("No Such Object");
    @ <p>No such object: %h(zName)</p>
    style_footer();
    return;

  }else if( rc==2 ){
    cgi_set_parameter("src","info");
    ambiguous_page();
    return;





  }
  zName = blob_str(&uuid);
  rid = db_int(0, "SELECT rid FROM blob WHERE uuid='%s'", zName);
  if( rid==0 ){
    style_header("Broken Link");
    @ <p>No such object: %h(zName)</p>
    style_footer();







>
>
>
|
|
<
<
<
|


|
<
<
<
<
|
|
|
|
>




>
>
>
>
>







1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902



1903
1904
1905
1906




1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
  const char *zName;
  Blob uuid;
  int rid;
  int rc;

  zName = P("name");
  if( zName==0 ) fossil_redirect_home();
  blob_set(&uuid, zName);
  rc = name_to_uuid3(&uuid, -1, "*");
  if( rc==1 ){
    if( validate16(zName, strlen(zName)) &&
        db_exists("SELECT 1 FROM tag"



                  " WHERE tagname GLOB 'event-%q*'", zName) ){
      event_page();
      return;
    }else{




      style_header("No Such Object");
      @ <p>No such object: %h(zName)</p>
      style_footer();
      return;
    }
  }else if( rc==2 ){
    cgi_set_parameter("src","info");
    ambiguous_page();
    return;
  }else if( rc==3 && validate16(zName, strlen(zName)) ){
    if( db_exists("SELECT 1 FROM ticket WHERE tkt_uuid GLOB '%q*'", zName) ){
      tktview_page();
      return;
    }
  }
  zName = blob_str(&uuid);
  rid = db_int(0, "SELECT rid FROM blob WHERE uuid='%s'", zName);
  if( rid==0 ){
    style_header("Broken Link");
    @ <p>No such object: %h(zName)</p>
    style_footer();

Changes to src/name.c.

264
265
266
267
268
269
270




















271
272
273
274
275
276
277
...
316
317
318
319
320
321
322













323














324
325
326
327
328
329
330
...
404
405
406
407
408
409
410






















411
412
413
414
415
416
417
          "   AND event.type GLOB '%q'", zTag, zType);
      }
    }
  }
  return rid;
}






















/*
** This routine takes a user-entered UUID which might be in mixed
** case and might only be a prefix of the full UUID and converts it
** into the full-length UUID in canonical form.
**
** If the input is not a UUID or a UUID prefix, then try to resolve
................................................................................
  int rid = symbolic_name_to_rid(zName, zType);
  if((rid>0) && pUuid){
    *pUuid = db_text(NULL, "SELECT uuid FROM blob WHERE rid=%d", rid);
  }
  return rid;
}






























/*
** COMMAND:  test-name-to-id
**
** Convert a name to a full artifact ID.
*/
void test_name_to_id(void){
................................................................................
  while( db_step(&q)==SQLITE_ROW ){
    const char *zUuid = db_column_text(&q, 0);
    int rid = db_column_int(&q, 1);
    @ <li><p><a href="%s(g.zTop)/%T(zSrc)/%s(zUuid)">
    @ %s(zUuid)</a> -
    object_description(rid, 0, 0);
    @ </p></li>






















  }
  @ </ol>
  db_finalize(&q);
  style_footer();
}

/*







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







 







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







 







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







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
...
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
...
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
          "   AND event.type GLOB '%q'", zTag, zType);
      }
    }
  }
  return rid;
}

/*
** Return the ticket id from the ticket table if found.  If more than one
** is found, return -1 to indicate ambiguity.
*/
int symbolic_name_to_tktid(const char *zTag){
  int tktid = 0;
  Stmt q;

  if( strlen(zTag)>=4 &&
      strlen(zTag)<=UUID_SIZE && validate16(zTag, strlen(zTag)) ) {
    db_prepare(&q, "SELECT tkt_id FROM ticket"
                   " WHERE tkt_uuid GLOB '%s*'", zTag );
    if( db_step(&q)==SQLITE_ROW ){
      tktid = db_column_int(&q, 0);
      if( db_step(&q)==SQLITE_ROW ) tktid = -1;
    }
    db_finalize(&q);
  }
  return tktid;
}

/*
** This routine takes a user-entered UUID which might be in mixed
** case and might only be a prefix of the full UUID and converts it
** into the full-length UUID in canonical form.
**
** If the input is not a UUID or a UUID prefix, then try to resolve
................................................................................
  int rid = symbolic_name_to_rid(zName, zType);
  if((rid>0) && pUuid){
    *pUuid = db_text(NULL, "SELECT uuid FROM blob WHERE rid=%d", rid);
  }
  return rid;
}

/*
** This routine is similar to name_to_uuid() except it also accounts for
** collisions in tickets which don't have an entry in blob (only associated
** ticket changes).
** Return 0 if rid is found.  Return 1 if neither rid nor tkt_id is found.
** Return 2 if name is ambiguous.  Return 3 if tkt_id is found.
*/
int name_to_uuid3(Blob *pName, int iErrPriority, const char *zType){
  char *zName = blob_str(pName);
  int tkt_id = 0;
  int rid = symbolic_name_to_rid(zName, zType);
  if( zType && zType[0]=='*' ){
    tkt_id = symbolic_name_to_tktid(zName);
  }
  if( rid<0 || tkt_id<0 || (rid>0 && tkt_id>0) ){
    fossil_error(iErrPriority, "ambiguous name: %s", zName);
    return 2;
  }else if( rid==0 && tkt_id==0 ){
    fossil_error(iErrPriority, "not found: %s", zName);
    return 1;
  }else if( tkt_id>0 ){
    return 3;
  }else{
    blob_reset(pName);
    db_blob(pName, "SELECT uuid FROM blob WHERE rid=%d", rid);
    return 0;
  }
}

/*
** COMMAND:  test-name-to-id
**
** Convert a name to a full artifact ID.
*/
void test_name_to_id(void){
................................................................................
  while( db_step(&q)==SQLITE_ROW ){
    const char *zUuid = db_column_text(&q, 0);
    int rid = db_column_int(&q, 1);
    @ <li><p><a href="%s(g.zTop)/%T(zSrc)/%s(zUuid)">
    @ %s(zUuid)</a> -
    object_description(rid, 0, 0);
    @ </p></li>
  }
  db_finalize(&q);
  db_prepare(&q, "   SELECT tkt_rid, tkt_uuid, title"
                 "     FROM ticket, ticketchng"
                 "    WHERE ticket.tkt_id = ticketchng.tkt_id"
                 "      AND tkt_uuid GLOB '%q*'"
                 " GROUP BY tkt_uuid"
                 " ORDER BY tkt_ctime DESC", z);
  while( db_step(&q)==SQLITE_ROW ){
    int rid = db_column_int(&q, 0); 
    const char *zUuid = db_column_text(&q, 1);
    const char *zTitle = db_column_text(&q, 2);
    @ <li><p><a href="%s(g.zTop)/%T(zSrc)/%s(zUuid)">
    @ %s(zUuid)</a> -
    @ <ul></ul>
    @ Ticket
    hyperlink_to_uuid(zUuid);
    @ - %s(zTitle).
    @ <ul><li>
    object_description(rid, 0, 0);
    @ </li></ul>
    @ </p></li>
  }
  @ </ol>
  db_finalize(&q);
  style_footer();
}

/*