Check-in [d861fe77fb]
Not logged in
Overview

SHA1 Hash:d861fe77fbeb26a31c79d5ce39c1eeb0242e506d
Date: 2009-12-17 18:47:14
User: drh
Comment: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".
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/update.c from [af63100f92] to [b8775abaa9].

@@ -164,16 +164,16 @@
 
   db_prepare(&q,
     "SELECT fn, idv, ridv, idt, ridt, chnged FROM fv ORDER BY 1"
   );
   while( db_step(&q)==SQLITE_ROW ){
-    const char *zName = db_column_text(&q, 0);
-    int idv = db_column_int(&q, 1);
-    int ridv = db_column_int(&q, 2);
-    int idt = db_column_int(&q, 3);
-    int ridt = db_column_int(&q, 4);
-    int chnged = db_column_int(&q, 5);
+    const char *zName = db_column_text(&q, 0);  /* The filename */
+    int idv = db_column_int(&q, 1);             /* VFILE entry for current */
+    int ridv = db_column_int(&q, 2);            /* RecordID for current */
+    int idt = db_column_int(&q, 3);             /* VFILE entry for target */
+    int ridt = db_column_int(&q, 4);            /* RecordID for target */
+    int chnged = db_column_int(&q, 5);          /* Current is edited */
 
     if( idv>0 && ridv==0 && idt>0 ){
       /* Conflict.  This file has been added to the current checkout
       ** but also exists in the target checkout.  Use the current version.
       */
@@ -301,13 +301,15 @@
   const char *zRevision;
   Blob fname;
   Blob record;
   Blob ans;
   int i;
-  int rid = 0, yesRevert;
+  int rid = 0;
+  int yesFlag;
+  int yesRevert;
 
-  yesRevert = find_option("yes", "y", 0)!=0;
+  yesFlag = find_option("yes", "y", 0)!=0;
   zRevision = find_option("revision", "r", 1);
   verify_all_options();
 
   if( g.argc<3 ){
     usage("?OPTIONS FILE ...");
@@ -315,11 +317,12 @@
   db_must_be_within_tree();
 
   for(i=2; i<g.argc; i++){
     zFile = mprintf("%/", g.argv[i]);
     file_tree_name(zFile, &fname, 1);
-    if( access(zFile, 0) ) yesRevert = 1;
+    yesRevert = yesFlag;
+    if( !yesRevert && access(zFile, 0) ) yesRevert = 1;
     if( yesRevert==0 ){
       char *prompt = mprintf("revert file %B? this will"
                              " destroy local changes (y/N)? ",
                              &fname);
       blob_zero(&ans);

Modified src/vfile.c from [47f667e751] to [976e15ff22].

@@ -143,10 +143,11 @@
 **
 ** If VFILE.DELETED is null or if VFILE.RID is zero, then we can assume
 ** the file has changed without having the check the on-disk image.
 */
 void vfile_check_signature(int vid){
+  int nErr = 0;
   Stmt q;
   Blob fileCksum, origCksum;
   int checkMtime = db_get_boolean("mtime-changes", 0);
 
   db_begin_transaction();
@@ -166,10 +167,15 @@
     zName = db_column_text(&q, 1);
     rid = db_column_int(&q, 2);
     isDeleted = db_column_int(&q, 3);
     oldChnged = db_column_int(&q, 4);
     oldMtime = db_column_int64(&q, 6);
+    if( !file_isfile(zName) && file_size(zName)>=0 ){
+      fossil_warning("not a ordinary file: %s", zName);
+      nErr++;
+      continue;
+    }
     if( oldChnged>=2 ){
       chnged = oldChnged;
     }else if( isDeleted || rid==0 ){
       chnged = 1;
     }
@@ -193,10 +199,11 @@
     if( chnged!=oldChnged ){
       db_multi_exec("UPDATE vfile SET chnged=%d WHERE id=%d", chnged, id);
     }
   }
   db_finalize(&q);
+  if( nErr ) fossil_fatal("abort due to prior errors");
   db_end_transaction(0);
 }
 
 /*
 ** Write all files from vid to the disk.  Or if vid==0 and id!=0