Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add the "fossil test-missing" command. Make test-missing and test-orphans available to "fossil all". |
|---|---|
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
eb949991434d3e1a33abd8d15df867c5 |
| User & Date: | drh 2012-10-31 14:15:14.216 |
Context
|
2012-10-31
| ||
| 14:56 | Some more style en comment fixes, backported from [d57f0a9361], that I missed before. check-in: 1e2fdf98bc user: jan.nijtmans tags: trunk | |
| 14:15 | Add the "fossil test-missing" command. Make test-missing and test-orphans available to "fossil all". check-in: eb94999143 user: drh tags: trunk | |
| 12:12 | Enhance the control-artifact parser to optionally return an error when the parse fails. Fix a bug in the artifact parser which caused it to ignore Z-card checksum failures. check-in: aab9e66b8b user: drh tags: trunk | |
Changes
Changes to src/allrepo.c.
| ︙ | ︙ | |||
146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
collect_argument(&extra, "deanalyze");
collect_argument(&extra, "wal");
collect_argument(&extra, "stat");
}else if( strncmp(zCmd, "sync", n)==0 ){
zCmd = "sync -autourl -R";
}else if( strncmp(zCmd, "test-integrity", n)==0 ){
zCmd = "test-integrity";
}else if( strncmp(zCmd, "changes", n)==0 ){
zCmd = "changes --quiet --header --chdir";
useCheckouts = 1;
stopOnError = 0;
quiet = 1;
}else if( strncmp(zCmd, "ignore", n)==0 ){
int j;
| > > > > > | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
collect_argument(&extra, "deanalyze");
collect_argument(&extra, "wal");
collect_argument(&extra, "stat");
}else if( strncmp(zCmd, "sync", n)==0 ){
zCmd = "sync -autourl -R";
}else if( strncmp(zCmd, "test-integrity", n)==0 ){
zCmd = "test-integrity";
}else if( strncmp(zCmd, "test-orphans", n)==0 ){
zCmd = "test-orphans -R";
}else if( strncmp(zCmd, "test-missing", n)==0 ){
zCmd = "test-missing -q -R";
collect_argument(&extra, "notshunned");
}else if( strncmp(zCmd, "changes", n)==0 ){
zCmd = "changes --quiet --header --chdir";
useCheckouts = 1;
stopOnError = 0;
quiet = 1;
}else if( strncmp(zCmd, "ignore", n)==0 ){
int j;
|
| ︙ | ︙ |
Changes to src/content.c.
| ︙ | ︙ | |||
924 925 926 927 928 929 930 |
db_column_text(&q, 1),
db_column_int(&q,2));
cnt++;
}
db_finalize(&q);
fossil_print("%d orphans\n", cnt);
}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 |
db_column_text(&q, 1),
db_column_int(&q,2));
cnt++;
}
db_finalize(&q);
fossil_print("%d orphans\n", cnt);
}
/* Allowed flags for check_exists */
#define MISSING_SHUNNED 0x0001 /* Do not report shunned artifacts */
/* This is a helper routine for test-artifacts.
**
** Check to see that artifact zUuid exists in the repository. If it does,
** return 0. If it does not, generate an error message and return 1.
*/
static int check_exists(
const char *zUuid, /* The artifact we are checking for */
unsigned flags, /* Flags */
Manifest *p, /* The control artifact that references zUuid */
const char *zRole, /* Role of zUuid in p */
const char *zDetail /* Additional information, such as a filename */
){
static Stmt q;
int rc = 0;
db_static_prepare(&q, "SELECT size FROM blob WHERE uuid=:uuid");
if( zUuid==0 || zUuid[0]==0 ) return 0;
db_bind_text(&q, ":uuid", zUuid);
if( db_step(&q)==SQLITE_ROW ){
int size = db_column_int(&q, 0);
if( size<0 ) rc = 2;
}else{
rc = 1;
}
db_reset(&q);
if( rc ){
const char *zCFType = "control artifact";
char *zSrc;
char *zDate;
char *zErrType = "MISSING";
if( db_exists("SELECT 1 FROM shun WHERE uuid=%Q", zUuid) ){
if( flags & MISSING_SHUNNED ) return 0;
zErrType = "SHUNNED";
}
switch( p->type ){
case CFTYPE_MANIFEST: zCFType = "check-in"; break;
case CFTYPE_CLUSTER: zCFType = "cluster"; break;
case CFTYPE_CONTROL: zCFType = "tag"; break;
case CFTYPE_WIKI: zCFType = "wiki"; break;
case CFTYPE_TICKET: zCFType = "ticket"; break;
case CFTYPE_ATTACHMENT: zCFType = "attachment"; break;
case CFTYPE_EVENT: zCFType = "event"; break;
}
zSrc = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", p->rid);
if( p->rDate>0.0 ){
zDate = db_text(0, "SELECT datetime(%.17g)", p->rDate);
}else{
zDate = db_text(0,
"SELECT datetime(rcvfrom.mtime)"
" FROM blob, rcvfrom"
" WHERE blob.rcvid=rcvfrom.rcvid"
" AND blob.rid=%d", p->rid);
}
fossil_print("%s: %s\n %s %s %S (%d) %s\n",
zErrType, zUuid, zRole, zCFType, zSrc, p->rid, zDate);
if( zDetail && zDetail[0] ){
fossil_print(" %s\n", zDetail);
}
fossil_free(zSrc);
fossil_free(zDate);
rc = 1;
}
return rc;
}
/*
** COMMAND: test-missing
**
** Usage: %fossil test-missing
**
** Look at every artifact in the repository and verify that
** all references are satisfied. Report any referenced artifacts
** that are missing or shunned.
**
** Options:
**
** --notshunned Do not report shunned artifacts
** --quiet Only show output if there are errors
*/
void test_missing(void){
Stmt q;
Blob content;
int nErr = 0;
int nArtifact = 0;
int i;
Manifest *p;
unsigned flags = 0;
int quietFlag;
if( find_option("notshunned", 0, 0)!=0 ) flags |= MISSING_SHUNNED;
quietFlag = find_option("quiet","q",0)!=0;
db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
db_prepare(&q,
"SELECT mid FROM mlink UNION "
"SELECT srcid FROM tagxref WHERE srcid>0 UNION "
"SELECT rid FROM tagxref UNION "
"SELECT rid FROM attachment JOIN blob ON src=uuid UNION "
"SELECT objid FROM event");
while( db_step(&q)==SQLITE_ROW ){
int rid = db_column_int(&q, 0);
content_get(rid, &content);
p = manifest_parse(&content, rid, 0);
if( p ){
nArtifact++;
nErr += check_exists(p->zBaseline, flags, p, "baseline of", 0);
nErr += check_exists(p->zAttachSrc, flags, p, "file of", 0);
for(i=0; i<p->nFile; i++){
nErr += check_exists(p->aFile[i].zUuid, flags, p, "file of",
p->aFile[i].zName);
}
for(i=0; i<p->nParent; i++){
nErr += check_exists(p->azParent[i], flags, p, "parent of", 0);
}
for(i=0; i<p->nCherrypick; i++){
nErr += check_exists(p->aCherrypick[i].zCPTarget+1, flags, p,
"cherry-pick target of", 0);
nErr += check_exists(p->aCherrypick[i].zCPBase, flags, p,
"cherry-pick baseline of", 0);
}
for(i=0; i<p->nCChild; i++){
nErr += check_exists(p->azCChild[i], flags, p, "in", 0);
}
for(i=0; i<p->nTag; i++){
nErr += check_exists(p->aTag[i].zUuid, flags, p, "target of", 0);
}
manifest_destroy(p);
}
}
db_finalize(&q);
if( nErr>0 || quietFlag==0 ){
fossil_print("%d missing or shunned references in %d control artifacts\n",
nErr, nArtifact);
}
}
|