Index: src/merge.c ================================================================== --- src/merge.c +++ src/merge.c @@ -218,17 +218,18 @@ /* ** Print the content of the VFILE table on standard output, for ** debugging purposes. */ -static void debug_show_vfile(void){ +static void debug_show_vfile(int showAll){ Stmt q; int pvid = -1; db_prepare(&q, "SELECT vid, id, chnged, deleted, isexe, islink, rid, mrid, mtime," - " pathname, origname, mhash FROM vfile" - " ORDER BY vid, pathname" + " pathname, origname, mhash, %s FROM vfile" + " ORDER BY vid, pathname", + showAll ? "COALESCE(datetime(mtime, 'unixepoch', 'localtime'), 'NULL')" : "''" ); while( db_step(&q)==SQLITE_ROW ){ int vid = db_column_int(&q, 0); int chnged = db_column_int(&q, 2); int dltd = db_column_int(&q, 3); @@ -252,27 +253,35 @@ if( zOrig && zOrig[0] ){ fossil_print(" <- %s\n", zOrig); }else{ fossil_print("\n"); } + if( showAll ){ + fossil_print(" mtime %19s / %-10i mhash %s\n", db_column_text(&q, 12), + db_column_int(&q , 8), db_column_text(&q, 11)); + } } db_finalize(&q); } /* ** COMMAND: test-show-vfile ** Usage: %fossil test-show-vfile ** +** Options: +** --all Show all fields +** ** Show the content of the VFILE table in a local check-out. */ void test_show_vfile_cmd(void){ + int showVfileAll = find_option("mtime",0,0)!=0; if( g.argc!=2 ){ fossil_fatal("unknown arguments to the %s command\n", g.argv[1]); } verify_all_options(); db_must_be_within_tree(); - debug_show_vfile(); + debug_show_vfile(showVfileAll); } /* ** COMMAND: merge @@ -333,10 +342,11 @@ int forceMissingFlag; /* True if the --force-missing option is present */ const char *zBinGlob; /* The value of --binary */ const char *zPivot; /* The value of --baseline */ int debugFlag; /* True if --debug is present */ int showVfileFlag; /* True if the --show-vfile flag is present */ + int showVfileAll; /* True if the --show-vfile-all flag is present */ int keepMergeFlag; /* True if --keep-merge-files is present */ int nConflict = 0; /* Number of conflicts seen */ int nOverwrite = 0; /* Number of unmanaged files overwritten */ char vAncestor = 'p'; /* If P is an ancestor of V then 'p', else 'n' */ Stmt q; @@ -369,25 +379,27 @@ } forceFlag = find_option("force","f",0)!=0; zPivot = find_option("baseline",0,1); keepMergeFlag = find_option("keep-merge-files", "K",0)!=0; - /* Undocumented --debug and --show-vfile options: + /* Undocumented --debug, --show-vfile, --show-vfile-all options: ** ** When included on the command-line, --debug causes lots of state ** information to be displayed. This option is undocumented as it ** might change or be eliminated in future releases. ** ** The --show-vfile flag does a dump of the VFILE table for reference. + ** The --show-vfile-all shows all fields from the VFILE table. ** ** Hints: ** * Combine --debug and --verbose for still more output. ** * The --dry-run option is also useful in combination with --debug. */ debugFlag = find_option("debug",0,0)!=0; if( debugFlag && verboseFlag ) debugFlag = 2; showVfileFlag = find_option("show-vfile",0,0)!=0; + showVfileAll = find_option("show-vfile-all",0,0)!=0; verify_all_options(); db_must_be_within_tree(); if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0); vid = db_lget_int("checkout", 0); @@ -555,11 +567,11 @@ fossil_print("M=%-4d %z (merged-in version)\n", mid, z); z = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid); fossil_print("V=%-4d %z (current version)\n", vid, z); fossil_print("vAncestor = '%c'\n", vAncestor); } - if( showVfileFlag ) debug_show_vfile(); + if( showVfileFlag || showVfileAll ) debug_show_vfile(showVfileAll); /* ** The vfile.pathname field is used to match files against each other. The ** FV table contains one row for each each unique filename in ** in the current check-out, the pivot, and the version being merged. Index: src/update.c ================================================================== --- src/update.c +++ src/update.c @@ -946,11 +946,10 @@ zFile, zFile ); }else if( file_unsafe_in_tree_path(zFull) ){ /* Ignore this file */ }else{ - sqlite3_int64 mtime; int rvChnged = 0; int rvPerm = manifest_file_mperm(pRvFile); /* Determine if reverted-to file is different than checked-out file. */ if( pCoManifest && (pCoFile = manifest_file_find(pCoManifest, zFile)) ){ @@ -972,17 +971,16 @@ }else{ blob_write_to_file(&record, zFull); } file_setexe(zFull, rvPerm==PERM_EXE); fossil_print("REVERT %s\n", zFile); - mtime = file_mtime(zFull, RepoFILE); db_multi_exec( "UPDATE vfile" - " SET mtime=%lld, chnged=%d, deleted=0, isexe=%d, islink=%d," + " SET mtime=0, chnged=%d, deleted=0, isexe=%d, islink=%d," " mrid=rid, mhash=NULL" " WHERE pathname=%Q OR origname=%Q", - mtime, rvChnged, rvPerm==PERM_EXE, rvPerm==PERM_LNK, zFile, zFile + rvChnged, rvPerm==PERM_EXE, rvPerm==PERM_LNK, zFile, zFile ); } blob_reset(&record); free(zFull); } Index: src/vfile.c ================================================================== --- src/vfile.c +++ src/vfile.c @@ -19,10 +19,11 @@ */ #include "config.h" #include "vfile.h" #include #include +#include /* ** The input is guaranteed to be a 40- or 64-character well-formed ** artifact hash. Find its rid. */ @@ -170,10 +171,11 @@ ** If the mtime of a file has changed, we still examine the on-disk content ** to see whether or not the edit was a null-edit. */ void vfile_check_signature(int vid, unsigned int cksigFlags){ int nErr = 0; + time_t now = time(0); Stmt q; int useMtime = (cksigFlags & CKSIG_HASH)==0 && db_get_boolean("mtime-changes", 1); db_begin_transaction(); @@ -242,11 +244,18 @@ const char *zUuid = db_column_text(&q, 5); int nUuid = db_column_bytes(&q, 5); assert( origSize==currentSize ); if( !hname_verify_file_hash(zName, zUuid, nUuid) ) chnged = 1; } - if( (cksigFlags & CKSIG_SETMTIME) && (chnged==0 || chnged==2 || chnged==4)){ + /* Before updating VFILE below, currentMtime may need an update: + ** 1. If file was modified just now, set to 0 as done when merging. + ** Next time we check, we will likely check the hash and update mtime. + ** 2. Set to manifest time, if requested. + */ + if( currentMtime >= now ){ + currentMtime = 0; + } else if( (cksigFlags & CKSIG_SETMTIME) && (chnged==0 || chnged==2 || chnged==4)){ i64 desiredMtime; if( mtime_of_manifest_file(vid,rid,&desiredMtime)==0 ){ if( currentMtime!=desiredMtime ){ file_set_mtime(zName, desiredMtime); currentMtime = file_mtime(zName, RepoFILE); @@ -323,12 +332,11 @@ } content_get(rid, &content); if( file_is_the_same(&content, zName) ){ blob_reset(&content); if( file_setexe(zName, isExe) ){ - db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d", - file_mtime(zName, RepoFILE), id); + db_multi_exec("UPDATE vfile SET mtime=0 WHERE id=%d", id); } continue; } if( promptFlag && file_size(zName, RepoFILE)>=0 ){ Blob ans; @@ -359,12 +367,11 @@ }else{ blob_write_to_file(&content, zName); } file_setexe(zName, isExe); blob_reset(&content); - db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d", - file_mtime(zName, RepoFILE), id); + db_multi_exec("UPDATE vfile SET mtime=0 WHERE id=%d", id); } db_finalize(&q); } /*