Fossil SCM

merge trunk

jan.nijtmans 2012-10-16 01:22 use-utf8-in-win-external-editor merge
Commit 7f939bd8d7148059f4097c303cf4e00619ef36b1
+2 -2
--- src/captcha.c
+++ src/captcha.c
@@ -98,11 +98,11 @@
9898
}
9999
#endif /* CAPTCHA==1 */
100100
101101
102102
#if CAPTCHA==2
103
-static const char *azFont2[] = {
103
+static const char *const azFont2[] = {
104104
/* 0 */
105105
" __ ",
106106
" / \\ ",
107107
"| () |",
108108
" \\__/ ",
@@ -223,11 +223,11 @@
223223
return z;
224224
}
225225
#endif /* CAPTCHA==2 */
226226
227227
#if CAPTCHA==3
228
-static const char *azFont3[] = {
228
+static const char *const azFont3[] = {
229229
/* 0 */
230230
" ___ ",
231231
" / _ \\ ",
232232
"| | | |",
233233
"| | | |",
234234
--- src/captcha.c
+++ src/captcha.c
@@ -98,11 +98,11 @@
98 }
99 #endif /* CAPTCHA==1 */
100
101
102 #if CAPTCHA==2
103 static const char *azFont2[] = {
104 /* 0 */
105 " __ ",
106 " / \\ ",
107 "| () |",
108 " \\__/ ",
@@ -223,11 +223,11 @@
223 return z;
224 }
225 #endif /* CAPTCHA==2 */
226
227 #if CAPTCHA==3
228 static const char *azFont3[] = {
229 /* 0 */
230 " ___ ",
231 " / _ \\ ",
232 "| | | |",
233 "| | | |",
234
--- src/captcha.c
+++ src/captcha.c
@@ -98,11 +98,11 @@
98 }
99 #endif /* CAPTCHA==1 */
100
101
102 #if CAPTCHA==2
103 static const char *const azFont2[] = {
104 /* 0 */
105 " __ ",
106 " / \\ ",
107 "| () |",
108 " \\__/ ",
@@ -223,11 +223,11 @@
223 return z;
224 }
225 #endif /* CAPTCHA==2 */
226
227 #if CAPTCHA==3
228 static const char *const azFont3[] = {
229 /* 0 */
230 " ___ ",
231 " / _ \\ ",
232 "| | | |",
233 "| | | |",
234
+2 -2
--- src/cgi.c
+++ src/cgi.c
@@ -1354,13 +1354,13 @@
13541354
13551355
13561356
/*
13571357
** Name of days and months.
13581358
*/
1359
-static const char *azDays[] =
1359
+static const char *const azDays[] =
13601360
{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", 0};
1361
-static const char *azMonths[] =
1361
+static const char *const azMonths[] =
13621362
{"Jan", "Feb", "Mar", "Apr", "May", "Jun",
13631363
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec", 0};
13641364
13651365
13661366
/*
13671367
--- src/cgi.c
+++ src/cgi.c
@@ -1354,13 +1354,13 @@
1354
1355
1356 /*
1357 ** Name of days and months.
1358 */
1359 static const char *azDays[] =
1360 {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", 0};
1361 static const char *azMonths[] =
1362 {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
1363 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", 0};
1364
1365
1366 /*
1367
--- src/cgi.c
+++ src/cgi.c
@@ -1354,13 +1354,13 @@
1354
1355
1356 /*
1357 ** Name of days and months.
1358 */
1359 static const char *const azDays[] =
1360 {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", 0};
1361 static const char *const azMonths[] =
1362 {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
1363 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", 0};
1364
1365
1366 /*
1367
--- src/content.c
+++ src/content.c
@@ -894,5 +894,37 @@
894894
}
895895
db_finalize(&q);
896896
fossil_print("%d non-phantom blobs (out of %d total) checked: %d errors\n",
897897
n2, n1, nErr);
898898
}
899
+
900
+/*
901
+** COMMAND: test-orphans
902
+**
903
+** Search the repository for orphaned artifacts
904
+*/
905
+void test_orphans(void){
906
+ Stmt q;
907
+ int cnt = 0;
908
+
909
+ db_find_and_open_repository(0, 0);
910
+ db_multi_exec(
911
+ "CREATE TEMP TABLE used(id INTEGER PRIMARY KEY ON CONFLICT IGNORE);"
912
+ "INSERT INTO used SELECT mid FROM mlink;" /* Manifests */
913
+ "INSERT INTO used SELECT fid FROM mlink;" /* Files */
914
+ "INSERT INTO used SELECT srcid FROM tagxref WHERE srcid>0;" /* Tags */
915
+ "INSERT INTO used SELECT rid FROM tagxref;" /* Wiki & tickets */
916
+ "INSERT INTO used SELECT rid FROM attachment JOIN blob ON src=uuid;"
917
+ "INSERT INTO used SELECT attachid FROM attachment;"
918
+ "INSERT INTO used SELECT objid FROM event;"
919
+ );
920
+ db_prepare(&q, "SELECT rid, uuid, size FROM blob WHERE rid NOT IN used");
921
+ while( db_step(&q)==SQLITE_ROW ){
922
+ fossil_print("%7d %s size: %d\n",
923
+ db_column_int(&q, 0),
924
+ db_column_text(&q, 1),
925
+ db_column_int(&q,2));
926
+ cnt++;
927
+ }
928
+ db_finalize(&q);
929
+ fossil_print("%d orphans\n", cnt);
930
+}
899931
--- src/content.c
+++ src/content.c
@@ -894,5 +894,37 @@
894 }
895 db_finalize(&q);
896 fossil_print("%d non-phantom blobs (out of %d total) checked: %d errors\n",
897 n2, n1, nErr);
898 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
899
--- src/content.c
+++ src/content.c
@@ -894,5 +894,37 @@
894 }
895 db_finalize(&q);
896 fossil_print("%d non-phantom blobs (out of %d total) checked: %d errors\n",
897 n2, n1, nErr);
898 }
899
900 /*
901 ** COMMAND: test-orphans
902 **
903 ** Search the repository for orphaned artifacts
904 */
905 void test_orphans(void){
906 Stmt q;
907 int cnt = 0;
908
909 db_find_and_open_repository(0, 0);
910 db_multi_exec(
911 "CREATE TEMP TABLE used(id INTEGER PRIMARY KEY ON CONFLICT IGNORE);"
912 "INSERT INTO used SELECT mid FROM mlink;" /* Manifests */
913 "INSERT INTO used SELECT fid FROM mlink;" /* Files */
914 "INSERT INTO used SELECT srcid FROM tagxref WHERE srcid>0;" /* Tags */
915 "INSERT INTO used SELECT rid FROM tagxref;" /* Wiki & tickets */
916 "INSERT INTO used SELECT rid FROM attachment JOIN blob ON src=uuid;"
917 "INSERT INTO used SELECT attachid FROM attachment;"
918 "INSERT INTO used SELECT objid FROM event;"
919 );
920 db_prepare(&q, "SELECT rid, uuid, size FROM blob WHERE rid NOT IN used");
921 while( db_step(&q)==SQLITE_ROW ){
922 fossil_print("%7d %s size: %d\n",
923 db_column_int(&q, 0),
924 db_column_text(&q, 1),
925 db_column_int(&q,2));
926 cnt++;
927 }
928 db_finalize(&q);
929 fossil_print("%d orphans\n", cnt);
930 }
931
+2 -2
--- src/db.c
+++ src/db.c
@@ -1609,19 +1609,19 @@
16091609
16101610
/*
16111611
** Return true if the string zVal represents "true" (or "false").
16121612
*/
16131613
int is_truth(const char *zVal){
1614
- static const char *azOn[] = { "on", "yes", "true", "1" };
1614
+ static const char *const azOn[] = { "on", "yes", "true", "1" };
16151615
int i;
16161616
for(i=0; i<sizeof(azOn)/sizeof(azOn[0]); i++){
16171617
if( fossil_stricmp(zVal,azOn[i])==0 ) return 1;
16181618
}
16191619
return 0;
16201620
}
16211621
int is_false(const char *zVal){
1622
- static const char *azOff[] = { "off", "no", "false", "0" };
1622
+ static const char *const azOff[] = { "off", "no", "false", "0" };
16231623
int i;
16241624
for(i=0; i<sizeof(azOff)/sizeof(azOff[0]); i++){
16251625
if( fossil_stricmp(zVal,azOff[i])==0 ) return 1;
16261626
}
16271627
return 0;
16281628
--- src/db.c
+++ src/db.c
@@ -1609,19 +1609,19 @@
1609
1610 /*
1611 ** Return true if the string zVal represents "true" (or "false").
1612 */
1613 int is_truth(const char *zVal){
1614 static const char *azOn[] = { "on", "yes", "true", "1" };
1615 int i;
1616 for(i=0; i<sizeof(azOn)/sizeof(azOn[0]); i++){
1617 if( fossil_stricmp(zVal,azOn[i])==0 ) return 1;
1618 }
1619 return 0;
1620 }
1621 int is_false(const char *zVal){
1622 static const char *azOff[] = { "off", "no", "false", "0" };
1623 int i;
1624 for(i=0; i<sizeof(azOff)/sizeof(azOff[0]); i++){
1625 if( fossil_stricmp(zVal,azOff[i])==0 ) return 1;
1626 }
1627 return 0;
1628
--- src/db.c
+++ src/db.c
@@ -1609,19 +1609,19 @@
1609
1610 /*
1611 ** Return true if the string zVal represents "true" (or "false").
1612 */
1613 int is_truth(const char *zVal){
1614 static const char *const azOn[] = { "on", "yes", "true", "1" };
1615 int i;
1616 for(i=0; i<sizeof(azOn)/sizeof(azOn[0]); i++){
1617 if( fossil_stricmp(zVal,azOn[i])==0 ) return 1;
1618 }
1619 return 0;
1620 }
1621 int is_false(const char *zVal){
1622 static const char *const azOff[] = { "off", "no", "false", "0" };
1623 int i;
1624 for(i=0; i<sizeof(azOff)/sizeof(azOff[0]); i++){
1625 if( fossil_stricmp(zVal,azOff[i])==0 ) return 1;
1626 }
1627 return 0;
1628
+9 -5
--- src/name.c
+++ src/name.c
@@ -253,15 +253,19 @@
253253
if( rid>0 ) return rid;
254254
255255
/* Undocumented: numeric tags get translated directly into the RID */
256256
for(i=0; fossil_isdigit(zTag[i]); i++){}
257257
if( zTag[i]==0 ){
258
- rid = db_int(0,
259
- "SELECT event.objid"
260
- " FROM event"
261
- " WHERE event.objid=%s"
262
- " AND event.type GLOB '%q'", zTag, zType);
258
+ if( strcmp(zType,"*")==0 ){
259
+ rid = atoi(zTag);
260
+ }else{
261
+ rid = db_int(0,
262
+ "SELECT event.objid"
263
+ " FROM event"
264
+ " WHERE event.objid=%s"
265
+ " AND event.type GLOB '%q'", zTag, zType);
266
+ }
263267
}
264268
return rid;
265269
}
266270
267271
268272
--- src/name.c
+++ src/name.c
@@ -253,15 +253,19 @@
253 if( rid>0 ) return rid;
254
255 /* Undocumented: numeric tags get translated directly into the RID */
256 for(i=0; fossil_isdigit(zTag[i]); i++){}
257 if( zTag[i]==0 ){
258 rid = db_int(0,
259 "SELECT event.objid"
260 " FROM event"
261 " WHERE event.objid=%s"
262 " AND event.type GLOB '%q'", zTag, zType);
 
 
 
 
263 }
264 return rid;
265 }
266
267
268
--- src/name.c
+++ src/name.c
@@ -253,15 +253,19 @@
253 if( rid>0 ) return rid;
254
255 /* Undocumented: numeric tags get translated directly into the RID */
256 for(i=0; fossil_isdigit(zTag[i]); i++){}
257 if( zTag[i]==0 ){
258 if( strcmp(zType,"*")==0 ){
259 rid = atoi(zTag);
260 }else{
261 rid = db_int(0,
262 "SELECT event.objid"
263 " FROM event"
264 " WHERE event.objid=%s"
265 " AND event.type GLOB '%q'", zTag, zType);
266 }
267 }
268 return rid;
269 }
270
271
272
+1 -1
--- src/report.c
+++ src/report.c
@@ -170,11 +170,11 @@
170170
case SQLITE_SELECT:
171171
case SQLITE_FUNCTION: {
172172
break;
173173
}
174174
case SQLITE_READ: {
175
- static const char *azAllowed[] = {
175
+ static const char *const azAllowed[] = {
176176
"ticket",
177177
"blob",
178178
"filename",
179179
"mlink",
180180
"plink",
181181
--- src/report.c
+++ src/report.c
@@ -170,11 +170,11 @@
170 case SQLITE_SELECT:
171 case SQLITE_FUNCTION: {
172 break;
173 }
174 case SQLITE_READ: {
175 static const char *azAllowed[] = {
176 "ticket",
177 "blob",
178 "filename",
179 "mlink",
180 "plink",
181
--- src/report.c
+++ src/report.c
@@ -170,11 +170,11 @@
170 case SQLITE_SELECT:
171 case SQLITE_FUNCTION: {
172 break;
173 }
174 case SQLITE_READ: {
175 static const char *const azAllowed[] = {
176 "ticket",
177 "blob",
178 "filename",
179 "mlink",
180 "plink",
181
+6
--- src/tkt.c
+++ src/tkt.c
@@ -433,10 +433,11 @@
433433
){
434434
char *zDate;
435435
const char *zUuid;
436436
int i;
437437
int rid;
438
+ int nJ = 0;
438439
Blob tktchng, cksum;
439440
440441
login_verify_csrf_secret();
441442
zUuid = (const char *)pUuid;
442443
blob_zero(&tktchng);
@@ -461,10 +462,11 @@
461462
zValue = db_conceal(zValue, nValue);
462463
blob_appendf(&tktchng, "J %s %s\n", azField[i], zValue);
463464
}else{
464465
blob_appendf(&tktchng, "J %s %#F\n", azField[i], nValue, zValue);
465466
}
467
+ nJ++;
466468
}
467469
}
468470
}
469471
if( *(char**)pUuid ){
470472
zUuid = db_text(0,
@@ -476,10 +478,14 @@
476478
*(const char**)pUuid = zUuid;
477479
blob_appendf(&tktchng, "K %s\n", zUuid);
478480
blob_appendf(&tktchng, "U %F\n", g.zLogin ? g.zLogin : "");
479481
md5sum_blob(&tktchng, &cksum);
480482
blob_appendf(&tktchng, "Z %b\n", &cksum);
483
+ if( nJ==0 ){
484
+ blob_reset(&tktchng);
485
+ return TH_OK;
486
+ }
481487
if( g.zPath[0]=='d' ){
482488
/* If called from /debug_tktnew or /debug_tktedit... */
483489
@ <font color="blue">
484490
@ <p>Ticket artifact that would have been submitted:</p>
485491
@ <blockquote><pre>%h(blob_str(&tktchng))</pre></blockquote>
486492
--- src/tkt.c
+++ src/tkt.c
@@ -433,10 +433,11 @@
433 ){
434 char *zDate;
435 const char *zUuid;
436 int i;
437 int rid;
 
438 Blob tktchng, cksum;
439
440 login_verify_csrf_secret();
441 zUuid = (const char *)pUuid;
442 blob_zero(&tktchng);
@@ -461,10 +462,11 @@
461 zValue = db_conceal(zValue, nValue);
462 blob_appendf(&tktchng, "J %s %s\n", azField[i], zValue);
463 }else{
464 blob_appendf(&tktchng, "J %s %#F\n", azField[i], nValue, zValue);
465 }
 
466 }
467 }
468 }
469 if( *(char**)pUuid ){
470 zUuid = db_text(0,
@@ -476,10 +478,14 @@
476 *(const char**)pUuid = zUuid;
477 blob_appendf(&tktchng, "K %s\n", zUuid);
478 blob_appendf(&tktchng, "U %F\n", g.zLogin ? g.zLogin : "");
479 md5sum_blob(&tktchng, &cksum);
480 blob_appendf(&tktchng, "Z %b\n", &cksum);
 
 
 
 
481 if( g.zPath[0]=='d' ){
482 /* If called from /debug_tktnew or /debug_tktedit... */
483 @ <font color="blue">
484 @ <p>Ticket artifact that would have been submitted:</p>
485 @ <blockquote><pre>%h(blob_str(&tktchng))</pre></blockquote>
486
--- src/tkt.c
+++ src/tkt.c
@@ -433,10 +433,11 @@
433 ){
434 char *zDate;
435 const char *zUuid;
436 int i;
437 int rid;
438 int nJ = 0;
439 Blob tktchng, cksum;
440
441 login_verify_csrf_secret();
442 zUuid = (const char *)pUuid;
443 blob_zero(&tktchng);
@@ -461,10 +462,11 @@
462 zValue = db_conceal(zValue, nValue);
463 blob_appendf(&tktchng, "J %s %s\n", azField[i], zValue);
464 }else{
465 blob_appendf(&tktchng, "J %s %#F\n", azField[i], nValue, zValue);
466 }
467 nJ++;
468 }
469 }
470 }
471 if( *(char**)pUuid ){
472 zUuid = db_text(0,
@@ -476,10 +478,14 @@
478 *(const char**)pUuid = zUuid;
479 blob_appendf(&tktchng, "K %s\n", zUuid);
480 blob_appendf(&tktchng, "U %F\n", g.zLogin ? g.zLogin : "");
481 md5sum_blob(&tktchng, &cksum);
482 blob_appendf(&tktchng, "Z %b\n", &cksum);
483 if( nJ==0 ){
484 blob_reset(&tktchng);
485 return TH_OK;
486 }
487 if( g.zPath[0]=='d' ){
488 /* If called from /debug_tktnew or /debug_tktedit... */
489 @ <font color="blue">
490 @ <p>Ticket artifact that would have been submitted:</p>
491 @ <blockquote><pre>%h(blob_str(&tktchng))</pre></blockquote>
492
+1 -1
--- src/xfer.c
+++ src/xfer.c
@@ -270,11 +270,11 @@
270270
int rid, /* record id of the file to send */
271271
int isPrivate, /* True if rid is a private artifact */
272272
Blob *pContent, /* The content of the file to send */
273273
Blob *pUuid /* The UUID of the file to send */
274274
){
275
- static const char *azQuery[] = {
275
+ static const char *const azQuery[] = {
276276
"SELECT pid FROM plink x"
277277
" WHERE cid=%d"
278278
" AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)"
279279
" AND NOT EXISTS(SELECT 1 FROM plink y"
280280
" WHERE y.pid=x.cid AND y.cid=x.pid)",
281281
--- src/xfer.c
+++ src/xfer.c
@@ -270,11 +270,11 @@
270 int rid, /* record id of the file to send */
271 int isPrivate, /* True if rid is a private artifact */
272 Blob *pContent, /* The content of the file to send */
273 Blob *pUuid /* The UUID of the file to send */
274 ){
275 static const char *azQuery[] = {
276 "SELECT pid FROM plink x"
277 " WHERE cid=%d"
278 " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)"
279 " AND NOT EXISTS(SELECT 1 FROM plink y"
280 " WHERE y.pid=x.cid AND y.cid=x.pid)",
281
--- src/xfer.c
+++ src/xfer.c
@@ -270,11 +270,11 @@
270 int rid, /* record id of the file to send */
271 int isPrivate, /* True if rid is a private artifact */
272 Blob *pContent, /* The content of the file to send */
273 Blob *pUuid /* The UUID of the file to send */
274 ){
275 static const char *const azQuery[] = {
276 "SELECT pid FROM plink x"
277 " WHERE cid=%d"
278 " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)"
279 " AND NOT EXISTS(SELECT 1 FROM plink y"
280 " WHERE y.pid=x.cid AND y.cid=x.pid)",
281

Keyboard Shortcuts

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