Fossil SCM
Improvements to the test-integrity command so that it detects the kinds of repository problems injected when cloning a repo that contains private check-ins.
Commit
697d6bfd8ed2fab6442884f2fdb931fd1fb96a7d
Parent
a57d6ee139028a2…
1 file changed
+31
-5
+31
-5
| --- src/content.c | ||
| +++ src/content.c | ||
| @@ -828,12 +828,35 @@ | ||
| 828 | 828 | Stmt q; |
| 829 | 829 | Blob content; |
| 830 | 830 | Blob cksum; |
| 831 | 831 | int n1 = 0; |
| 832 | 832 | int n2 = 0; |
| 833 | + int nErr = 0; | |
| 833 | 834 | int total; |
| 834 | 835 | db_find_and_open_repository(OPEN_ANY_SCHEMA, 2); |
| 836 | + | |
| 837 | + /* Make sure no public artifact is a delta from a private artifact */ | |
| 838 | + db_prepare(&q, | |
| 839 | + "SELECT " | |
| 840 | + " rid, (SELECT uuid FROM blob WHERE rid=delta.rid)," | |
| 841 | + " srcid, (SELECT uuid FROM blob WHERE rid=delta.srcid)" | |
| 842 | + " FROM delta" | |
| 843 | + " WHERE srcid in private AND rid NOT IN private" | |
| 844 | + ); | |
| 845 | + while( db_step(&q)==SQLITE_ROW ){ | |
| 846 | + int rid = db_column_int(&q, 0); | |
| 847 | + const char *zId = db_column_text(&q, 1); | |
| 848 | + int srcid = db_column_int(&q, 2); | |
| 849 | + const char *zSrc = db_column_text(&q, 3); | |
| 850 | + fossil_print( | |
| 851 | + "public artifact %S (%d) is a delta from private artifact %S (%d)\n", | |
| 852 | + zId, rid, zSrc, srcid | |
| 853 | + ); | |
| 854 | + nErr++; | |
| 855 | + } | |
| 856 | + db_finalize(&q); | |
| 857 | + | |
| 835 | 858 | db_prepare(&q, "SELECT rid, uuid, size FROM blob ORDER BY rid"); |
| 836 | 859 | total = db_int(0, "SELECT max(rid) FROM blob"); |
| 837 | 860 | while( db_step(&q)==SQLITE_ROW ){ |
| 838 | 861 | int rid = db_column_int(&q, 0); |
| 839 | 862 | const char *zUuid = db_column_text(&q, 1); |
| @@ -845,20 +868,23 @@ | ||
| 845 | 868 | fossil_print("skip phantom %d %s\n", rid, zUuid); |
| 846 | 869 | continue; /* Ignore phantoms */ |
| 847 | 870 | } |
| 848 | 871 | content_get(rid, &content); |
| 849 | 872 | if( blob_size(&content)!=size ){ |
| 850 | - fossil_warning("size mismatch on blob rid=%d: %d vs %d", | |
| 851 | - rid, blob_size(&content), size); | |
| 873 | + fossil_print("size mismatch on artifact %d: wanted %d but got %d\n", | |
| 874 | + rid, size, blob_size(&content)); | |
| 875 | + nErr++; | |
| 852 | 876 | } |
| 853 | 877 | sha1sum_blob(&content, &cksum); |
| 854 | 878 | if( fossil_strcmp(blob_str(&cksum), zUuid)!=0 ){ |
| 855 | - fossil_fatal("checksum mismatch on blob rid=%d: %s vs %s", | |
| 856 | - rid, blob_str(&cksum), zUuid); | |
| 879 | + fossil_print("checksum mismatch on artifact %d: wanted %s but got %s\n", | |
| 880 | + rid, zUuid, blob_str(&cksum)); | |
| 881 | + nErr++; | |
| 857 | 882 | } |
| 858 | 883 | blob_reset(&cksum); |
| 859 | 884 | blob_reset(&content); |
| 860 | 885 | n2++; |
| 861 | 886 | } |
| 862 | 887 | db_finalize(&q); |
| 863 | - fossil_print("%d non-phantom blobs (out of %d total) verified\n", n2, n1); | |
| 888 | + fossil_print("%d non-phantom blobs (out of %d total) checked: %d errors\n", | |
| 889 | + n2, n1, nErr); | |
| 864 | 890 | } |
| 865 | 891 |
| --- src/content.c | |
| +++ src/content.c | |
| @@ -828,12 +828,35 @@ | |
| 828 | Stmt q; |
| 829 | Blob content; |
| 830 | Blob cksum; |
| 831 | int n1 = 0; |
| 832 | int n2 = 0; |
| 833 | int total; |
| 834 | db_find_and_open_repository(OPEN_ANY_SCHEMA, 2); |
| 835 | db_prepare(&q, "SELECT rid, uuid, size FROM blob ORDER BY rid"); |
| 836 | total = db_int(0, "SELECT max(rid) FROM blob"); |
| 837 | while( db_step(&q)==SQLITE_ROW ){ |
| 838 | int rid = db_column_int(&q, 0); |
| 839 | const char *zUuid = db_column_text(&q, 1); |
| @@ -845,20 +868,23 @@ | |
| 845 | fossil_print("skip phantom %d %s\n", rid, zUuid); |
| 846 | continue; /* Ignore phantoms */ |
| 847 | } |
| 848 | content_get(rid, &content); |
| 849 | if( blob_size(&content)!=size ){ |
| 850 | fossil_warning("size mismatch on blob rid=%d: %d vs %d", |
| 851 | rid, blob_size(&content), size); |
| 852 | } |
| 853 | sha1sum_blob(&content, &cksum); |
| 854 | if( fossil_strcmp(blob_str(&cksum), zUuid)!=0 ){ |
| 855 | fossil_fatal("checksum mismatch on blob rid=%d: %s vs %s", |
| 856 | rid, blob_str(&cksum), zUuid); |
| 857 | } |
| 858 | blob_reset(&cksum); |
| 859 | blob_reset(&content); |
| 860 | n2++; |
| 861 | } |
| 862 | db_finalize(&q); |
| 863 | fossil_print("%d non-phantom blobs (out of %d total) verified\n", n2, n1); |
| 864 | } |
| 865 |
| --- src/content.c | |
| +++ src/content.c | |
| @@ -828,12 +828,35 @@ | |
| 828 | Stmt q; |
| 829 | Blob content; |
| 830 | Blob cksum; |
| 831 | int n1 = 0; |
| 832 | int n2 = 0; |
| 833 | int nErr = 0; |
| 834 | int total; |
| 835 | db_find_and_open_repository(OPEN_ANY_SCHEMA, 2); |
| 836 | |
| 837 | /* Make sure no public artifact is a delta from a private artifact */ |
| 838 | db_prepare(&q, |
| 839 | "SELECT " |
| 840 | " rid, (SELECT uuid FROM blob WHERE rid=delta.rid)," |
| 841 | " srcid, (SELECT uuid FROM blob WHERE rid=delta.srcid)" |
| 842 | " FROM delta" |
| 843 | " WHERE srcid in private AND rid NOT IN private" |
| 844 | ); |
| 845 | while( db_step(&q)==SQLITE_ROW ){ |
| 846 | int rid = db_column_int(&q, 0); |
| 847 | const char *zId = db_column_text(&q, 1); |
| 848 | int srcid = db_column_int(&q, 2); |
| 849 | const char *zSrc = db_column_text(&q, 3); |
| 850 | fossil_print( |
| 851 | "public artifact %S (%d) is a delta from private artifact %S (%d)\n", |
| 852 | zId, rid, zSrc, srcid |
| 853 | ); |
| 854 | nErr++; |
| 855 | } |
| 856 | db_finalize(&q); |
| 857 | |
| 858 | db_prepare(&q, "SELECT rid, uuid, size FROM blob ORDER BY rid"); |
| 859 | total = db_int(0, "SELECT max(rid) FROM blob"); |
| 860 | while( db_step(&q)==SQLITE_ROW ){ |
| 861 | int rid = db_column_int(&q, 0); |
| 862 | const char *zUuid = db_column_text(&q, 1); |
| @@ -845,20 +868,23 @@ | |
| 868 | fossil_print("skip phantom %d %s\n", rid, zUuid); |
| 869 | continue; /* Ignore phantoms */ |
| 870 | } |
| 871 | content_get(rid, &content); |
| 872 | if( blob_size(&content)!=size ){ |
| 873 | fossil_print("size mismatch on artifact %d: wanted %d but got %d\n", |
| 874 | rid, size, blob_size(&content)); |
| 875 | nErr++; |
| 876 | } |
| 877 | sha1sum_blob(&content, &cksum); |
| 878 | if( fossil_strcmp(blob_str(&cksum), zUuid)!=0 ){ |
| 879 | fossil_print("checksum mismatch on artifact %d: wanted %s but got %s\n", |
| 880 | rid, zUuid, blob_str(&cksum)); |
| 881 | nErr++; |
| 882 | } |
| 883 | blob_reset(&cksum); |
| 884 | blob_reset(&content); |
| 885 | n2++; |
| 886 | } |
| 887 | db_finalize(&q); |
| 888 | fossil_print("%d non-phantom blobs (out of %d total) checked: %d errors\n", |
| 889 | n2, n1, nErr); |
| 890 | } |
| 891 |