Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Speedup handling of checked-out files: When multiple information about a file is requested (size, mtime, permission flags) only call stat() once. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
dd94e596f4bc6e483b110741baf1bd2e |
| User & Date: | jan.nijtmans 2015-02-10 08:24:05.048 |
Context
|
2015-02-11
| ||
| 01:55 | Add the m= query parameter to /timeline. Disable the y= selection box on /timeline for cases where other parameters only allow checkins. Further work needed on the a= and b= query parameters to get them working with all combinations of other parameters. check-in: 45127a7236 user: drh tags: trunk | |
|
2015-02-10
| ||
| 17:31 | Merge updates from trunk. Closed-Leaf check-in: 488dcfada1 user: mistachkin tags: viric_pbranch | |
| 08:24 | Speedup handling of checked-out files: When multiple information about a file is requested (size, mtime, permission flags) only call stat() once. check-in: dd94e596f4 user: jan.nijtmans tags: trunk | |
|
2015-02-09
| ||
| 12:18 | Add mime-types for openoffice documents. Cherry-picked from [/timeline?r=viric_flavour|viric_flavour] branch. Thanks! check-in: 04e6a82ed7 user: jan.nijtmans tags: trunk | |
Changes
Changes to src/add.c.
| ︙ | ︙ | |||
151 152 153 154 155 156 157 158 159 160 |
}
if( db_exists("SELECT 1 FROM vfile"
" WHERE pathname=%Q %s", zPath, filename_collation()) ){
db_multi_exec("UPDATE vfile SET deleted=0"
" WHERE pathname=%Q %s", zPath, filename_collation());
}else{
char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath);
db_multi_exec(
"INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe,islink)"
"VALUES(%d,0,0,0,%Q,%d,%d)",
| > | | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
}
if( db_exists("SELECT 1 FROM vfile"
" WHERE pathname=%Q %s", zPath, filename_collation()) ){
db_multi_exec("UPDATE vfile SET deleted=0"
" WHERE pathname=%Q %s", zPath, filename_collation());
}else{
char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath);
int isExe = file_wd_isexe(zFullname);
db_multi_exec(
"INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe,islink)"
"VALUES(%d,0,0,0,%Q,%d,%d)",
vid, zPath, isExe, file_wd_islink(0));
fossil_free(zFullname);
}
if( db_changes() ){
fossil_print("ADDED %s\n", zPath);
return 1;
}else{
fossil_print("SKIP %s\n", zPath);
|
| ︙ | ︙ |
Changes to src/diffcmd.c.
| ︙ | ︙ | |||
107 108 109 110 111 112 113 |
const char *zName2; /* Name of zFile2 for display */
/* Read content of zFile2 into memory */
blob_zero(&file2);
if( file_wd_size(zFile2)<0 ){
zName2 = NULL_DEVICE;
}else{
| | | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
const char *zName2; /* Name of zFile2 for display */
/* Read content of zFile2 into memory */
blob_zero(&file2);
if( file_wd_size(zFile2)<0 ){
zName2 = NULL_DEVICE;
}else{
if( file_wd_islink(0) ){
blob_read_link(&file2, zFile2);
}else{
blob_read_from_file(&file2, zFile2);
}
zName2 = zName;
}
|
| ︙ | ︙ | |||
154 155 156 157 158 159 160 |
glob_free(pBinary);
return;
}
glob_free(pBinary);
}
blob_zero(&file2);
if( file_wd_size(zFile2)>=0 ){
| | | 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
glob_free(pBinary);
return;
}
glob_free(pBinary);
}
blob_zero(&file2);
if( file_wd_size(zFile2)>=0 ){
if( file_wd_islink(0) ){
blob_read_link(&file2, zFile2);
}else{
blob_read_from_file(&file2, zFile2);
}
}
if( looks_like_binary(&file2) ){
fossil_print("%s",DIFF_CANNOT_COMPUTE_BINARY);
|
| ︙ | ︙ |
Changes to src/file.c.
| ︙ | ︙ | |||
230 231 232 233 234 235 236 | blob_read_link(&content, zFrom); symlink_create(blob_str(&content), zTo); blob_reset(&content); } /* ** Return file permissions (normal, executable, or symlink): | | < | < < | | | < < < < < | | > | | < | 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
blob_read_link(&content, zFrom);
symlink_create(blob_str(&content), zTo);
blob_reset(&content);
}
/*
** Return file permissions (normal, executable, or symlink):
** - PERM_EXE on Unix if file is executable;
** - PERM_LNK on Unix if file is symlink and allow-symlinks option is on;
** - PERM_REG for all other cases (regular file, directory, fifo, etc).
*/
int file_wd_perm(const char *zFilename){
#if !defined(_WIN32)
if( !getStat(zFilename, 1) ){
if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
return PERM_EXE;
else if( g.allowSymlinks && S_ISLNK(fileStat.st_mode) )
return PERM_LNK;
}
#endif
return PERM_REG;
}
/*
** Return TRUE if the named file is an executable. Return false
** for directories, devices, fifos, symlinks, etc.
*/
int file_wd_isexe(const char *zFilename){
|
| ︙ | ︙ |
Changes to src/tar.c.
| ︙ | ︙ | |||
283 284 285 286 287 288 289 | */ static void tar_add_header( const char *zName, /* Name of the object */ int nName, /* Number of characters in zName */ int iMode, /* Mode. 0644 or 0755 */ unsigned int mTime, /* File modification time */ int iSize, /* Size of the object in bytes */ | | | 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
*/
static void tar_add_header(
const char *zName, /* Name of the object */
int nName, /* Number of characters in zName */
int iMode, /* Mode. 0644 or 0755 */
unsigned int mTime, /* File modification time */
int iSize, /* Size of the object in bytes */
char cType /* Type of object:
'0'==file. '2'==symlink. '5'==directory */
){
/* set mode and modification time */
sqlite3_snprintf(8, (char*)&tball.aHdr[100], "%07o", iMode);
sqlite3_snprintf(12, (char*)&tball.aHdr[136], "%011o", mTime);
/* see if we need to output a Pax Interchange Header */
|
| ︙ | ︙ | |||
339 340 341 342 343 344 345 |
const char *zName, /* Name of directory including final "/" */
int nName, /* Characters in zName */
unsigned int mTime /* Modification time */
){
int i;
for(i=nName-1; i>0 && zName[i]!='/'; i--){}
if( i<=0 ) return;
| | | 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
const char *zName, /* Name of directory including final "/" */
int nName, /* Characters in zName */
unsigned int mTime /* Modification time */
){
int i;
for(i=nName-1; i>0 && zName[i]!='/'; i--){}
if( i<=0 ) return;
if( i<tball.nPrevDirAlloc
&& strncmp(tball.zPrevDir, zName, i)==0
&& tball.zPrevDir[i]==0 ) return;
db_multi_exec("INSERT OR IGNORE INTO dir VALUES('%#q')", i, zName);
if( sqlite3_changes(g.db)==0 ) return;
tar_add_directory_of(zName, i-1, mTime);
tar_add_header(zName, i, 0755, mTime, 0, '5');
if( i >= tball.nPrevDirAlloc ){
|
| ︙ | ︙ | |||
375 376 377 378 379 380 381 | int n = blob_size(pContent); int lastPage; char cType = '0'; /* length check moved to tar_split_path */ tar_add_directory_of(zName, nName, mTime); | | | | 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
int n = blob_size(pContent);
int lastPage;
char cType = '0';
/* length check moved to tar_split_path */
tar_add_directory_of(zName, nName, mTime);
/*
* If we have a symlink, write its destination path (which is stored in
* pContent) into header, and set content length to 0 to avoid storing path
* as file content in the next step. Since 'linkname' header is limited to
* 100 bytes (-1 byte for terminating zero), if path is greater than that,
* store symlink as a plain-text file. (Not sure how TAR handles long links.)
*/
if( mPerm == PERM_LNK && n <= 100 ){
sqlite3_snprintf(100, (char*)&tball.aHdr[157], "%s", blob_str(pContent));
cType = '2';
n = 0;
}
tar_add_header(zName, nName, ( mPerm==PERM_EXE ) ? 0755 : 0644,
mTime, n, cType);
if( n ){
gzip_step(blob_buffer(pContent), n);
lastPage = n % 512;
if( lastPage!=0 ){
gzip_step(tball.zSpaces, 512 - lastPage);
}
|
| ︙ | ︙ | |||
426 427 428 429 430 431 432 |
**
** Generate a GZIP-compressed tarball in the file given by the first argument
** that contains files given in the second and subsequent arguments.
*/
void test_tarball_cmd(void){
int i;
Blob zip;
| < > | < | 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 |
**
** Generate a GZIP-compressed tarball in the file given by the first argument
** that contains files given in the second and subsequent arguments.
*/
void test_tarball_cmd(void){
int i;
Blob zip;
if( g.argc<3 ){
usage("ARCHIVE FILE....");
}
sqlite3_open(":memory:", &g.db);
tar_begin(-1);
for(i=3; i<g.argc; i++){
Blob file;
blob_zero(&file);
blob_read_from_file(&file, g.argv[i]);
tar_add_file(g.argv[i], &file, file_wd_perm(0), file_wd_mtime(0));
blob_reset(&file);
}
tar_finish(&zip);
blob_write_to_file(&zip, g.argv[2]);
}
/*
|
| ︙ | ︙ | |||
589 590 591 592 593 594 595 | ** Return that tarball as the HTTP reply content. ** ** Optional URL Parameters: ** ** - name=NAME[.tar.gz] is base name of the output file. Defaults to ** something project/version-specific. The prefix of the name, up to ** the last '.', are used as the top-most directory name in the tar | | | 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 |
** Return that tarball as the HTTP reply content.
**
** Optional URL Parameters:
**
** - name=NAME[.tar.gz] is base name of the output file. Defaults to
** something project/version-specific. The prefix of the name, up to
** the last '.', are used as the top-most directory name in the tar
** output.
**
** - uuid=the version to tar (may be a tag/branch name).
** Defaults to "trunk".
**
*/
void tarball_page(void){
int rid;
|
| ︙ | ︙ |
Changes to src/undo.c.
| ︙ | ︙ | |||
10 11 12 13 14 15 16 | ** merchantability or fitness for a particular purpose. ** ** Author contact information: ** drh@hwaci.com ** http://www.hwaci.com/drh/ ** ******************************************************************************* | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ** merchantability or fitness for a particular purpose. ** ** Author contact information: ** drh@hwaci.com ** http://www.hwaci.com/drh/ ** ******************************************************************************* ** ** This file implements the undo/redo functionality. */ #include "config.h" #include "undo.h" |
| ︙ | ︙ | |||
43 44 45 46 47 48 49 |
int new_exe;
int new_link;
int old_link;
Blob current;
Blob new;
zFullname = mprintf("%s/%s", g.zLocalRoot, zPathname);
old_link = db_column_int(&q, 3);
| < > | | | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
int new_exe;
int new_link;
int old_link;
Blob current;
Blob new;
zFullname = mprintf("%s/%s", g.zLocalRoot, zPathname);
old_link = db_column_int(&q, 3);
new_exists = file_wd_size(zFullname)>=0;
new_link = file_wd_islink(0);
if( new_exists ){
if( new_link ){
blob_read_link(¤t, zFullname);
}else{
blob_read_from_file(¤t, zFullname);
}
new_exe = file_wd_isexe(0);
}else{
blob_zero(¤t);
new_exe = 0;
}
blob_zero(&new);
old_exists = db_column_int(&q, 1);
old_exe = db_column_int(&q, 2);
|
| ︙ | ︙ | |||
84 85 86 87 88 89 90 |
}else{
fossil_print("DELETE %s\n", zPathname);
file_delete(zFullname);
}
blob_reset(&new);
free(zFullname);
db_finalize(&q);
| | | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
}else{
fossil_print("DELETE %s\n", zPathname);
file_delete(zFullname);
}
blob_reset(&new);
free(zFullname);
db_finalize(&q);
db_prepare(&q,
"UPDATE undo SET content=:c, existsflag=%d, isExe=%d, isLink=%d,"
" redoflag=NOT redoflag"
" WHERE pathname=%Q",
new_exists, new_exe, new_link, zPathname
);
if( new_exists ){
db_bind_blob(&q, ":c", ¤t);
|
| ︙ | ︙ | |||
215 216 217 218 219 220 221 |
/*
** Begin capturing a snapshot that can be undone.
*/
void undo_begin(void){
int cid;
const char *zDb = db_name("localdb");
| | | 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
/*
** Begin capturing a snapshot that can be undone.
*/
void undo_begin(void){
int cid;
const char *zDb = db_name("localdb");
static const char zSql[] =
@ CREATE TABLE "%w".undo(
@ pathname TEXT UNIQUE, -- Name of the file
@ redoflag BOOLEAN, -- 0 for undoable. 1 for redoable
@ existsflag BOOLEAN, -- True if the file exists
@ isExe BOOLEAN, -- True if the file is executable
@ isLink BOOLEAN, -- True if the file is symlink
@ content BLOB -- Saved content
|
| ︙ | ︙ | |||
238 239 240 241 242 243 244 |
db_lset_int("undo_checkout", cid);
db_lset_int("undo_available", 1);
db_lset("undo_cmdline", undoCmd);
undoActive = 1;
}
/*
| | | 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
db_lset_int("undo_checkout", cid);
db_lset_int("undo_available", 1);
db_lset("undo_cmdline", undoCmd);
undoActive = 1;
}
/*
** Permanently disable undo
*/
void undo_disable(void){
undoDisable = 1;
}
/*
** This flag is true if one or more files have changed and have been
|
| ︙ | ︙ | |||
277 278 279 280 281 282 283 |
"INSERT OR IGNORE INTO"
" undo(pathname,redoflag,existsflag,isExe,isLink,content)"
" VALUES(%Q,0,%d,%d,%d,:c)",
zPathname, existsFlag, file_wd_isexe(zFullname), isLink
);
if( existsFlag ){
if( isLink ){
| | | 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
"INSERT OR IGNORE INTO"
" undo(pathname,redoflag,existsflag,isExe,isLink,content)"
" VALUES(%Q,0,%d,%d,%d,:c)",
zPathname, existsFlag, file_wd_isexe(zFullname), isLink
);
if( existsFlag ){
if( isLink ){
blob_read_link(&content, zFullname);
}else{
blob_read_from_file(&content, zFullname);
}
db_bind_blob(&q, ":c", &content);
}
free(zFullname);
db_step(&q);
|
| ︙ | ︙ | |||
361 362 363 364 365 366 367 | ** ** (1) fossil update (5) fossil stash apply ** (2) fossil merge (6) fossil stash drop ** (3) fossil revert (7) fossil stash goto ** (4) fossil stash pop ** ** If FILENAME is specified then restore the content of the named | | | 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | ** ** (1) fossil update (5) fossil stash apply ** (2) fossil merge (6) fossil stash drop ** (3) fossil revert (7) fossil stash goto ** (4) fossil stash pop ** ** If FILENAME is specified then restore the content of the named ** file(s) but otherwise leave the update or merge or revert in effect. ** The redo command undoes the effect of the most recent undo. ** ** If the -n|--dry-run option is present, no changes are made and instead ** the undo or redo command explains what actions the undo or redo would ** have done had the -n|--dry-run been omitted. ** ** A single level of undo/redo is supported. The undo/redo stack |
| ︙ | ︙ | |||
408 409 410 411 412 413 414 |
);
while( db_step(&q)==SQLITE_ROW ){
if( nChng==0 ){
fossil_print("The following file changes would occur if the "
"command above is %sne:\n\n", zCmd);
}
nChng++;
| | | 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 |
);
while( db_step(&q)==SQLITE_ROW ){
if( nChng==0 ){
fossil_print("The following file changes would occur if the "
"command above is %sne:\n\n", zCmd);
}
nChng++;
fossil_print("%s %s\n",
db_column_int(&q,0) ? "UPDATE" : "DELETE",
db_column_text(&q, 1)
);
}
db_finalize(&q);
if( nChng==0 ){
fossil_print("No file changes would occur with this undo/redo.\n");
|
| ︙ | ︙ |
Changes to src/update.c.
| ︙ | ︙ | |||
807 808 809 810 811 812 813 |
" WHERE pathname=%Q AND origname!=pathname;"
"DELETE FROM vfile WHERE pathname=%Q",
zFile, zFile
);
}else{
sqlite3_int64 mtime;
undo_save(zFile);
| | | 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 |
" WHERE pathname=%Q AND origname!=pathname;"
"DELETE FROM vfile WHERE pathname=%Q",
zFile, zFile
);
}else{
sqlite3_int64 mtime;
undo_save(zFile);
if( file_wd_size(zFull)>=0 && (isLink || file_wd_islink(0)) ){
file_delete(zFull);
}
if( isLink ){
symlink_create(blob_str(&record), zFull);
}else{
blob_write_to_file(&record, zFull);
}
|
| ︙ | ︙ |
Changes to src/vfile.c.
| ︙ | ︙ | |||
187 188 189 190 191 192 193 |
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 = chnged = db_column_int(&q, 4);
oldMtime = db_column_int64(&q, 7);
| < > | 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
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 = chnged = db_column_int(&q, 4);
oldMtime = db_column_int64(&q, 7);
origSize = db_column_int64(&q, 6);
currentSize = file_wd_size(zName);
currentMtime = file_wd_mtime(0);
if( chnged==0 && (isDeleted || rid==0) ){
/* "fossil rm" or "fossil add" always change the file */
chnged = 1;
}else if( !file_wd_isfile_or_link(0) && currentSize>=0 ){
if( cksigFlags & CKSIG_ENOTFILE ){
fossil_warning("not an ordinary file: %s", zName);
|
| ︙ | ︙ | |||
318 319 320 321 322 323 324 |
}
}
if( verbose ) fossil_print("%s\n", &zName[nRepos]);
if( file_wd_isdir(zName) == 1 ){
/*TODO(dchest): remove directories? */
fossil_fatal("%s is directory, cannot overwrite\n", zName);
}
| | | 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
}
}
if( verbose ) fossil_print("%s\n", &zName[nRepos]);
if( file_wd_isdir(zName) == 1 ){
/*TODO(dchest): remove directories? */
fossil_fatal("%s is directory, cannot overwrite\n", zName);
}
if( file_wd_size(zName)>=0 && (isLink || file_wd_islink(0)) ){
file_delete(zName);
}
if( isLink ){
symlink_create(blob_str(&content), zName);
}else{
blob_write_to_file(&content, zName);
}
|
| ︙ | ︙ |