Fossil SCM

Speedup handling of checked-out files: When multiple information about a file is requested (size, mtime, permission flags) only call stat() once.

jan.nijtmans 2015-02-10 08:24 trunk
Commit dd94e596f4bc6e483b110741baf1bd2eb67c416f
+2 -1
--- src/add.c
+++ src/add.c
@@ -153,14 +153,15 @@
153153
" WHERE pathname=%Q %s", zPath, filename_collation()) ){
154154
db_multi_exec("UPDATE vfile SET deleted=0"
155155
" WHERE pathname=%Q %s", zPath, filename_collation());
156156
}else{
157157
char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath);
158
+ int isExe = file_wd_isexe(zFullname);
158159
db_multi_exec(
159160
"INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe,islink)"
160161
"VALUES(%d,0,0,0,%Q,%d,%d)",
161
- vid, zPath, file_wd_isexe(zFullname), file_wd_islink(zFullname));
162
+ vid, zPath, isExe, file_wd_islink(0));
162163
fossil_free(zFullname);
163164
}
164165
if( db_changes() ){
165166
fossil_print("ADDED %s\n", zPath);
166167
return 1;
167168
--- src/add.c
+++ src/add.c
@@ -153,14 +153,15 @@
153 " WHERE pathname=%Q %s", zPath, filename_collation()) ){
154 db_multi_exec("UPDATE vfile SET deleted=0"
155 " WHERE pathname=%Q %s", zPath, filename_collation());
156 }else{
157 char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath);
 
