Fossil SCM

Back out the undo/redo logic changes of [0c37874941c89] that caused the mtime to be restored on files. Playing games with mtimes is bad policy. Consider a scenario: "fossil merge; make; fossil undo; make". If the mtimes are reset by undo, then the second "make" above will not work correctly. This is not a complete backout of [0c37874941c89] as the underlying infrastructure used to compute the age of files is retained.

drh 2012-10-11 18:33 trunk
Commit 5c0843a8f1a7cc018f1249cf9b0ba44d648bfa8c
1 file changed +6 -14
+6 -14
--- src/undo.c
+++ src/undo.c
@@ -30,11 +30,11 @@
3030
*/
3131
static void undo_one(const char *zPathname, int redoFlag){
3232
Stmt q;
3333
char *zFullname;
3434
db_prepare(&q,
35
- "SELECT content, existsflag, isExe, isLink, mtime FROM undo"
35
+ "SELECT content, existsflag, isExe, isLink FROM undo"
3636
" WHERE pathname=%Q AND redoflag=%d",
3737
zPathname, redoFlag
3838
);
3939
if( db_step(&q)==SQLITE_ROW ){
4040
int old_exists;
@@ -41,11 +41,10 @@
4141
int new_exists;
4242
int old_exe;
4343
int new_exe;
4444
int new_link;
4545
int old_link;
46
- i64 old_mtime, new_mtime;
4746
Blob current;
4847
Blob new;
4948
zFullname = mprintf("%s/%s", g.zLocalRoot, zPathname);
5049
old_link = db_column_int(&q, 3);
5150
new_link = file_wd_islink(zFullname);
@@ -55,20 +54,17 @@
5554
blob_read_link(&current, zFullname);
5655
}else{
5756
blob_read_from_file(&current, zFullname);
5857
}
5958
new_exe = file_wd_isexe(zFullname);
60
- new_mtime = file_wd_mtime(zFullname);
6159
}else{
6260
blob_zero(&current);
6361
new_exe = 0;
64
- new_mtime = 0;
6562
}
6663
blob_zero(&new);
6764
old_exists = db_column_int(&q, 1);
6865
old_exe = db_column_int(&q, 2);
69
- old_mtime = db_column_int64(&q, 4);
7066
if( old_exists ){
7167
db_ephemeral_blob(&q, 0, &new);
7268
}
7369
if( old_exists ){
7470
if( new_exists ){
@@ -83,23 +79,22 @@
8379
symlink_create(blob_str(&new), zFullname);
8480
}else{
8581
blob_write_to_file(&new, zFullname);
8682
}
8783
file_wd_setexe(zFullname, old_exe);
88
- file_set_mtime(zFullname, old_mtime);
8984
}else{
9085
fossil_print("DELETE %s\n", zPathname);
9186
file_delete(zFullname);
9287
}
9388
blob_reset(&new);
9489
free(zFullname);
9590
db_finalize(&q);
9691
db_prepare(&q,
9792
"UPDATE undo SET content=:c, existsflag=%d, isExe=%d, isLink=%d,"
98
- " mtime=%lld, redoflag=NOT redoflag"
93
+ " redoflag=NOT redoflag"
9994
" WHERE pathname=%Q",
100
- new_exists, new_exe, new_link, new_mtime, zPathname
95
+ new_exists, new_exe, new_link, zPathname
10196
);
10297
if( new_exists ){
10398
db_bind_blob(&q, ":c", &current);
10499
}
105100
db_step(&q);
@@ -230,11 +225,10 @@
230225
@ pathname TEXT UNIQUE, -- Name of the file
231226
@ redoflag BOOLEAN, -- 0 for undoable. 1 for redoable
232227
@ existsflag BOOLEAN, -- True if the file exists
233228
@ isExe BOOLEAN, -- True if the file is executable
234229
@ isLink BOOLEAN, -- True if the file is symlink
235
- @ mtime DATETIME, -- File modification time
236230
@ content BLOB -- Saved content
237231
@ );
238232
@ CREATE TABLE %s.undo_vfile AS SELECT * FROM vfile;
239233
@ CREATE TABLE %s.undo_vmerge AS SELECT * FROM vmerge;
240234
;
@@ -280,14 +274,13 @@
280274
zFullname = mprintf("%s%s", g.zLocalRoot, zPathname);
281275
existsFlag = file_wd_size(zFullname)>=0;
282276
isLink = file_wd_islink(zFullname);
283277
db_prepare(&q,
284278
"INSERT OR IGNORE INTO"
285
- " undo(pathname,redoflag,existsflag,isExe,isLink,mtime,content)"
286
- " VALUES(%Q,0,%d,%d,%d,%lld,:c)",
287
- zPathname, existsFlag, file_wd_isexe(zFullname), isLink,
288
- file_wd_mtime(zFullname)
279
+ " undo(pathname,redoflag,existsflag,isExe,isLink,content)"
280
+ " VALUES(%Q,0,%d,%d,%d,:c)",
281
+ zPathname, existsFlag, file_wd_isexe(zFullname), isLink
289282
);
290283
if( existsFlag ){
291284
if( isLink ){
292285
blob_read_link(&content, zFullname);
293286
}else{
@@ -390,11 +383,10 @@
390383
int isRedo = g.argv[1][0]=='r';
391384
int undo_available;
392385
int explainFlag = find_option("explain", 0, 0)!=0;
393386
const char *zCmd = isRedo ? "redo" : "undo";
394387
db_must_be_within_tree();
395
- if( find_option("reset", 0, 0)!=0 ){ undo_reset(); return; }
396388
verify_all_options();
397389
db_begin_transaction();
398390
undo_available = db_lget_int("undo_available", 0);
399391
if( explainFlag ){
400392
if( undo_available==0 ){
401393
--- src/undo.c
+++ src/undo.c
@@ -30,11 +30,11 @@
30 */
31 static void undo_one(const char *zPathname, int redoFlag){
32 Stmt q;
33 char *zFullname;
34 db_prepare(&q,
35 "SELECT content, existsflag, isExe, isLink, mtime FROM undo"
36 " WHERE pathname=%Q AND redoflag=%d",
37 zPathname, redoFlag
38 );
39 if( db_step(&q)==SQLITE_ROW ){
40 int old_exists;
@@ -41,11 +41,10 @@
41 int new_exists;
42 int old_exe;
43 int new_exe;
44 int new_link;
45 int old_link;
46 i64 old_mtime, new_mtime;
47 Blob current;
48 Blob new;
49 zFullname = mprintf("%s/%s", g.zLocalRoot, zPathname);
50 old_link = db_column_int(&q, 3);
51 new_link = file_wd_islink(zFullname);
@@ -55,20 +54,17 @@
55 blob_read_link(&current, zFullname);
56 }else{
57 blob_read_from_file(&current, zFullname);
58 }
59 new_exe = file_wd_isexe(zFullname);
60 new_mtime = file_wd_mtime(zFullname);
61 }else{
62 blob_zero(&current);
63 new_exe = 0;
64 new_mtime = 0;
65 }
66 blob_zero(&new);
67 old_exists = db_column_int(&q, 1);
68 old_exe = db_column_int(&q, 2);
69 old_mtime = db_column_int64(&q, 4);
70 if( old_exists ){
71 db_ephemeral_blob(&q, 0, &new);
72 }
73 if( old_exists ){
74 if( new_exists ){
@@ -83,23 +79,22 @@
83 symlink_create(blob_str(&new), zFullname);
84 }else{
85 blob_write_to_file(&new, zFullname);
86 }
87 file_wd_setexe(zFullname, old_exe);
88 file_set_mtime(zFullname, old_mtime);
89 }else{
90 fossil_print("DELETE %s\n", zPathname);
91 file_delete(zFullname);
92 }
93 blob_reset(&new);
94 free(zFullname);
95 db_finalize(&q);
96 db_prepare(&q,
97 "UPDATE undo SET content=:c, existsflag=%d, isExe=%d, isLink=%d,"
98 " mtime=%lld, redoflag=NOT redoflag"
99 " WHERE pathname=%Q",
100 new_exists, new_exe, new_link, new_mtime, zPathname
101 );
102 if( new_exists ){
103 db_bind_blob(&q, ":c", &current);
104 }
105 db_step(&q);
@@ -230,11 +225,10 @@
230 @ pathname TEXT UNIQUE, -- Name of the file
231 @ redoflag BOOLEAN, -- 0 for undoable. 1 for redoable
232 @ existsflag BOOLEAN, -- True if the file exists
233 @ isExe BOOLEAN, -- True if the file is executable
234 @ isLink BOOLEAN, -- True if the file is symlink
235 @ mtime DATETIME, -- File modification time
236 @ content BLOB -- Saved content
237 @ );
238 @ CREATE TABLE %s.undo_vfile AS SELECT * FROM vfile;
239 @ CREATE TABLE %s.undo_vmerge AS SELECT * FROM vmerge;
240 ;
@@ -280,14 +274,13 @@
280 zFullname = mprintf("%s%s", g.zLocalRoot, zPathname);
281 existsFlag = file_wd_size(zFullname)>=0;
282 isLink = file_wd_islink(zFullname);
283 db_prepare(&q,
284 "INSERT OR IGNORE INTO"
285 " undo(pathname,redoflag,existsflag,isExe,isLink,mtime,content)"
286 " VALUES(%Q,0,%d,%d,%d,%lld,:c)",
287 zPathname, existsFlag, file_wd_isexe(zFullname), isLink,
288 file_wd_mtime(zFullname)
289 );
290 if( existsFlag ){
291 if( isLink ){
292 blob_read_link(&content, zFullname);
293 }else{
@@ -390,11 +383,10 @@
390 int isRedo = g.argv[1][0]=='r';
391 int undo_available;
392 int explainFlag = find_option("explain", 0, 0)!=0;
393 const char *zCmd = isRedo ? "redo" : "undo";
394 db_must_be_within_tree();
395 if( find_option("reset", 0, 0)!=0 ){ undo_reset(); return; }
396 verify_all_options();
397 db_begin_transaction();
398 undo_available = db_lget_int("undo_available", 0);
399 if( explainFlag ){
400 if( undo_available==0 ){
401
--- src/undo.c
+++ src/undo.c
@@ -30,11 +30,11 @@
30 */
31 static void undo_one(const char *zPathname, int redoFlag){
32 Stmt q;
33 char *zFullname;
34 db_prepare(&q,
35 "SELECT content, existsflag, isExe, isLink FROM undo"
36 " WHERE pathname=%Q AND redoflag=%d",
37 zPathname, redoFlag
38 );
39 if( db_step(&q)==SQLITE_ROW ){
40 int old_exists;
@@ -41,11 +41,10 @@
41 int new_exists;
42 int old_exe;
43 int new_exe;
44 int new_link;
45 int old_link;
 
46 Blob current;
47 Blob new;
48 zFullname = mprintf("%s/%s", g.zLocalRoot, zPathname);
49 old_link = db_column_int(&q, 3);
50 new_link = file_wd_islink(zFullname);
@@ -55,20 +54,17 @@
54 blob_read_link(&current, zFullname);
55 }else{
56 blob_read_from_file(&current, zFullname);
57 }
58 new_exe = file_wd_isexe(zFullname);
 
59 }else{
60 blob_zero(&current);
61 new_exe = 0;
 
62 }
63 blob_zero(&new);
64 old_exists = db_column_int(&q, 1);
65 old_exe = db_column_int(&q, 2);
 
66 if( old_exists ){
67 db_ephemeral_blob(&q, 0, &new);
68 }
69 if( old_exists ){
70 if( new_exists ){
@@ -83,23 +79,22 @@
79 symlink_create(blob_str(&new), zFullname);
80 }else{
81 blob_write_to_file(&new, zFullname);
82 }
83 file_wd_setexe(zFullname, old_exe);
 
84 }else{
85 fossil_print("DELETE %s\n", zPathname);
86 file_delete(zFullname);
87 }
88 blob_reset(&new);
89 free(zFullname);
90 db_finalize(&q);
91 db_prepare(&q,
92 "UPDATE undo SET content=:c, existsflag=%d, isExe=%d, isLink=%d,"
93 " redoflag=NOT redoflag"
94 " WHERE pathname=%Q",
95 new_exists, new_exe, new_link, zPathname
96 );
97 if( new_exists ){
98 db_bind_blob(&q, ":c", &current);
99 }
100 db_step(&q);
@@ -230,11 +225,10 @@
225 @ pathname TEXT UNIQUE, -- Name of the file
226 @ redoflag BOOLEAN, -- 0 for undoable. 1 for redoable
227 @ existsflag BOOLEAN, -- True if the file exists
228 @ isExe BOOLEAN, -- True if the file is executable
229 @ isLink BOOLEAN, -- True if the file is symlink
 
230 @ content BLOB -- Saved content
231 @ );
232 @ CREATE TABLE %s.undo_vfile AS SELECT * FROM vfile;
233 @ CREATE TABLE %s.undo_vmerge AS SELECT * FROM vmerge;
234 ;
@@ -280,14 +274,13 @@
274 zFullname = mprintf("%s%s", g.zLocalRoot, zPathname);
275 existsFlag = file_wd_size(zFullname)>=0;
276 isLink = file_wd_islink(zFullname);
277 db_prepare(&q,
278 "INSERT OR IGNORE INTO"
279 " undo(pathname,redoflag,existsflag,isExe,isLink,content)"
280 " VALUES(%Q,0,%d,%d,%d,:c)",
281 zPathname, existsFlag, file_wd_isexe(zFullname), isLink
 
282 );
283 if( existsFlag ){
284 if( isLink ){
285 blob_read_link(&content, zFullname);
286 }else{
@@ -390,11 +383,10 @@
383 int isRedo = g.argv[1][0]=='r';
384 int undo_available;
385 int explainFlag = find_option("explain", 0, 0)!=0;
386 const char *zCmd = isRedo ? "redo" : "undo";
387 db_must_be_within_tree();
 
388 verify_all_options();
389 db_begin_transaction();
390 undo_available = db_lget_int("undo_available", 0);
391 if( explainFlag ){
392 if( undo_available==0 ){
393

Keyboard Shortcuts

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