Fossil SCM

Show the current hash policy on the "Database Stats" line of the /stat screen.

drh 2017-03-05 00:21 fossil-2.1
Commit 2ca8bc8baacdcc562426862ac4b61f6b534d277e
2 files changed +14 -3 +2 -1
+14 -3
--- src/hname.c
+++ src/hname.c
@@ -211,10 +211,24 @@
211211
return HPOLICY_SHA3;
212212
}else{
213213
return HPOLICY_AUTO;
214214
}
215215
}
216
+
217
+/*
218
+** Names of the hash policies.
219
+*/
220
+static const char *azPolicy[] = {
221
+ "sha1", "auto", "sha3", "sha3-only", "shun-sha1"
222
+};
223
+
224
+/* Return the name of the current hash policy.
225
+*/
226
+const char *hpolicy_name(void){
227
+ return azPolicy[g.eHashPolicy];
228
+}
229
+
216230
217231
/*
218232
** COMMAND: hash-policy*
219233
**
220234
** Usage: fossil hash-policy ?NEW-POLICY?
@@ -242,13 +256,10 @@
242256
** immediately promote to "sha3" if the repository contains one or more
243257
** artifacts with SHA3 names. The default hash policy for new repositories
244258
** is "shun-sha1".
245259
*/
246260
void hash_policy_command(void){
247
- static const char *azPolicy[] = {
248
- "sha1", "auto", "sha3", "sha3-only", "shun-sha1"
249
- };
250261
int i;
251262
db_find_and_open_repository(0, 0);
252263
if( g.argc!=2 && g.argc!=3 ) usage("?NEW-POLICY?");
253264
if( g.argc==2 ){
254265
fossil_print("%s\n", azPolicy[g.eHashPolicy]);
255266
--- src/hname.c
+++ src/hname.c
@@ -211,10 +211,24 @@
211 return HPOLICY_SHA3;
212 }else{
213 return HPOLICY_AUTO;
214 }
215 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
217 /*
218 ** COMMAND: hash-policy*
219 **
220 ** Usage: fossil hash-policy ?NEW-POLICY?
@@ -242,13 +256,10 @@
242 ** immediately promote to "sha3" if the repository contains one or more
243 ** artifacts with SHA3 names. The default hash policy for new repositories
244 ** is "shun-sha1".
245 */
246 void hash_policy_command(void){
247 static const char *azPolicy[] = {
248 "sha1", "auto", "sha3", "sha3-only", "shun-sha1"
249 };
250 int i;
251 db_find_and_open_repository(0, 0);
252 if( g.argc!=2 && g.argc!=3 ) usage("?NEW-POLICY?");
253 if( g.argc==2 ){
254 fossil_print("%s\n", azPolicy[g.eHashPolicy]);
255
--- src/hname.c
+++ src/hname.c
@@ -211,10 +211,24 @@
211 return HPOLICY_SHA3;
212 }else{
213 return HPOLICY_AUTO;
214 }
215 }
216
217 /*
218 ** Names of the hash policies.
219 */
220 static const char *azPolicy[] = {
221 "sha1", "auto", "sha3", "sha3-only", "shun-sha1"
222 };
223
224 /* Return the name of the current hash policy.
225 */
226 const char *hpolicy_name(void){
227 return azPolicy[g.eHashPolicy];
228 }
229
230
231 /*
232 ** COMMAND: hash-policy*
233 **
234 ** Usage: fossil hash-policy ?NEW-POLICY?
@@ -242,13 +256,10 @@
256 ** immediately promote to "sha3" if the repository contains one or more
257 ** artifacts with SHA3 names. The default hash policy for new repositories
258 ** is "shun-sha1".
259 */
260 void hash_policy_command(void){
 
 
 
261 int i;
262 db_find_and_open_repository(0, 0);
263 if( g.argc!=2 && g.argc!=3 ) usage("?NEW-POLICY?");
264 if( g.argc==2 ){
265 fossil_print("%s\n", azPolicy[g.eHashPolicy]);
266
+2 -1
--- src/stat.c
+++ src/stat.c
@@ -192,11 +192,12 @@
192192
@ <tr><th>Database&nbsp;Stats:</th><td>
193193
@ %d(db_int(0, "PRAGMA repository.page_count")) pages,
194194
@ %d(db_int(0, "PRAGMA repository.page_size")) bytes/page,
195195
@ %d(db_int(0, "PRAGMA repository.freelist_count")) free pages,
196196
@ %s(db_text(0, "PRAGMA repository.encoding")),
197
- @ %s(db_text(0, "PRAGMA repository.journal_mode")) mode
197
+ @ %s(db_text(0, "PRAGMA repository.journal_mode")) mode,
198
+ @ hash %s(hpolicy_name())
198199
@ </td></tr>
199200
200201
@ </table>
201202
style_footer();
202203
}
203204
--- src/stat.c
+++ src/stat.c
@@ -192,11 +192,12 @@
192 @ <tr><th>Database&nbsp;Stats:</th><td>
193 @ %d(db_int(0, "PRAGMA repository.page_count")) pages,
194 @ %d(db_int(0, "PRAGMA repository.page_size")) bytes/page,
195 @ %d(db_int(0, "PRAGMA repository.freelist_count")) free pages,
196 @ %s(db_text(0, "PRAGMA repository.encoding")),
197 @ %s(db_text(0, "PRAGMA repository.journal_mode")) mode
 
198 @ </td></tr>
199
200 @ </table>
201 style_footer();
202 }
203
--- src/stat.c
+++ src/stat.c
@@ -192,11 +192,12 @@
192 @ <tr><th>Database&nbsp;Stats:</th><td>
193 @ %d(db_int(0, "PRAGMA repository.page_count")) pages,
194 @ %d(db_int(0, "PRAGMA repository.page_size")) bytes/page,
195 @ %d(db_int(0, "PRAGMA repository.freelist_count")) free pages,
196 @ %s(db_text(0, "PRAGMA repository.encoding")),
197 @ %s(db_text(0, "PRAGMA repository.journal_mode")) mode,
198 @ hash %s(hpolicy_name())
199 @ </td></tr>
200
201 @ </table>
202 style_footer();
203 }
204

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button