| | @@ -31,14 +31,22 @@ |
| 31 | 31 | /* |
| 32 | 32 | ** Generate text describing all changes. Prepend zPrefix to each line |
| 33 | 33 | ** of output. |
| 34 | 34 | ** |
| 35 | 35 | ** We assume that vfile_check_signature has been run. |
| 36 | +** |
| 37 | +** If missingIsFatal is true, then any files that are missing or which |
| 38 | +** are not true files results in a fatal error. |
| 36 | 39 | */ |
| 37 | | -static void status_report(Blob *report, const char *zPrefix){ |
| 40 | +static void status_report( |
| 41 | + Blob *report, /* Append the status report here */ |
| 42 | + const char *zPrefix, /* Prefix on each line of the report */ |
| 43 | + int missingIsFatal /* MISSING and NOT_A_FILE are fatal errors */ |
| 44 | +){ |
| 38 | 45 | Stmt q; |
| 39 | 46 | int nPrefix = strlen(zPrefix); |
| 47 | + int nErr = 0; |
| 40 | 48 | db_prepare(&q, |
| 41 | 49 | "SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)" |
| 42 | 50 | " FROM vfile " |
| 43 | 51 | " WHERE file_is_selected(id)" |
| 44 | 52 | " AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1" |
| | @@ -50,25 +58,37 @@ |
| 50 | 58 | int isNew = db_column_int(&q,3)==0; |
| 51 | 59 | int isRenamed = db_column_int(&q,4); |
| 52 | 60 | char *zFullName = mprintf("%s/%s", g.zLocalRoot, zPathname); |
| 53 | 61 | blob_append(report, zPrefix, nPrefix); |
| 54 | 62 | if( isDeleted ){ |
| 55 | | - blob_appendf(report, "DELETED %s\n", zPathname); |
| 56 | | - }else if( access(zFullName, 0) ){ |
| 57 | | - blob_appendf(report, "MISSING %s\n", zPathname); |
| 63 | + blob_appendf(report, "DELETED %s\n", zPathname); |
| 64 | + }else if( !file_isfile(zFullName) ){ |
| 65 | + if( access(zFullName, 0)==0 ){ |
| 66 | + blob_appendf(report, "NOT_A_FILE %s\n", zPathname); |
| 67 | + if( missingIsFatal ){ |
| 68 | + fossil_warning("not a file: %s", zPathname); |
| 69 | + nErr++; |
| 70 | + } |
| 71 | + }else{ |
| 72 | + blob_appendf(report, "MISSING %s\n", zPathname); |
| 73 | + if( missingIsFatal ){ |
| 74 | + fossil_warning("missing file: %s", zPathname); |
| 75 | + nErr++; |
| 76 | + } |
| 77 | + } |
| 58 | 78 | }else if( isNew ){ |
| 59 | | - blob_appendf(report, "ADDED %s\n", zPathname); |
| 79 | + blob_appendf(report, "ADDED %s\n", zPathname); |
| 60 | 80 | }else if( isDeleted ){ |
| 61 | | - blob_appendf(report, "DELETED %s\n", zPathname); |
| 81 | + blob_appendf(report, "DELETED %s\n", zPathname); |
| 62 | 82 | }else if( isChnged==2 ){ |
| 63 | 83 | blob_appendf(report, "UPDATED_BY_MERGE %s\n", zPathname); |
| 64 | 84 | }else if( isChnged==3 ){ |
| 65 | 85 | blob_appendf(report, "ADDED_BY_MERGE %s\n", zPathname); |
| 66 | 86 | }else if( isChnged==1 ){ |
| 67 | | - blob_appendf(report, "EDITED %s\n", zPathname); |
| 87 | + blob_appendf(report, "EDITED %s\n", zPathname); |
| 68 | 88 | }else if( isRenamed ){ |
| 69 | | - blob_appendf(report, "RENAMED %s\n", zPathname); |
| 89 | + blob_appendf(report, "RENAMED %s\n", zPathname); |
| 70 | 90 | } |
| 71 | 91 | free(zFullName); |
| 72 | 92 | } |
| 73 | 93 | db_finalize(&q); |
| 74 | 94 | db_prepare(&q, "SELECT uuid FROM vmerge JOIN blob ON merge=rid" |
| | @@ -76,10 +96,13 @@ |
| 76 | 96 | while( db_step(&q)==SQLITE_ROW ){ |
| 77 | 97 | blob_append(report, zPrefix, nPrefix); |
| 78 | 98 | blob_appendf(report, "MERGED_WITH %s\n", db_column_text(&q, 0)); |
| 79 | 99 | } |
| 80 | 100 | db_finalize(&q); |
| 101 | + if( nErr ){ |
| 102 | + fossil_fatal("aborting due to prior errors"); |
| 103 | + } |
| 81 | 104 | } |
| 82 | 105 | |
| 83 | 106 | /* |
| 84 | 107 | ** COMMAND: changes |
| 85 | 108 | ** |
| | @@ -92,12 +115,12 @@ |
| 92 | 115 | Blob report; |
| 93 | 116 | int vid; |
| 94 | 117 | db_must_be_within_tree(); |
| 95 | 118 | blob_zero(&report); |
| 96 | 119 | vid = db_lget_int("checkout", 0); |
| 97 | | - vfile_check_signature(vid); |
| 98 | | - status_report(&report, ""); |
| 120 | + vfile_check_signature(vid, 0); |
| 121 | + status_report(&report, "", 0); |
| 99 | 122 | blob_write_to_file(&report, "-"); |
| 100 | 123 | } |
| 101 | 124 | |
| 102 | 125 | /* |
| 103 | 126 | ** COMMAND: status |
| | @@ -134,11 +157,11 @@ |
| 134 | 157 | int isBrief; |
| 135 | 158 | |
| 136 | 159 | isBrief = find_option("l","l", 0)==0; |
| 137 | 160 | db_must_be_within_tree(); |
| 138 | 161 | vid = db_lget_int("checkout", 0); |
| 139 | | - vfile_check_signature(vid); |
| 162 | + vfile_check_signature(vid, 0); |
| 140 | 163 | db_prepare(&q, |
| 141 | 164 | "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)" |
| 142 | 165 | " FROM vfile" |
| 143 | 166 | " ORDER BY 1" |
| 144 | 167 | ); |
| | @@ -150,21 +173,25 @@ |
| 150 | 173 | int renamed = db_column_int(&q,4); |
| 151 | 174 | char *zFullName = mprintf("%s/%s", g.zLocalRoot, zPathname); |
| 152 | 175 | if( isBrief ){ |
| 153 | 176 | printf("%s\n", zPathname); |
| 154 | 177 | }else if( isNew ){ |
| 155 | | - printf("ADDED %s\n", zPathname); |
| 156 | | - }else if( access(zFullName, 0) ){ |
| 157 | | - printf("MISSING %s\n", zPathname); |
| 178 | + printf("ADDED %s\n", zPathname); |
| 179 | + }else if( !file_isfile(zFullName) ){ |
| 180 | + if( access(zFullName, 0)==0 ){ |
| 181 | + printf("NOT_A_FILE %s\n", zPathname); |
| 182 | + }else{ |
| 183 | + printf("MISSING %s\n", zPathname); |
| 184 | + } |
| 158 | 185 | }else if( isDeleted ){ |
| 159 | | - printf("DELETED %s\n", zPathname); |
| 186 | + printf("DELETED %s\n", zPathname); |
| 160 | 187 | }else if( chnged ){ |
| 161 | | - printf("EDITED %s\n", zPathname); |
| 188 | + printf("EDITED %s\n", zPathname); |
| 162 | 189 | }else if( renamed ){ |
| 163 | | - printf("RENAMED %s\n", zPathname); |
| 190 | + printf("RENAMED %s\n", zPathname); |
| 164 | 191 | }else{ |
| 165 | | - printf("UNCHANGED %s\n", zPathname); |
| 192 | + printf("UNCHANGED %s\n", zPathname); |
| 166 | 193 | } |
| 167 | 194 | free(zFullName); |
| 168 | 195 | } |
| 169 | 196 | db_finalize(&q); |
| 170 | 197 | } |
| | @@ -303,11 +330,11 @@ |
| 303 | 330 | "# PRIVATE BRANCH: This check-in will be private and will not sync to\n" |
| 304 | 331 | "# repositories.\n" |
| 305 | 332 | "#\n", -1 |
| 306 | 333 | ); |
| 307 | 334 | } |
| 308 | | - status_report(&text, "# "); |
| 335 | + status_report(&text, "# ", 1); |
| 309 | 336 | zEditor = db_get("editor", 0); |
| 310 | 337 | if( zEditor==0 ){ |
| 311 | 338 | zEditor = getenv("VISUAL"); |
| 312 | 339 | } |
| 313 | 340 | if( zEditor==0 ){ |
| 314 | 341 | |