Overview
SHA1 Hash: | 2dffce041d44564bb95515e0f9d344c4a4ba80f7 |
---|---|
Date: | 2008-12-06 18:02:21 |
User: | drh |
Comment: | Add the ability to detect file changes using only the mtime. This is turned on using the "fossil setting mtime-changes ON" command. It is off by default, but it does make many operations go much faster, especially on large repositories, so we might want to start turning it on by default. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified src/db.c from [87e3dcf414] to [3391579825].
@@ -687,13 +687,26 @@ db_open_or_attach(zDbName, "localdb"); g.localOpen = 1; db_open_config(); db_open_repository(0); + /* If the "mtime" column is missing from the vfile table, then + ** add it now. This code added on 2008-12-06. After all users have + ** upgraded, this code can be safely deleted. + */ + rc = sqlite3_prepare(g.db, "SELECT mtime FROM vfile", -1, &pStmt, 0); + sqlite3_finalize(pStmt); + if( rc==SQLITE_ERROR ){ + sqlite3_exec(g.db, "ALTER TABLE vfile ADD COLUMN mtime INTEGER", 0, 0, 0); + } + /* If the "origname" column is missing from the vfile table, then - ** add it now. */ + ** add it now. This code added on 2008-11-09. After all users have + ** upgraded, this code can be safely deleted. + */ rc = sqlite3_prepare(g.db, "SELECT origname FROM vfile", -1, &pStmt, 0); + sqlite3_finalize(pStmt); if( rc==SQLITE_ERROR ){ sqlite3_exec(g.db, "ALTER TABLE vfile ADD COLUMN origname TEXT", 0, 0, 0); } return 1; @@ -1324,10 +1337,13 @@ ** be unsigned. ** ** pgp-command Command used to clear-sign manifests at check-in. ** The default is "gpg --clearsign -o ". ** +** mtime-changes Use file modification times (mtimes) to detect when +** files have been modified. +** ** proxy URL of the HTTP proxy. If undefined or "off" then ** the "http_proxy" environment variable is consulted. ** If the http_proxy environment variable is undefined ** then a direct HTTP connection is used. ** @@ -1344,10 +1360,11 @@ "gdiff-command", "http-port", "localauth", "clearsign", "pgp-command", + "mtime-changes", "proxy", "web-browser", }; int i; int globalFlag = find_option("global","g",0)!=0;
Modified src/schema.c from [fa8ac9641b] to [89e594d6c0].
@@ -380,10 +380,11 @@ @ vid INTEGER REFERENCES blob, -- The baseline this file is part of. @ chnged INT DEFAULT 0, -- 0:unchnged 1:edited 2:m-chng 3:m-add @ deleted BOOLEAN DEFAULT 0, -- True if deleted @ rid INTEGER, -- Originally from this repository record @ mrid INTEGER, -- Based on this record due to a merge +@ mtime INTEGER, -- Modification time of file on disk @ pathname TEXT, -- Full pathname relative to root @ origname TEXT, -- Original pathname. NULL if unchanged @ UNIQUE(pathname,vid) @ ); @
Modified src/vfile.c from [a6f67aae7d] to [0b0beebd09].
@@ -145,39 +145,49 @@ ** the file has changed without having the check the on-disk image. */ void vfile_check_signature(int vid){ Stmt q; Blob fileCksum, origCksum; + int checkMtime = db_get_boolean("mtime-changes", 0); db_begin_transaction(); db_prepare(&q, "SELECT id, %Q || pathname," - " vfile.mrid, deleted, chnged, uuid" + " vfile.mrid, deleted, chnged, uuid, mtime" " FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid" " WHERE vid=%d ", g.zLocalRoot, vid); while( db_step(&q)==SQLITE_ROW ){ int id, rid, isDeleted; const char *zName; int chnged = 0; int oldChnged; + i64 oldMtime; + i64 currentMtime; id = db_column_int(&q, 0); 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( oldChnged>=2 ){ chnged = oldChnged; }else if( isDeleted || rid==0 ){ chnged = 1; } if( chnged!=1 ){ + currentMtime = file_mtime(zName); + } + if( chnged!=1 && (checkMtime==0 || currentMtime!=oldMtime) ){ db_ephemeral_blob(&q, 5, &origCksum); if( sha1sum_file(zName, &fileCksum) ){ blob_zero(&fileCksum); } if( blob_compare(&fileCksum, &origCksum) ){ chnged = 1; + }else if( currentMtime!=oldMtime ){ + db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d", + currentMtime, id); } blob_reset(&origCksum); blob_reset(&fileCksum); } if( chnged!=oldChnged ){ @@ -217,10 +227,12 @@ zName = db_column_text(&q, 1); rid = db_column_int(&q, 2); content_get(rid, &content); if( verbose ) printf("%s\n", &zName[nRepos]); blob_write_to_file(&content, zName); + db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d", + file_mtime(zName), id); } db_finalize(&q); } @@ -236,10 +248,11 @@ zName = db_column_text(&q, 0); unlink(zName); } db_finalize(&q); + db_multi_exec("UPDATE vfile SET mtime=NULL HERE vid=%d AND mrid>0", vid); } /* ** Load into table SFILE the name of every ordinary file in ** the directory pPath. Omit the first nPrefix characters of