158 db_multi_exec(
159 "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe,islink)"
160 "VALUES(%d,0,0,0,%Q,%d,%d)",
161 vid, zPath, file_wd_isexe(zFullname), file_wd_islink(zFullname));
162 fossil_free(zFullname);
163 }
164 if( db_changes() ){
165 fossil_print("ADDED %s\n", zPath);
166 return 1;
167
--- src/add.c
+++ src/add.c
@@ -153,14 +153,15 @@
153 " WHERE pathname=%Q %s", zPath, filename_collation()) ){
154 db_multi_exec("UPDATE vfile SET deleted=0"
155 " WHERE pathname=%Q %s", zPath, filename_collation());
156 }else{
157 char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath);
158 int isExe = file_wd_isexe(zFullname);
159 db_multi_exec(
160 "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe,islink)"
161 "VALUES(%d,0,0,0,%Q,%d,%d)",
162 vid, zPath, isExe, file_wd_islink(0));
163 fossil_free(zFullname);
164 }
165 if( db_changes() ){
166 fossil_print("ADDED %s\n", zPath);
167 return 1;
168
+2 -2
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -109,11 +109,11 @@
109109
/* Read content of zFile2 into memory */
110110
blob_zero(&file2);
111111
if( file_wd_size(zFile2)<0 ){
112112
zName2 = NULL_DEVICE;
113113
}else{
114
- if( file_wd_islink(zFile2) ){
114
+ if( file_wd_islink(0) ){
115115
blob_read_link(&file2, zFile2);
116116
}else{
117117
blob_read_from_file(&file2, zFile2);
118118
}
119119
zName2 = zName;
@@ -156,11 +156,11 @@
156156
}
157157
glob_free(pBinary);
158158
}
159159
blob_zero(&file2);
160160
if( file_wd_size(zFile2)>=0 ){
161
- if( file_wd_islink(zFile2) ){
161
+ if( file_wd_islink(0) ){
162162
blob_read_link(&file2, zFile2);
163163
}else{
164164
blob_read_from_file(&file2, zFile2);
165165
}
166166
}
167167
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -109,11 +109,11 @@
109 /* Read content of zFile2 into memory */
110 blob_zero(&file2);
111 if( file_wd_size(zFile2)<0 ){
112 zName2 = NULL_DEVICE;
113 }else{
114 if( file_wd_islink(zFile2) ){
115 blob_read_link(&file2, zFile2);
116 }else{
117 blob_read_from_file(&file2, zFile2);
118 }
119 zName2 = zName;
@@ -156,11 +156,11 @@
156 }
157 glob_free(pBinary);
158 }
159 blob_zero(&file2);
160 if( file_wd_size(zFile2)>=0 ){
161 if( file_wd_islink(zFile2) ){
162 blob_read_link(&file2, zFile2);
163 }else{
164 blob_read_from_file(&file2, zFile2);
165 }
166 }
167
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -109,11 +109,11 @@
109 /* Read content of zFile2 into memory */
110 blob_zero(&file2);
111 if( file_wd_size(zFile2)<0 ){
112 zName2 = NULL_DEVICE;
113 }else{
114 if( file_wd_islink(0) ){
115 blob_read_link(&file2, zFile2);
116 }else{
117 blob_read_from_file(&file2, zFile2);
118 }
119 zName2 = zName;
@@ -156,11 +156,11 @@
156 }
157 glob_free(pBinary);
158 }
159 blob_zero(&file2);
160 if( file_wd_size(zFile2)>=0 ){
161 if( file_wd_islink(0) ){
162 blob_read_link(&file2, zFile2);
163 }else{
164 blob_read_from_file(&file2, zFile2);
165 }
166 }
167
+9 -17
--- src/file.c
+++ src/file.c
@@ -232,32 +232,24 @@
232232
blob_reset(&content);
233233
}
234234
235235
/*
236236
** Return file permissions (normal, executable, or symlink):
237
-** - PERM_EXE if file is executable;
237
+** - PERM_EXE on Unix if file is executable;
238238
** - PERM_LNK on Unix if file is symlink and allow-symlinks option is on;
239239
** - PERM_REG for all other cases (regular file, directory, fifo, etc).
240240
*/
241241
int file_wd_perm(const char *zFilename){
242
- if( getStat(zFilename, 1) ) return PERM_REG;
243
-#if defined(_WIN32)
244
-# ifndef S_IXUSR
245
-# define S_IXUSR _S_IEXEC
246
-# endif
247
- if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
248
- return PERM_EXE;
249
- else
250
- return PERM_REG;
251
-#else
252
- if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
253
- return PERM_EXE;
254
- else if( g.allowSymlinks && S_ISLNK(fileStat.st_mode) )
255
- return PERM_LNK;
256
- else
257
- return PERM_REG;
242
+#if !defined(_WIN32)
243
+ if( !getStat(zFilename, 1) ){
244
+ if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
245
+ return PERM_EXE;
246
+ else if( g.allowSymlinks && S_ISLNK(fileStat.st_mode) )
247
+ return PERM_LNK;
248
+ }
258249
#endif
250
+ return PERM_REG;
259251
}
260252
261253
/*
262254
** Return TRUE if the named file is an executable. Return false
263255
** for directories, devices, fifos, symlinks, etc.
264256
--- src/file.c
+++ src/file.c
@@ -232,32 +232,24 @@
232 blob_reset(&content);
233 }
234
235 /*
236 ** Return file permissions (normal, executable, or symlink):
237 ** - PERM_EXE if file is executable;
238 ** - PERM_LNK on Unix if file is symlink and allow-symlinks option is on;
239 ** - PERM_REG for all other cases (regular file, directory, fifo, etc).
240 */
241 int file_wd_perm(const char *zFilename){
242 if( getStat(zFilename, 1) ) return PERM_REG;
243 #if defined(_WIN32)
244 # ifndef S_IXUSR
245 # define S_IXUSR _S_IEXEC
246 # endif
247 if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
248 return PERM_EXE;
249 else
250 return PERM_REG;
251 #else
252 if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
253 return PERM_EXE;
254 else if( g.allowSymlinks && S_ISLNK(fileStat.st_mode) )
255 return PERM_LNK;
256 else
257 return PERM_REG;
258 #endif
 
259 }
260
261 /*
262 ** Return TRUE if the named file is an executable. Return false
263 ** for directories, devices, fifos, symlinks, etc.
264
--- src/file.c
+++ src/file.c
@@ -232,32 +232,24 @@
232 blob_reset(&content);
233 }
234
235 /*
236 ** Return file permissions (normal, executable, or symlink):
237 ** - PERM_EXE on Unix if file is executable;
238 ** - PERM_LNK on Unix if file is symlink and allow-symlinks option is on;
239 ** - PERM_REG for all other cases (regular file, directory, fifo, etc).
240 */
241 int file_wd_perm(const char *zFilename){
242 #if !defined(_WIN32)
243 if( !getStat(zFilename, 1) ){
244 if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
245 return PERM_EXE;
246 else if( g.allowSymlinks && S_ISLNK(fileStat.st_mode) )
247 return PERM_LNK;
248 }
 
 
 
 
 
 
 
 
 
249 #endif
250 return PERM_REG;
251 }
252
253 /*
254 ** Return TRUE if the named file is an executable. Return false
255 ** for directories, devices, fifos, symlinks, etc.
256
+7 -8
--- src/tar.c
+++ src/tar.c
@@ -285,11 +285,11 @@
285285
const char *zName, /* Name of the object */
286286
int nName, /* Number of characters in zName */
287287
int iMode, /* Mode. 0644 or 0755 */
288288
unsigned int mTime, /* File modification time */
289289
int iSize, /* Size of the object in bytes */
290
- char cType /* Type of object:
290
+ char cType /* Type of object:
291291
'0'==file. '2'==symlink. '5'==directory */
292292
){
293293
/* set mode and modification time */
294294
sqlite3_snprintf(8, (char*)&tball.aHdr[100], "%07o", iMode);
295295
sqlite3_snprintf(12, (char*)&tball.aHdr[136], "%011o", mTime);
@@ -341,11 +341,11 @@
341341
unsigned int mTime /* Modification time */
342342
){
343343
int i;
344344
for(i=nName-1; i>0 && zName[i]!='/'; i--){}
345345
if( i<=0 ) return;
346
- if( i<tball.nPrevDirAlloc
346
+ if( i<tball.nPrevDirAlloc
347347
&& strncmp(tball.zPrevDir, zName, i)==0
348348
&& tball.zPrevDir[i]==0 ) return;
349349
db_multi_exec("INSERT OR IGNORE INTO dir VALUES('%#q')", i, zName);
350350
if( sqlite3_changes(g.db)==0 ) return;
351351
tar_add_directory_of(zName, i-1, mTime);
@@ -377,11 +377,11 @@
377377
char cType = '0';
378378
379379
/* length check moved to tar_split_path */
380380
tar_add_directory_of(zName, nName, mTime);
381381
382
- /*
382
+ /*
383383
* If we have a symlink, write its destination path (which is stored in
384384
* pContent) into header, and set content length to 0 to avoid storing path
385385
* as file content in the next step. Since 'linkname' header is limited to
386386
* 100 bytes (-1 byte for terminating zero), if path is greater than that,
387387
* store symlink as a plain-text file. (Not sure how TAR handles long links.)
@@ -390,11 +390,11 @@
390390
sqlite3_snprintf(100, (char*)&tball.aHdr[157], "%s", blob_str(pContent));
391391
cType = '2';
392392
n = 0;
393393
}
394394
395
- tar_add_header(zName, nName, ( mPerm==PERM_EXE ) ? 0755 : 0644,
395
+ tar_add_header(zName, nName, ( mPerm==PERM_EXE ) ? 0755 : 0644,
396396
mTime, n, cType);
397397
if( n ){
398398
gzip_step(blob_buffer(pContent), n);
399399
lastPage = n % 512;
400400
if( lastPage!=0 ){
@@ -428,21 +428,20 @@
428428
** that contains files given in the second and subsequent arguments.
429429
*/
430430
void test_tarball_cmd(void){
431431
int i;
432432
Blob zip;
433
- Blob file;
434433
if( g.argc<3 ){
435434
usage("ARCHIVE FILE....");
436435
}
437436
sqlite3_open(":memory:", &g.db);
438437
tar_begin(-1);
439438
for(i=3; i<g.argc; i++){
439
+ Blob file;
440440
blob_zero(&file);
441441
blob_read_from_file(&file, g.argv[i]);
442
- tar_add_file(g.argv[i], &file,
443
- file_wd_perm(g.argv[i]), file_wd_mtime(g.argv[i]));
442
+ tar_add_file(g.argv[i], &file, file_wd_perm(0), file_wd_mtime(0));
444443
blob_reset(&file);
445444
}
446445
tar_finish(&zip);
447446
blob_write_to_file(&zip, g.argv[2]);
448447
}
@@ -591,11 +590,11 @@
591590
** Optional URL Parameters:
592591
**
593592
** - name=NAME[.tar.gz] is base name of the output file. Defaults to
594593
** something project/version-specific. The prefix of the name, up to
595594
** the last '.', are used as the top-most directory name in the tar
596
-** output.
595
+** output.
597596
**
598597
** - uuid=the version to tar (may be a tag/branch name).
599598
** Defaults to "trunk".
600599
**
601600
*/
602601
--- src/tar.c
+++ src/tar.c
@@ -285,11 +285,11 @@
285 const char *zName, /* Name of the object */
286 int nName, /* Number of characters in zName */
287 int iMode, /* Mode. 0644 or 0755 */
288 unsigned int mTime, /* File modification time */
289 int iSize, /* Size of the object in bytes */
290 char cType /* Type of object:
291 '0'==file. '2'==symlink. '5'==directory */
292 ){
293 /* set mode and modification time */
294 sqlite3_snprintf(8, (char*)&tball.aHdr[100], "%07o", iMode);
295 sqlite3_snprintf(12, (char*)&tball.aHdr[136], "%011o", mTime);
@@ -341,11 +341,11 @@
341 unsigned int mTime /* Modification time */
342 ){
343 int i;
344 for(i=nName-1; i>0 && zName[i]!='/'; i--){}
345 if( i<=0 ) return;
346 if( i<tball.nPrevDirAlloc
347 && strncmp(tball.zPrevDir, zName, i)==0
348 && tball.zPrevDir[i]==0 ) return;
349 db_multi_exec("INSERT OR IGNORE INTO dir VALUES('%#q')", i, zName);
350 if( sqlite3_changes(g.db)==0 ) return;
351 tar_add_directory_of(zName, i-1, mTime);
@@ -377,11 +377,11 @@
377 char cType = '0';
378
379 /* length check moved to tar_split_path */
380 tar_add_directory_of(zName, nName, mTime);
381
382 /*
383 * If we have a symlink, write its destination path (which is stored in
384 * pContent) into header, and set content length to 0 to avoid storing path
385 * as file content in the next step. Since 'linkname' header is limited to
386 * 100 bytes (-1 byte for terminating zero), if path is greater than that,
387 * store symlink as a plain-text file. (Not sure how TAR handles long links.)
@@ -390,11 +390,11 @@
390 sqlite3_snprintf(100, (char*)&tball.aHdr[157], "%s", blob_str(pContent));
391 cType = '2';
392 n = 0;
393 }
394
395 tar_add_header(zName, nName, ( mPerm==PERM_EXE ) ? 0755 : 0644,
396 mTime, n, cType);
397 if( n ){
398 gzip_step(blob_buffer(pContent), n);
399 lastPage = n % 512;
400 if( lastPage!=0 ){
@@ -428,21 +428,20 @@
428 ** that contains files given in the second and subsequent arguments.
429 */
430 void test_tarball_cmd(void){
431 int i;
432 Blob zip;
433 Blob file;
434 if( g.argc<3 ){
435 usage("ARCHIVE FILE....");
436 }
437 sqlite3_open(":memory:", &g.db);
438 tar_begin(-1);
439 for(i=3; i<g.argc; i++){
 
440 blob_zero(&file);
441 blob_read_from_file(&file, g.argv[i]);
442 tar_add_file(g.argv[i], &file,
443 file_wd_perm(g.argv[i]), file_wd_mtime(g.argv[i]));
444 blob_reset(&file);
445 }
446 tar_finish(&zip);
447 blob_write_to_file(&zip, g.argv[2]);
448 }
@@ -591,11 +590,11 @@
591 ** Optional URL Parameters:
592 **
593 ** - name=NAME[.tar.gz] is base name of the output file. Defaults to
594 ** something project/version-specific. The prefix of the name, up to
595 ** the last '.', are used as the top-most directory name in the tar
596 ** output.
597 **
598 ** - uuid=the version to tar (may be a tag/branch name).
599 ** Defaults to "trunk".
600 **
601 */
602
--- src/tar.c
+++ src/tar.c
@@ -285,11 +285,11 @@
285 const char *zName, /* Name of the object */
286 int nName, /* Number of characters in zName */
287 int iMode, /* Mode. 0644 or 0755 */
288 unsigned int mTime, /* File modification time */
289 int iSize, /* Size of the object in bytes */
290 char cType /* Type of object:
291 '0'==file. '2'==symlink. '5'==directory */
292 ){
293 /* set mode and modification time */
294 sqlite3_snprintf(8, (char*)&tball.aHdr[100], "%07o", iMode);
295 sqlite3_snprintf(12, (char*)&tball.aHdr[136], "%011o", mTime);
@@ -341,11 +341,11 @@
341 unsigned int mTime /* Modification time */
342 ){
343 int i;
344 for(i=nName-1; i>0 && zName[i]!='/'; i--){}
345 if( i<=0 ) return;
346 if( i<tball.nPrevDirAlloc
347 && strncmp(tball.zPrevDir, zName, i)==0
348 && tball.zPrevDir[i]==0 ) return;
349 db_multi_exec("INSERT OR IGNORE INTO dir VALUES('%#q')", i, zName);
350 if( sqlite3_changes(g.db)==0 ) return;
351 tar_add_directory_of(zName, i-1, mTime);
@@ -377,11 +377,11 @@
377 char cType = '0';
378
379 /* length check moved to tar_split_path */
380 tar_add_directory_of(zName, nName, mTime);
381
382 /*
383 * If we have a symlink, write its destination path (which is stored in
384 * pContent) into header, and set content length to 0 to avoid storing path
385 * as file content in the next step. Since 'linkname' header is limited to
386 * 100 bytes (-1 byte for terminating zero), if path is greater than that,
387 * store symlink as a plain-text file. (Not sure how TAR handles long links.)
@@ -390,11 +390,11 @@
390 sqlite3_snprintf(100, (char*)&tball.aHdr[157], "%s", blob_str(pContent));
391 cType = '2';
392 n = 0;
393 }
394
395 tar_add_header(zName, nName, ( mPerm==PERM_EXE ) ? 0755 : 0644,
396 mTime, n, cType);
397 if( n ){
398 gzip_step(blob_buffer(pContent), n);
399 lastPage = n % 512;
400 if( lastPage!=0 ){
@@ -428,21 +428,20 @@
428 ** that contains files given in the second and subsequent arguments.
429 */
430 void test_tarball_cmd(void){
431 int i;
432 Blob zip;
 
433 if( g.argc<3 ){
434 usage("ARCHIVE FILE....");
435 }
436 sqlite3_open(":memory:", &g.db);
437 tar_begin(-1);
438 for(i=3; i<g.argc; i++){
439 Blob file;
440 blob_zero(&file);
441 blob_read_from_file(&file, g.argv[i]);
442 tar_add_file(g.argv[i], &file, file_wd_perm(0), file_wd_mtime(0));
 
443 blob_reset(&file);
444 }
445 tar_finish(&zip);
446 blob_write_to_file(&zip, g.argv[2]);
447 }
@@ -591,11 +590,11 @@
590 ** Optional URL Parameters:
591 **
592 ** - name=NAME[.tar.gz] is base name of the output file. Defaults to
593 ** something project/version-specific. The prefix of the name, up to
594 ** the last '.', are used as the top-most directory name in the tar
595 ** output.
596 **
597 ** - uuid=the version to tar (may be a tag/branch name).
598 ** Defaults to "trunk".
599 **
600 */
601
+10 -10
--- src/undo.c
+++ src/undo.c
@@ -12,11 +12,11 @@
1212
** Author contact information:
1313
** [email protected]
1414
** http://www.hwaci.com/drh/
1515
**
1616
*******************************************************************************
17
-**
17
+**
1818
** This file implements the undo/redo functionality.
1919
*/
2020
#include "config.h"
2121
#include "undo.h"
2222
@@ -45,19 +45,19 @@
4545
int old_link;
4646
Blob current;
4747
Blob new;
4848
zFullname = mprintf("%s/%s", g.zLocalRoot, zPathname);
4949
old_link = db_column_int(&q, 3);
50
- new_link = file_wd_islink(zFullname);
5150
new_exists = file_wd_size(zFullname)>=0;
51
+ new_link = file_wd_islink(0);
5252
if( new_exists ){
5353
if( new_link ){
5454
blob_read_link(&current, zFullname);
5555
}else{
56
- blob_read_from_file(&current, zFullname);
56
+ blob_read_from_file(&current, zFullname);
5757
}
58
- new_exe = file_wd_isexe(zFullname);
58
+ new_exe = file_wd_isexe(0);
5959
}else{
6060
blob_zero(&current);
6161
new_exe = 0;
6262
}
6363
blob_zero(&new);
@@ -86,11 +86,11 @@
8686
file_delete(zFullname);
8787
}
8888
blob_reset(&new);
8989
free(zFullname);
9090
db_finalize(&q);
91
- db_prepare(&q,
91
+ db_prepare(&q,
9292
"UPDATE undo SET content=:c, existsflag=%d, isExe=%d, isLink=%d,"
9393
" redoflag=NOT redoflag"
9494
" WHERE pathname=%Q",
9595
new_exists, new_exe, new_link, zPathname
9696
);
@@ -217,11 +217,11 @@
217217
** Begin capturing a snapshot that can be undone.
218218
*/
219219
void undo_begin(void){
220220
int cid;
221221
const char *zDb = db_name("localdb");
222
- static const char zSql[] =
222
+ static const char zSql[] =
223223
@ CREATE TABLE "%w".undo(
224224
@ pathname TEXT UNIQUE, -- Name of the file
225225
@ redoflag BOOLEAN, -- 0 for undoable. 1 for redoable
226226
@ existsflag BOOLEAN, -- True if the file exists
227227
@ isExe BOOLEAN, -- True if the file is executable
@@ -240,11 +240,11 @@
240240
db_lset("undo_cmdline", undoCmd);
241241
undoActive = 1;
242242
}
243243
244244
/*
245
-** Permanently disable undo
245
+** Permanently disable undo
246246
*/
247247
void undo_disable(void){
248248
undoDisable = 1;
249249
}
250250
@@ -279,11 +279,11 @@
279279
" VALUES(%Q,0,%d,%d,%d,:c)",
280280
zPathname, existsFlag, file_wd_isexe(zFullname), isLink
281281
);
282282
if( existsFlag ){
283283
if( isLink ){
284
- blob_read_link(&content, zFullname);
284
+ blob_read_link(&content, zFullname);
285285
}else{
286286
blob_read_from_file(&content, zFullname);
287287
}
288288
db_bind_blob(&q, ":c", &content);
289289
}
@@ -363,11 +363,11 @@
363363
** (2) fossil merge (6) fossil stash drop
364364
** (3) fossil revert (7) fossil stash goto
365365
** (4) fossil stash pop
366366
**
367367
** If FILENAME is specified then restore the content of the named
368
-** file(s) but otherwise leave the update or merge or revert in effect.
368
+** file(s) but otherwise leave the update or merge or revert in effect.
369369
** The redo command undoes the effect of the most recent undo.
370370
**
371371
** If the -n|--dry-run option is present, no changes are made and instead
372372
** the undo or redo command explains what actions the undo or redo would
373373
** have done had the -n|--dry-run been omitted.
@@ -410,11 +410,11 @@
410410
if( nChng==0 ){
411411
fossil_print("The following file changes would occur if the "
412412
"command above is %sne:\n\n", zCmd);
413413
}
414414
nChng++;
415
- fossil_print("%s %s\n",
415
+ fossil_print("%s %s\n",
416416
db_column_int(&q,0) ? "UPDATE" : "DELETE",
417417
db_column_text(&q, 1)
418418
);
419419
}
420420
db_finalize(&q);
421421
--- src/undo.c
+++ src/undo.c
@@ -12,11 +12,11 @@
12 ** Author contact information:
13 ** [email protected]
14 ** http://www.hwaci.com/drh/
15 **
16 *******************************************************************************
17 **
18 ** This file implements the undo/redo functionality.
19 */
20 #include "config.h"
21 #include "undo.h"
22
@@ -45,19 +45,19 @@
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);
51 new_exists = file_wd_size(zFullname)>=0;
 
52 if( new_exists ){
53 if( new_link ){
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);
@@ -86,11 +86,11 @@
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 );
@@ -217,11 +217,11 @@
217 ** Begin capturing a snapshot that can be undone.
218 */
219 void undo_begin(void){
220 int cid;
221 const char *zDb = db_name("localdb");
222 static const char zSql[] =
223 @ CREATE TABLE "%w".undo(
224 @ pathname TEXT UNIQUE, -- Name of the file
225 @ redoflag BOOLEAN, -- 0 for undoable. 1 for redoable
226 @ existsflag BOOLEAN, -- True if the file exists
227 @ isExe BOOLEAN, -- True if the file is executable
@@ -240,11 +240,11 @@
240 db_lset("undo_cmdline", undoCmd);
241 undoActive = 1;
242 }
243
244 /*
245 ** Permanently disable undo
246 */
247 void undo_disable(void){
248 undoDisable = 1;
249 }
250
@@ -279,11 +279,11 @@
279 " VALUES(%Q,0,%d,%d,%d,:c)",
280 zPathname, existsFlag, file_wd_isexe(zFullname), isLink
281 );
282 if( existsFlag ){
283 if( isLink ){
284 blob_read_link(&content, zFullname);
285 }else{
286 blob_read_from_file(&content, zFullname);
287 }
288 db_bind_blob(&q, ":c", &content);
289 }
@@ -363,11 +363,11 @@
363 ** (2) fossil merge (6) fossil stash drop
364 ** (3) fossil revert (7) fossil stash goto
365 ** (4) fossil stash pop
366 **
367 ** If FILENAME is specified then restore the content of the named
368 ** file(s) but otherwise leave the update or merge or revert in effect.
369 ** The redo command undoes the effect of the most recent undo.
370 **
371 ** If the -n|--dry-run option is present, no changes are made and instead
372 ** the undo or redo command explains what actions the undo or redo would
373 ** have done had the -n|--dry-run been omitted.
@@ -410,11 +410,11 @@
410 if( nChng==0 ){
411 fossil_print("The following file changes would occur if the "
412 "command above is %sne:\n\n", zCmd);
413 }
414 nChng++;
415 fossil_print("%s %s\n",
416 db_column_int(&q,0) ? "UPDATE" : "DELETE",
417 db_column_text(&q, 1)
418 );
419 }
420 db_finalize(&q);
421
--- src/undo.c
+++ src/undo.c
@@ -12,11 +12,11 @@
12 ** Author contact information:
13 ** [email protected]
14 ** http://www.hwaci.com/drh/
15 **
16 *******************************************************************************
17 **
18 ** This file implements the undo/redo functionality.
19 */
20 #include "config.h"
21 #include "undo.h"
22
@@ -45,19 +45,19 @@
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_exists = file_wd_size(zFullname)>=0;
51 new_link = file_wd_islink(0);
52 if( new_exists ){
53 if( new_link ){
54 blob_read_link(&current, zFullname);
55 }else{
56 blob_read_from_file(&current, zFullname);
57 }
58 new_exe = file_wd_isexe(0);
59 }else{
60 blob_zero(&current);
61 new_exe = 0;
62 }
63 blob_zero(&new);
@@ -86,11 +86,11 @@
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 );
@@ -217,11 +217,11 @@
217 ** Begin capturing a snapshot that can be undone.
218 */
219 void undo_begin(void){
220 int cid;
221 const char *zDb = db_name("localdb");
222 static const char zSql[] =
223 @ CREATE TABLE "%w".undo(
224 @ pathname TEXT UNIQUE, -- Name of the file
225 @ redoflag BOOLEAN, -- 0 for undoable. 1 for redoable
226 @ existsflag BOOLEAN, -- True if the file exists
227 @ isExe BOOLEAN, -- True if the file is executable
@@ -240,11 +240,11 @@
240 db_lset("undo_cmdline", undoCmd);
241 undoActive = 1;
242 }
243
244 /*
245 ** Permanently disable undo
246 */
247 void undo_disable(void){
248 undoDisable = 1;
249 }
250
@@ -279,11 +279,11 @@
279 " VALUES(%Q,0,%d,%d,%d,:c)",
280 zPathname, existsFlag, file_wd_isexe(zFullname), isLink
281 );
282 if( existsFlag ){
283 if( isLink ){
284 blob_read_link(&content, zFullname);
285 }else{
286 blob_read_from_file(&content, zFullname);
287 }
288 db_bind_blob(&q, ":c", &content);
289 }
@@ -363,11 +363,11 @@
363 ** (2) fossil merge (6) fossil stash drop
364 ** (3) fossil revert (7) fossil stash goto
365 ** (4) fossil stash pop
366 **
367 ** If FILENAME is specified then restore the content of the named
368 ** file(s) but otherwise leave the update or merge or revert in effect.
369 ** The redo command undoes the effect of the most recent undo.
370 **
371 ** If the -n|--dry-run option is present, no changes are made and instead
372 ** the undo or redo command explains what actions the undo or redo would
373 ** have done had the -n|--dry-run been omitted.
@@ -410,11 +410,11 @@
410 if( nChng==0 ){
411 fossil_print("The following file changes would occur if the "
412 "command above is %sne:\n\n", zCmd);
413 }
414 nChng++;
415 fossil_print("%s %s\n",
416 db_column_int(&q,0) ? "UPDATE" : "DELETE",
417 db_column_text(&q, 1)
418 );
419 }
420 db_finalize(&q);
421
+1 -1
--- src/update.c
+++ src/update.c
@@ -809,11 +809,11 @@
809809
zFile, zFile
810810
);
811811
}else{
812812
sqlite3_int64 mtime;
813813
undo_save(zFile);
814
- if( file_wd_size(zFull)>=0 && (isLink || file_wd_islink(zFull)) ){
814
+ if( file_wd_size(zFull)>=0 && (isLink || file_wd_islink(0)) ){
815815
file_delete(zFull);
816816
}
817817
if( isLink ){
818818
symlink_create(blob_str(&record), zFull);
819819
}else{
820820
--- src/update.c
+++ src/update.c
@@ -809,11 +809,11 @@
809 zFile, zFile
810 );
811 }else{
812 sqlite3_int64 mtime;
813 undo_save(zFile);
814 if( file_wd_size(zFull)>=0 && (isLink || file_wd_islink(zFull)) ){
815 file_delete(zFull);
816 }
817 if( isLink ){
818 symlink_create(blob_str(&record), zFull);
819 }else{
820
--- src/update.c
+++ src/update.c
@@ -809,11 +809,11 @@
809 zFile, zFile
810 );
811 }else{
812 sqlite3_int64 mtime;
813 undo_save(zFile);
814 if( file_wd_size(zFull)>=0 && (isLink || file_wd_islink(0)) ){
815 file_delete(zFull);
816 }
817 if( isLink ){
818 symlink_create(blob_str(&record), zFull);
819 }else{
820
+2 -2
--- src/vfile.c
+++ src/vfile.c
@@ -189,12 +189,12 @@
189189
zName = db_column_text(&q, 1);
190190
rid = db_column_int(&q, 2);
191191
isDeleted = db_column_int(&q, 3);
192192
oldChnged = chnged = db_column_int(&q, 4);
193193
oldMtime = db_column_int64(&q, 7);
194
- currentSize = file_wd_size(zName);
195194
origSize = db_column_int64(&q, 6);
195
+ currentSize = file_wd_size(zName);
196196
currentMtime = file_wd_mtime(0);
197197
if( chnged==0 && (isDeleted || rid==0) ){
198198
/* "fossil rm" or "fossil add" always change the file */
199199
chnged = 1;
200200
}else if( !file_wd_isfile_or_link(0) && currentSize>=0 ){
@@ -320,11 +320,11 @@
320320
if( verbose ) fossil_print("%s\n", &zName[nRepos]);
321321
if( file_wd_isdir(zName) == 1 ){
322322
/*TODO(dchest): remove directories? */
323323
fossil_fatal("%s is directory, cannot overwrite\n", zName);
324324
}
325
- if( file_wd_size(zName)>=0 && (isLink || file_wd_islink(zName)) ){
325
+ if( file_wd_size(zName)>=0 && (isLink || file_wd_islink(0)) ){
326326
file_delete(zName);
327327
}
328328
if( isLink ){
329329
symlink_create(blob_str(&content), zName);
330330
}else{
331331
--- src/vfile.c
+++ src/vfile.c
@@ -189,12 +189,12 @@
189 zName = db_column_text(&q, 1);
190 rid = db_column_int(&q, 2);
191 isDeleted = db_column_int(&q, 3);
192 oldChnged = chnged = db_column_int(&q, 4);
193 oldMtime = db_column_int64(&q, 7);
194 currentSize = file_wd_size(zName);
195 origSize = db_column_int64(&q, 6);
 
196 currentMtime = file_wd_mtime(0);
197 if( chnged==0 && (isDeleted || rid==0) ){
198 /* "fossil rm" or "fossil add" always change the file */
199 chnged = 1;
200 }else if( !file_wd_isfile_or_link(0) && currentSize>=0 ){
@@ -320,11 +320,11 @@
320 if( verbose ) fossil_print("%s\n", &zName[nRepos]);
321 if( file_wd_isdir(zName) == 1 ){
322 /*TODO(dchest): remove directories? */
323 fossil_fatal("%s is directory, cannot overwrite\n", zName);
324 }
325 if( file_wd_size(zName)>=0 && (isLink || file_wd_islink(zName)) ){
326 file_delete(zName);
327 }
328 if( isLink ){
329 symlink_create(blob_str(&content), zName);
330 }else{
331
--- src/vfile.c
+++ src/vfile.c
@@ -189,12 +189,12 @@
189 zName = db_column_text(&q, 1);
190 rid = db_column_int(&q, 2);
191 isDeleted = db_column_int(&q, 3);
192 oldChnged = chnged = db_column_int(&q, 4);
193 oldMtime = db_column_int64(&q, 7);
 
194 origSize = db_column_int64(&q, 6);
195 currentSize = file_wd_size(zName);
196 currentMtime = file_wd_mtime(0);
197 if( chnged==0 && (isDeleted || rid==0) ){
198 /* "fossil rm" or "fossil add" always change the file */
199 chnged = 1;
200 }else if( !file_wd_isfile_or_link(0) && currentSize>=0 ){
@@ -320,11 +320,11 @@
320 if( verbose ) fossil_print("%s\n", &zName[nRepos]);
321 if( file_wd_isdir(zName) == 1 ){
322 /*TODO(dchest): remove directories? */
323 fossil_fatal("%s is directory, cannot overwrite\n", zName);
324 }
325 if( file_wd_size(zName)>=0 && (isLink || file_wd_islink(0)) ){
326 file_delete(zName);
327 }
328 if( isLink ){
329 symlink_create(blob_str(&content), zName);
330 }else{
331

Keyboard Shortcuts

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