Fossil

Check-in [1dd49323]
Login

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

Overview
Comment:Added new "dbstat" command, mostly analog to the /stat web page, but not called "stat" to avoid breaking any "stat==status" typing habits.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:1dd493231a854cdc77afd04d3a203bcbe4cc5319
User & Date: stephan 2013-01-13 18:38:11
Context
2013-01-14
00:21
Enhance the "fossil merge" command so that if the VERSION argument is omitted, Fossil tries to merge any forks of the current branch. check-in: 9ee47de2 user: drh tags: trunk
2013-01-13
18:38
Added new "dbstat" command, mostly analog to the /stat web page, but not called "stat" to avoid breaking any "stat==status" typing habits. check-in: 1dd49323 user: stephan tags: trunk
02:01
Allow the FOSSIL_USER environment variable to be used as a fallback when creating a new repository. check-in: a0dd51e9 user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/stat.c.

135
136
137
138
139
140
141








































































































142
143
144
145
146
147
148
  @ %s(db_text(0, "PRAGMA %s.encoding", zDb)),
  @ %s(db_text(0, "PRAGMA %s.journal_mode", zDb)) mode
  @ </td></tr>

  @ </table>
  style_footer();
}









































































































/*
** WEBPAGE: urllist
**
** Show ways in which this repository has been accessed
*/
void urllist_page(void){







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







135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
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
181
182
183
184
185
186
187
188
189
190
191
192
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
  @ %s(db_text(0, "PRAGMA %s.encoding", zDb)),
  @ %s(db_text(0, "PRAGMA %s.journal_mode", zDb)) mode
  @ </td></tr>

  @ </table>
  style_footer();
}

/*
** COMMAND: dbstat
**
** Show statistics and global information about the repository.
*/
void dbstat_cmd(void){
  i64 t, fsize;
  int n, m;
  int szMax, szAvg;
  const char *zDb;
  int brief;
  char zBuf[100];
  const int colWidth = -20 /* printf alignment/width for left column */;
  brief = find_option("brief", "b",0)!=0;
  db_find_and_open_repository(0,0);
  fsize = file_size(g.zRepositoryName);
  bigSizeName(sizeof(zBuf), zBuf, fsize);
  fossil_print( "%*s%s\n", colWidth, "repository-size:", zBuf );
  if( !brief ){
    n = db_int(0, "SELECT count(*) FROM blob");
    m = db_int(0, "SELECT count(*) FROM delta");
    fossil_print("%*s%d (stored as %d full text and %d delta blobs)\n",
                 colWidth, "artifact-count:",
                 n, n-m, m);
    if( n>0 ){
      int a, b;
      Stmt q;
      db_prepare(&q, "SELECT total(size), avg(size), max(size)"
                     " FROM blob WHERE size>0");
      db_step(&q);
      t = db_column_int64(&q, 0);
      szAvg = db_column_int(&q, 1);
      szMax = db_column_int(&q, 2);
      db_finalize(&q);
      bigSizeName(sizeof(zBuf), zBuf, t);
      fossil_print( "%*s%d bytes average, "
                    "%d bytes max, %s total\n",
                    colWidth, "artifact-sizes:",
                    szAvg, szMax, zBuf);
      if( t/fsize < 5 ){
        b = 10;
        fsize /= 10;
      }else{
        b = 1;
      }
      a = t/fsize;
      fossil_print("%*s%d:%d\n", colWidth, "compression-ratio:", a, b);
    }
    n = db_int(0, "SELECT COUNT(*) FROM event e WHERE e.type='ci'");
    fossil_print("%*s%d\n", colWidth, "checkin-count:", n);
    n = db_int(0, "SELECT count(*) FROM filename /*scan*/");
    /* FIXME/TODO: add the change-count-per-type to each event type,
    **   plus add 'Event' count
    */
#if 0
    m = db_int(0, "SELECT count(distinct mid) FROM mlink /*scan*/");
#endif
    fossil_print("%*s%d"/*  (%d changes) */"\n", colWidth, "file-count:",
                 n/*, m */);
    n = db_int(0, "SELECT count(*) FROM tag  /*scan*/"
                  " WHERE tagname GLOB 'wiki-*'");
#if 0
    m = db_int(0, "SELECT COUNT(*) FROM blob b JOIN event e WHERE "
                  "b.rid=e.objid AND e.type='w'");
#endif
    fossil_print("%*s%d"/*  (%d changes) */"\n", colWidth, "wikipage-count:",
                 n/*, m */);
    n = db_int(0, "SELECT count(*) FROM tag  /*scan*/"
                  " WHERE tagname GLOB 'tkt-*'");
#if 0
    m = db_int(0, "SELECT COUNT(*) FROM blob b JOIN event e WHERE "
                   "b.rid=e.objid AND e.type='t'");
#endif
    fossil_print("%*s%d"/* (%d changes)*/"\n", colWidth, "ticket-count:",
                 n/* , m */);
  }
  n = db_int(0, "SELECT julianday('now') - (SELECT min(mtime) FROM event)"
                " + 0.99");
  fossil_print("%*s%d days or approximately %.2f years.\n",
               colWidth, "project-age:", n, n/365.24);
  fossil_print("%*s%s\n", colWidth, "project-id:", db_get("project-code",""));
  fossil_print("%*s%s\n", colWidth, "server-id:", db_get("server-code",""));
  fossil_print("%*s%s %s %s (%s)\n",
               colWidth, "fossil-version:",
               RELEASE_VERSION, MANIFEST_DATE, MANIFEST_VERSION,
               COMPILER_NAME);
  fossil_print("%*s%.19s [%.10s] (%s)\n",
               colWidth, "sqlite-version:",
               SQLITE_SOURCE_ID, &SQLITE_SOURCE_ID[20],
               SQLITE_VERSION);
  zDb = db_name("repository");
  fossil_print("%*s%d pages, %d bytes/page, %d free pages, "
               "%s, %s mode\n",
               colWidth, "database-stats:",
               db_int(0, "PRAGMA %s.page_count", zDb),
               db_int(0, "PRAGMA %s.page_size", zDb),
               db_int(0, "PRAGMA %s.freelist_count", zDb),
               db_text(0, "PRAGMA %s.encoding", zDb),
               db_text(0, "PRAGMA %s.journal_mode", zDb));

}



/*
** WEBPAGE: urllist
**
** Show ways in which this repository has been accessed
*/
void urllist_page(void){