Fossil SCM

If a file in the check-out is changed to something other than a file (like a directory) then raise an error when checking file signatures. Also fix a problem with the new multi-file "revert" command and add some comments to "update".

drh 2009-12-17 18:47 trunk
Commit d861fe77fbeb26a31c79d5ce39c1eeb0242e506d
2 files changed +13 -10 +7
+13 -10
--- src/update.c
+++ src/update.c
@@ -164,16 +164,16 @@
164164
165165
db_prepare(&q,
166166
"SELECT fn, idv, ridv, idt, ridt, chnged FROM fv ORDER BY 1"
167167
);
168168
while( db_step(&q)==SQLITE_ROW ){
169
- const char *zName = db_column_text(&q, 0);
170
- int idv = db_column_int(&q, 1);
171
- int ridv = db_column_int(&q, 2);
172
- int idt = db_column_int(&q, 3);
173
- int ridt = db_column_int(&q, 4);
174
- int chnged = db_column_int(&q, 5);
169
+ const char *zName = db_column_text(&q, 0); /* The filename */
170
+ int idv = db_column_int(&q, 1); /* VFILE entry for current */
171
+ int ridv = db_column_int(&q, 2); /* RecordID for current */
172
+ int idt = db_column_int(&q, 3); /* VFILE entry for target */
173
+ int ridt = db_column_int(&q, 4); /* RecordID for target */
174
+ int chnged = db_column_int(&q, 5); /* Current is edited */
175175
176176
if( idv>0 && ridv==0 && idt>0 ){
177177
/* Conflict. This file has been added to the current checkout
178178
** but also exists in the target checkout. Use the current version.
179179
*/
@@ -301,25 +301,28 @@
301301
const char *zRevision;
302302
Blob fname;
303303
Blob record;
304304
Blob ans;
305305
int i;
306
- int rid = 0, yesRevert;
306
+ int rid = 0;
307
+ int yesFlag;
308
+ int yesRevert;
307309
308
- yesRevert = find_option("yes", "y", 0)!=0;
310
+ yesFlag = find_option("yes", "y", 0)!=0;
309311
zRevision = find_option("revision", "r", 1);
310312
verify_all_options();
311313
312314
if( g.argc<3 ){
313315
usage("?OPTIONS FILE ...");
314316
}
315317
db_must_be_within_tree();
316318
317
- for(i=2; i<g.argc; i++){
319
+ for(i=2; i<g.argc; i++){
318320
zFile = mprintf("%/", g.argv[i]);
319321
file_tree_name(zFile, &fname, 1);
320
- if( access(zFile, 0) ) yesRevert = 1;
322
+ yesRevert = yesFlag;
323
+ if( !yesRevert && access(zFile, 0) ) yesRevert = 1;
321324
if( yesRevert==0 ){
322325
char *prompt = mprintf("revert file %B? this will"
323326
" destroy local changes (y/N)? ",
324327
&fname);
325328
blob_zero(&ans);
326329
--- src/update.c
+++ src/update.c
@@ -164,16 +164,16 @@
164
165 db_prepare(&q,
166 "SELECT fn, idv, ridv, idt, ridt, chnged FROM fv ORDER BY 1"
167 );
168 while( db_step(&q)==SQLITE_ROW ){
169 const char *zName = db_column_text(&q, 0);
170 int idv = db_column_int(&q, 1);
171 int ridv = db_column_int(&q, 2);
172 int idt = db_column_int(&q, 3);
173 int ridt = db_column_int(&q, 4);
174 int chnged = db_column_int(&q, 5);
175
176 if( idv>0 && ridv==0 && idt>0 ){
177 /* Conflict. This file has been added to the current checkout
178 ** but also exists in the target checkout. Use the current version.
179 */
@@ -301,25 +301,28 @@
301 const char *zRevision;
302 Blob fname;
303 Blob record;
304 Blob ans;
305 int i;
306 int rid = 0, yesRevert;
 
 
307
308 yesRevert = find_option("yes", "y", 0)!=0;
309 zRevision = find_option("revision", "r", 1);
310 verify_all_options();
311
312 if( g.argc<3 ){
313 usage("?OPTIONS FILE ...");
314 }
315 db_must_be_within_tree();
316
317 for(i=2; i<g.argc; i++){
318 zFile = mprintf("%/", g.argv[i]);
319 file_tree_name(zFile, &fname, 1);
320 if( access(zFile, 0) ) yesRevert = 1;
 
321 if( yesRevert==0 ){
322 char *prompt = mprintf("revert file %B? this will"
323 " destroy local changes (y/N)? ",
324 &fname);
325 blob_zero(&ans);
326
--- src/update.c
+++ src/update.c
@@ -164,16 +164,16 @@
164
165 db_prepare(&q,
166 "SELECT fn, idv, ridv, idt, ridt, chnged FROM fv ORDER BY 1"
167 );
168 while( db_step(&q)==SQLITE_ROW ){
169 const char *zName = db_column_text(&q, 0); /* The filename */
170 int idv = db_column_int(&q, 1); /* VFILE entry for current */
171 int ridv = db_column_int(&q, 2); /* RecordID for current */
172 int idt = db_column_int(&q, 3); /* VFILE entry for target */
173 int ridt = db_column_int(&q, 4); /* RecordID for target */
174 int chnged = db_column_int(&q, 5); /* Current is edited */
175
176 if( idv>0 && ridv==0 && idt>0 ){
177 /* Conflict. This file has been added to the current checkout
178 ** but also exists in the target checkout. Use the current version.
179 */
@@ -301,25 +301,28 @@
301 const char *zRevision;
302 Blob fname;
303 Blob record;
304 Blob ans;
305 int i;
306 int rid = 0;
307 int yesFlag;
308 int yesRevert;
309
310 yesFlag = find_option("yes", "y", 0)!=0;
311 zRevision = find_option("revision", "r", 1);
312 verify_all_options();
313
314 if( g.argc<3 ){
315 usage("?OPTIONS FILE ...");
316 }
317 db_must_be_within_tree();
318
319 for(i=2; i<g.argc; i++){
320 zFile = mprintf("%/", g.argv[i]);
321 file_tree_name(zFile, &fname, 1);
322 yesRevert = yesFlag;
323 if( !yesRevert && access(zFile, 0) ) yesRevert = 1;
324 if( yesRevert==0 ){
325 char *prompt = mprintf("revert file %B? this will"
326 " destroy local changes (y/N)? ",
327 &fname);
328 blob_zero(&ans);
329
--- src/vfile.c
+++ src/vfile.c
@@ -143,10 +143,11 @@
143143
**
144144
** If VFILE.DELETED is null or if VFILE.RID is zero, then we can assume
145145
** the file has changed without having the check the on-disk image.
146146
*/
147147
void vfile_check_signature(int vid){
148
+ int nErr = 0;
148149
Stmt q;
149150
Blob fileCksum, origCksum;
150151
int checkMtime = db_get_boolean("mtime-changes", 0);
151152
152153
db_begin_transaction();
@@ -166,10 +167,15 @@
166167
zName = db_column_text(&q, 1);
167168
rid = db_column_int(&q, 2);
168169
isDeleted = db_column_int(&q, 3);
169170
oldChnged = db_column_int(&q, 4);
170171
oldMtime = db_column_int64(&q, 6);
172
+ if( !file_isfile(zName) && file_size(zName)>=0 ){
173
+ fossil_warning("not a ordinary file: %s", zName);
174
+ nErr++;
175
+ continue;
176
+ }
171177
if( oldChnged>=2 ){
172178
chnged = oldChnged;
173179
}else if( isDeleted || rid==0 ){
174180
chnged = 1;
175181
}
@@ -193,10 +199,11 @@
193199
if( chnged!=oldChnged ){
194200
db_multi_exec("UPDATE vfile SET chnged=%d WHERE id=%d", chnged, id);
195201
}
196202
}
197203
db_finalize(&q);
204
+ if( nErr ) fossil_fatal("abort due to prior errors");
198205
db_end_transaction(0);
199206
}
200207
201208
/*
202209
** Write all files from vid to the disk. Or if vid==0 and id!=0
203210
--- src/vfile.c
+++ src/vfile.c
@@ -143,10 +143,11 @@
143 **
144 ** If VFILE.DELETED is null or if VFILE.RID is zero, then we can assume
145 ** the file has changed without having the check the on-disk image.
146 */
147 void vfile_check_signature(int vid){
 
148 Stmt q;
149 Blob fileCksum, origCksum;
150 int checkMtime = db_get_boolean("mtime-changes", 0);
151
152 db_begin_transaction();
@@ -166,10 +167,15 @@
166 zName = db_column_text(&q, 1);
167 rid = db_column_int(&q, 2);
168 isDeleted = db_column_int(&q, 3);
169 oldChnged = db_column_int(&q, 4);
170 oldMtime = db_column_int64(&q, 6);
 
 
 
 
 
171 if( oldChnged>=2 ){
172 chnged = oldChnged;
173 }else if( isDeleted || rid==0 ){
174 chnged = 1;
175 }
@@ -193,10 +199,11 @@
193 if( chnged!=oldChnged ){
194 db_multi_exec("UPDATE vfile SET chnged=%d WHERE id=%d", chnged, id);
195 }
196 }
197 db_finalize(&q);
 
198 db_end_transaction(0);
199 }
200
201 /*
202 ** Write all files from vid to the disk. Or if vid==0 and id!=0
203
--- src/vfile.c
+++ src/vfile.c
@@ -143,10 +143,11 @@
143 **
144 ** If VFILE.DELETED is null or if VFILE.RID is zero, then we can assume
145 ** the file has changed without having the check the on-disk image.
146 */
147 void vfile_check_signature(int vid){
148 int nErr = 0;
149 Stmt q;
150 Blob fileCksum, origCksum;
151 int checkMtime = db_get_boolean("mtime-changes", 0);
152
153 db_begin_transaction();
@@ -166,10 +167,15 @@
167 zName = db_column_text(&q, 1);
168 rid = db_column_int(&q, 2);
169 isDeleted = db_column_int(&q, 3);
170 oldChnged = db_column_int(&q, 4);
171 oldMtime = db_column_int64(&q, 6);
172 if( !file_isfile(zName) && file_size(zName)>=0 ){
173 fossil_warning("not a ordinary file: %s", zName);
174 nErr++;
175 continue;
176 }
177 if( oldChnged>=2 ){
178 chnged = oldChnged;
179 }else if( isDeleted || rid==0 ){
180 chnged = 1;
181 }
@@ -193,10 +199,11 @@
199 if( chnged!=oldChnged ){
200 db_multi_exec("UPDATE vfile SET chnged=%d WHERE id=%d", chnged, id);
201 }
202 }
203 db_finalize(&q);
204 if( nErr ) fossil_fatal("abort due to prior errors");
205 db_end_transaction(0);
206 }
207
208 /*
209 ** Write all files from vid to the disk. Or if vid==0 and id!=0
210

Keyboard Shortcuts

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