Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Added experimental "usage" command to track command usage stats on a per-checkout basis (not synched). |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | usage-command |
| Files: | files | file ages | folders |
| SHA1: |
bd71466446d67e859d53f932b0ee3d53 |
| User & Date: | stephan 2013-09-03 20:01:43.408 |
Context
|
2013-09-03
| ||
| 20:04 | Fixed a missing db_finalize() in the -clear case. ... (check-in: 3579d1cb87 user: stephan tags: usage-command) | |
| 20:01 | Added experimental "usage" command to track command usage stats on a per-checkout basis (not synched). ... (check-in: bd71466446 user: stephan tags: usage-command) | |
| 15:24 | Update the built-in SQLite from upstream, for the purpose of testing SQLite. ... (check-in: fa0df0c77e user: drh tags: trunk) | |
Changes
Changes to src/main.c.
| ︙ | ︙ | |||
503 504 505 506 507 508 509 510 511 512 513 514 515 516 |
case SQLITE_WARNING: return "SQLITE_WARNING";
default: {
sqlite3_snprintf(sizeof(zCode),zCode,"error code %d",iCode);
}
}
return zCode;
}
/* Error logs from SQLite */
static void fossil_sqlite_log(void *notUsed, int iCode, const char *zErrmsg){
#ifdef __APPLE__
/* Disable the file alias warning on apple products because Time Machine
** creates lots of aliases and the warning alarms people. */
if( iCode==SQLITE_WARNING ) return;
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 |
case SQLITE_WARNING: return "SQLITE_WARNING";
default: {
sqlite3_snprintf(sizeof(zCode),zCode,"error code %d",iCode);
}
}
return zCode;
}
static void update_cmd_usage_stats(char const * zCommand){
if(!g.zLocalRoot) return /* we need a checkout */;
db_multi_exec("CREATE TABLE IF NOT EXISTS cmd_usage (name,mtime FLOAT);"
"INSERT INTO cmd_usage (name,mtime) VALUES (%Q,julianday('now'));",
zCommand);
}
/*
** COMMAND: usage*
**
** Usage: %fossil usage [-clear|-c]
**
** Reports or clears information from the local checkout's cmd_usage
** table (if any). The cmd_usage table is updated each time a fossil
** CLI command succeeds (returns). The db has (name TEXT, mtime FLOAT
** (Julian Day)) fields for collecting statistics about usage. This
** information is stored in the local checkout db and is not
** synchronized.
*/
void usage_cmd(){
int rc;
Stmt q;
int i = 0;
int fClear = find_option("clear","c",0)!=0;
db_find_and_open_repository(0, 0);
rc = db_prepare_ignore_error(&q,
"SELECT name, count(*) AS n "
"FROM cmd_usage GROUP BY name "
"ORDER BY n DESC");
if(rc){
/* Assume missing cmd_usage table. */
fossil_print("(An sqlite error message is normal the first time "
"this is run for a given checkout!)\n"
"No command usage history has been collected "
"for this checkout.\n");
return;
}
if(fClear){
db_multi_exec("DELETE FROM cmd_usage;");
fossil_print("Usage history cleared.\n");
return;
}
fossil_print("CLI command usage history for this checkout:\n");
fossil_print("Count Command\n");
while(SQLITE_ROW==db_step(&q)){
++i;
fossil_print("%5d %s\n", db_column_int(&q, 1),
db_column_text(&q,0));
}
db_finalize(&q);
if(!i){
fossil_print("No command usage history has been collected "
"for this checkout.\n");
}
}
/* Error logs from SQLite */
static void fossil_sqlite_log(void *notUsed, int iCode, const char *zErrmsg){
#ifdef __APPLE__
/* Disable the file alias warning on apple products because Time Machine
** creates lots of aliases and the warning alarms people. */
if( iCode==SQLITE_WARNING ) return;
|
| ︙ | ︙ | |||
633 634 635 636 637 638 639 640 641 642 643 644 645 646 |
"%s: could be any of:%s\n"
"%s: use \"help\" for more information\n",
g.argv[0], zCmdName, g.argv[0], blob_str(&couldbe), g.argv[0]);
fossil_exit(1);
}
atexit( fossil_atexit );
aCommand[idx].xFunc();
fossil_exit(0);
/*NOT_REACHED*/
return 0;
}
/*
** Print a usage comment and quit
| > | 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 |
"%s: could be any of:%s\n"
"%s: use \"help\" for more information\n",
g.argv[0], zCmdName, g.argv[0], blob_str(&couldbe), g.argv[0]);
fossil_exit(1);
}
atexit( fossil_atexit );
aCommand[idx].xFunc();
update_cmd_usage_stats(aCommand[idx].zName);
fossil_exit(0);
/*NOT_REACHED*/
return 0;
}
/*
** Print a usage comment and quit
|
| ︙ | ︙ |