Fossil SCM

Cherrypick [3fbdaa243d]: Speedup "fossil extras" and other commands which traverse the local filesystem. See: [http://www.mail-archive.com/[email protected]/msg14697.html]. Thanks to Samuel Debionne for the suggestion.

jan.nijtmans 2014-02-25 11:06 UTC branch-1.28
Commit 5255b493184ae388043d94c73db48baac7ceefa3
+7 -1
--- src/rebuild.c
+++ src/rebuild.c
@@ -859,11 +859,17 @@
859859
continue;
860860
}
861861
zUtf8Name = fossil_filename_to_utf8(pEntry->d_name);
862862
zSubpath = mprintf("%s/%s", zPath, zUtf8Name);
863863
fossil_filename_free(zUtf8Name);
864
- if( file_isdir(zSubpath)==1 ){
864
+#ifdef _DIRENT_HAVE_D_TYPE
865
+ if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK)
866
+ ? (file_isdir(zSubpath)==1) : (pEntry->d_type==DT_DIR) )
867
+#else
868
+ if( file_isdir(zSubpath)==1 )
869
+#endif
870
+ {
865871
recon_read_dir(zSubpath);
866872
}else{
867873
blob_init(&path, 0, 0);
868874
blob_appendf(&path, "%s", zSubpath);
869875
if( blob_read_from_file(&aContent, blob_str(&path))==-1 ){
870876
--- src/rebuild.c
+++ src/rebuild.c
@@ -859,11 +859,17 @@
859 continue;
860 }
861 zUtf8Name = fossil_filename_to_utf8(pEntry->d_name);
862 zSubpath = mprintf("%s/%s", zPath, zUtf8Name);
863 fossil_filename_free(zUtf8Name);
864 if( file_isdir(zSubpath)==1 ){
 
 
 
 
 
 
865 recon_read_dir(zSubpath);
866 }else{
867 blob_init(&path, 0, 0);
868 blob_appendf(&path, "%s", zSubpath);
869 if( blob_read_from_file(&aContent, blob_str(&path))==-1 ){
870
--- src/rebuild.c
+++ src/rebuild.c
@@ -859,11 +859,17 @@
859 continue;
860 }
861 zUtf8Name = fossil_filename_to_utf8(pEntry->d_name);
862 zSubpath = mprintf("%s/%s", zPath, zUtf8Name);
863 fossil_filename_free(zUtf8Name);
864 #ifdef _DIRENT_HAVE_D_TYPE
865 if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK)
866 ? (file_isdir(zSubpath)==1) : (pEntry->d_type==DT_DIR) )
867 #else
868 if( file_isdir(zSubpath)==1 )
869 #endif
870 {
871 recon_read_dir(zSubpath);
872 }else{
873 blob_init(&path, 0, 0);
874 blob_appendf(&path, "%s", zSubpath);
875 if( blob_read_from_file(&aContent, blob_str(&path))==-1 ){
876
+7 -1
--- src/rebuild.c
+++ src/rebuild.c
@@ -859,11 +859,17 @@
859859
continue;
860860
}
861861
zUtf8Name = fossil_filename_to_utf8(pEntry->d_name);
862862
zSubpath = mprintf("%s/%s", zPath, zUtf8Name);
863863
fossil_filename_free(zUtf8Name);
864
- if( file_isdir(zSubpath)==1 ){
864
+#ifdef _DIRENT_HAVE_D_TYPE
865
+ if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK)
866
+ ? (file_isdir(zSubpath)==1) : (pEntry->d_type==DT_DIR) )
867
+#else
868
+ if( file_isdir(zSubpath)==1 )
869
+#endif
870
+ {
865871
recon_read_dir(zSubpath);
866872
}else{
867873
blob_init(&path, 0, 0);
868874
blob_appendf(&path, "%s", zSubpath);
869875
if( blob_read_from_file(&aContent, blob_str(&path))==-1 ){
870876
--- src/rebuild.c
+++ src/rebuild.c
@@ -859,11 +859,17 @@
859 continue;
860 }
861 zUtf8Name = fossil_filename_to_utf8(pEntry->d_name);
862 zSubpath = mprintf("%s/%s", zPath, zUtf8Name);
863 fossil_filename_free(zUtf8Name);
864 if( file_isdir(zSubpath)==1 ){
 
 
 
 
 
 
865 recon_read_dir(zSubpath);
866 }else{
867 blob_init(&path, 0, 0);
868 blob_appendf(&path, "%s", zSubpath);
869 if( blob_read_from_file(&aContent, blob_str(&path))==-1 ){
870
--- src/rebuild.c
+++ src/rebuild.c
@@ -859,11 +859,17 @@
859 continue;
860 }
861 zUtf8Name = fossil_filename_to_utf8(pEntry->d_name);
862 zSubpath = mprintf("%s/%s", zPath, zUtf8Name);
863 fossil_filename_free(zUtf8Name);
864 #ifdef _DIRENT_HAVE_D_TYPE
865 if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK)
866 ? (file_isdir(zSubpath)==1) : (pEntry->d_type==DT_DIR) )
867 #else
868 if( file_isdir(zSubpath)==1 )
869 #endif
870 {
871 recon_read_dir(zSubpath);
872 }else{
873 blob_init(&path, 0, 0);
874 blob_appendf(&path, "%s", zSubpath);
875 if( blob_read_from_file(&aContent, blob_str(&path))==-1 ){
876
+20
--- src/vfile.c
+++ src/vfile.c
@@ -486,15 +486,25 @@
486486
blob_appendf(pPath, "/%s", zUtf8);
487487
zPath = blob_str(pPath);
488488
if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
489489
glob_match(pIgnore2, &zPath[nPrefix+1]) ){
490490
/* do nothing */
491
+#ifdef _DIRENT_HAVE_D_TYPE
492
+ }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK)
493
+ ? (file_wd_isdir(zPath)==1) : (pEntry->d_type==DT_DIR) ){
494
+#else
491495
}else if( file_wd_isdir(zPath)==1 ){
496
+#endif
492497
if( !vfile_top_of_checkout(zPath) ){
493498
vfile_scan(pPath, nPrefix, scanFlags, pIgnore1, pIgnore2);
494499
}
500
+#ifdef _DIRENT_HAVE_D_TYPE
501
+ }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK)
502
+ ? (file_wd_isfile_or_link(zPath)) : (pEntry->d_type==DT_REG) ){
503
+#else
495504
}else if( file_wd_isfile_or_link(zPath) ){
505
+#endif
496506
if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(zUtf8) ){
497507
db_bind_text(&ins, ":file", &zPath[nPrefix+1]);
498508
db_step(&ins);
499509
db_reset(&ins);
500510
}
@@ -593,11 +603,16 @@
593603
zPath = blob_str(pPath);
594604
if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
595605
glob_match(pIgnore2, &zPath[nPrefix+1]) ||
596606
glob_match(pIgnore3, &zPath[nPrefix+1]) ){
597607
/* do nothing */
608
+#ifdef _DIRENT_HAVE_D_TYPE
609
+ }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK)
610
+ ? (file_wd_isdir(zPath)==1) : (pEntry->d_type==DT_DIR) ){
611
+#else
598612
}else if( file_wd_isdir(zPath)==1 ){
613
+#endif
599614
if( (scanFlags & SCAN_NESTED) || !vfile_top_of_checkout(zPath) ){
600615
char *zSavePath = mprintf("%s", zPath);
601616
int count = vfile_dir_scan(pPath, nPrefix, scanFlags, pIgnore1,
602617
pIgnore2, pIgnore3);
603618
db_bind_text(&ins, ":file", &zSavePath[nPrefix+1]);
@@ -605,11 +620,16 @@
605620
db_step(&ins);
606621
db_reset(&ins);
607622
fossil_free(zSavePath);
608623
result += count; /* found X normal files? */
609624
}
625
+#ifdef _DIRENT_HAVE_D_TYPE
626
+ }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK)
627
+ ? (file_wd_isfile_or_link(zPath)) : (pEntry->d_type==DT_REG) ){
628
+#else
610629
}else if( file_wd_isfile_or_link(zPath) ){
630
+#endif
611631
db_bind_text(&upd, ":file", zOrigPath);
612632
db_step(&upd);
613633
db_reset(&upd);
614634
result++; /* found 1 normal file */
615635
}
616636
--- src/vfile.c
+++ src/vfile.c
@@ -486,15 +486,25 @@
486 blob_appendf(pPath, "/%s", zUtf8);
487 zPath = blob_str(pPath);
488 if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
489 glob_match(pIgnore2, &zPath[nPrefix+1]) ){
490 /* do nothing */
 
 
 
 
491 }else if( file_wd_isdir(zPath)==1 ){
 
492 if( !vfile_top_of_checkout(zPath) ){
493 vfile_scan(pPath, nPrefix, scanFlags, pIgnore1, pIgnore2);
494 }
 
 
 
 
495 }else if( file_wd_isfile_or_link(zPath) ){
 
496 if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(zUtf8) ){
497 db_bind_text(&ins, ":file", &zPath[nPrefix+1]);
498 db_step(&ins);
499 db_reset(&ins);
500 }
@@ -593,11 +603,16 @@
593 zPath = blob_str(pPath);
594 if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
595 glob_match(pIgnore2, &zPath[nPrefix+1]) ||
596 glob_match(pIgnore3, &zPath[nPrefix+1]) ){
597 /* do nothing */
 
 
 
 
598 }else if( file_wd_isdir(zPath)==1 ){
 
599 if( (scanFlags & SCAN_NESTED) || !vfile_top_of_checkout(zPath) ){
600 char *zSavePath = mprintf("%s", zPath);
601 int count = vfile_dir_scan(pPath, nPrefix, scanFlags, pIgnore1,
602 pIgnore2, pIgnore3);
603 db_bind_text(&ins, ":file", &zSavePath[nPrefix+1]);
@@ -605,11 +620,16 @@
605 db_step(&ins);
606 db_reset(&ins);
607 fossil_free(zSavePath);
608 result += count; /* found X normal files? */
609 }
 
 
 
 
610 }else if( file_wd_isfile_or_link(zPath) ){
 
611 db_bind_text(&upd, ":file", zOrigPath);
612 db_step(&upd);
613 db_reset(&upd);
614 result++; /* found 1 normal file */
615 }
616
--- src/vfile.c
+++ src/vfile.c
@@ -486,15 +486,25 @@
486 blob_appendf(pPath, "/%s", zUtf8);
487 zPath = blob_str(pPath);
488 if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
489 glob_match(pIgnore2, &zPath[nPrefix+1]) ){
490 /* do nothing */
491 #ifdef _DIRENT_HAVE_D_TYPE
492 }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK)
493 ? (file_wd_isdir(zPath)==1) : (pEntry->d_type==DT_DIR) ){
494 #else
495 }else if( file_wd_isdir(zPath)==1 ){
496 #endif
497 if( !vfile_top_of_checkout(zPath) ){
498 vfile_scan(pPath, nPrefix, scanFlags, pIgnore1, pIgnore2);
499 }
500 #ifdef _DIRENT_HAVE_D_TYPE
501 }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK)
502 ? (file_wd_isfile_or_link(zPath)) : (pEntry->d_type==DT_REG) ){
503 #else
504 }else if( file_wd_isfile_or_link(zPath) ){
505 #endif
506 if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(zUtf8) ){
507 db_bind_text(&ins, ":file", &zPath[nPrefix+1]);
508 db_step(&ins);
509 db_reset(&ins);
510 }
@@ -593,11 +603,16 @@
603 zPath = blob_str(pPath);
604 if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
605 glob_match(pIgnore2, &zPath[nPrefix+1]) ||
606 glob_match(pIgnore3, &zPath[nPrefix+1]) ){
607 /* do nothing */
608 #ifdef _DIRENT_HAVE_D_TYPE
609 }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK)
610 ? (file_wd_isdir(zPath)==1) : (pEntry->d_type==DT_DIR) ){
611 #else
612 }else if( file_wd_isdir(zPath)==1 ){
613 #endif
614 if( (scanFlags & SCAN_NESTED) || !vfile_top_of_checkout(zPath) ){
615 char *zSavePath = mprintf("%s", zPath);
616 int count = vfile_dir_scan(pPath, nPrefix, scanFlags, pIgnore1,
617 pIgnore2, pIgnore3);
618 db_bind_text(&ins, ":file", &zSavePath[nPrefix+1]);
@@ -605,11 +620,16 @@
620 db_step(&ins);
621 db_reset(&ins);
622 fossil_free(zSavePath);
623 result += count; /* found X normal files? */
624 }
625 #ifdef _DIRENT_HAVE_D_TYPE
626 }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK)
627 ? (file_wd_isfile_or_link(zPath)) : (pEntry->d_type==DT_REG) ){
628 #else
629 }else if( file_wd_isfile_or_link(zPath) ){
630 #endif
631 db_bind_text(&upd, ":file", zOrigPath);
632 db_step(&upd);
633 db_reset(&upd);
634 result++; /* found 1 normal file */
635 }
636
+20
--- src/vfile.c
+++ src/vfile.c
@@ -486,15 +486,25 @@
486486
blob_appendf(pPath, "/%s", zUtf8);
487487
zPath = blob_str(pPath);
488488
if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
489489
glob_match(pIgnore2, &zPath[nPrefix+1]) ){
490490
/* do nothing */
491
+#ifdef _DIRENT_HAVE_D_TYPE
492
+ }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK)
493
+ ? (file_wd_isdir(zPath)==1) : (pEntry->d_type==DT_DIR) ){
494
+#else
491495
}else if( file_wd_isdir(zPath)==1 ){
496
+#endif
492497
if( !vfile_top_of_checkout(zPath) ){
493498
vfile_scan(pPath, nPrefix, scanFlags, pIgnore1, pIgnore2);
494499
}
500
+#ifdef _DIRENT_HAVE_D_TYPE
501
+ }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK)
502
+ ? (file_wd_isfile_or_link(zPath)) : (pEntry->d_type==DT_REG) ){
503
+#else
495504
}else if( file_wd_isfile_or_link(zPath) ){
505
+#endif
496506
if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(zUtf8) ){
497507
db_bind_text(&ins, ":file", &zPath[nPrefix+1]);
498508
db_step(&ins);
499509
db_reset(&ins);
500510
}
@@ -593,11 +603,16 @@
593603
zPath = blob_str(pPath);
594604
if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
595605
glob_match(pIgnore2, &zPath[nPrefix+1]) ||
596606
glob_match(pIgnore3, &zPath[nPrefix+1]) ){
597607
/* do nothing */
608
+#ifdef _DIRENT_HAVE_D_TYPE
609
+ }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK)
610
+ ? (file_wd_isdir(zPath)==1) : (pEntry->d_type==DT_DIR) ){
611
+#else
598612
}else if( file_wd_isdir(zPath)==1 ){
613
+#endif
599614
if( (scanFlags & SCAN_NESTED) || !vfile_top_of_checkout(zPath) ){
600615
char *zSavePath = mprintf("%s", zPath);
601616
int count = vfile_dir_scan(pPath, nPrefix, scanFlags, pIgnore1,
602617
pIgnore2, pIgnore3);
603618
db_bind_text(&ins, ":file", &zSavePath[nPrefix+1]);
@@ -605,11 +620,16 @@
605620
db_step(&ins);
606621
db_reset(&ins);
607622
fossil_free(zSavePath);
608623
result += count; /* found X normal files? */
609624
}
625
+#ifdef _DIRENT_HAVE_D_TYPE
626
+ }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK)
627
+ ? (file_wd_isfile_or_link(zPath)) : (pEntry->d_type==DT_REG) ){
628
+#else
610629
}else if( file_wd_isfile_or_link(zPath) ){
630
+#endif
611631
db_bind_text(&upd, ":file", zOrigPath);
612632
db_step(&upd);
613633
db_reset(&upd);
614634
result++; /* found 1 normal file */
615635
}
616636
--- src/vfile.c
+++ src/vfile.c
@@ -486,15 +486,25 @@
486 blob_appendf(pPath, "/%s", zUtf8);
487 zPath = blob_str(pPath);
488 if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
489 glob_match(pIgnore2, &zPath[nPrefix+1]) ){
490 /* do nothing */
 
 
 
 
491 }else if( file_wd_isdir(zPath)==1 ){
 
492 if( !vfile_top_of_checkout(zPath) ){
493 vfile_scan(pPath, nPrefix, scanFlags, pIgnore1, pIgnore2);
494 }
 
 
 
 
495 }else if( file_wd_isfile_or_link(zPath) ){
 
496 if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(zUtf8) ){
497 db_bind_text(&ins, ":file", &zPath[nPrefix+1]);
498 db_step(&ins);
499 db_reset(&ins);
500 }
@@ -593,11 +603,16 @@
593 zPath = blob_str(pPath);
594 if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
595 glob_match(pIgnore2, &zPath[nPrefix+1]) ||
596 glob_match(pIgnore3, &zPath[nPrefix+1]) ){
597 /* do nothing */
 
 
 
 
598 }else if( file_wd_isdir(zPath)==1 ){
 
599 if( (scanFlags & SCAN_NESTED) || !vfile_top_of_checkout(zPath) ){
600 char *zSavePath = mprintf("%s", zPath);
601 int count = vfile_dir_scan(pPath, nPrefix, scanFlags, pIgnore1,
602 pIgnore2, pIgnore3);
603 db_bind_text(&ins, ":file", &zSavePath[nPrefix+1]);
@@ -605,11 +620,16 @@
605 db_step(&ins);
606 db_reset(&ins);
607 fossil_free(zSavePath);
608 result += count; /* found X normal files? */
609 }
 
 
 
 
610 }else if( file_wd_isfile_or_link(zPath) ){
 
611 db_bind_text(&upd, ":file", zOrigPath);
612 db_step(&upd);
613 db_reset(&upd);
614 result++; /* found 1 normal file */
615 }
616
--- src/vfile.c
+++ src/vfile.c
@@ -486,15 +486,25 @@
486 blob_appendf(pPath, "/%s", zUtf8);
487 zPath = blob_str(pPath);
488 if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
489 glob_match(pIgnore2, &zPath[nPrefix+1]) ){
490 /* do nothing */
491 #ifdef _DIRENT_HAVE_D_TYPE
492 }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK)
493 ? (file_wd_isdir(zPath)==1) : (pEntry->d_type==DT_DIR) ){
494 #else
495 }else if( file_wd_isdir(zPath)==1 ){
496 #endif
497 if( !vfile_top_of_checkout(zPath) ){
498 vfile_scan(pPath, nPrefix, scanFlags, pIgnore1, pIgnore2);
499 }
500 #ifdef _DIRENT_HAVE_D_TYPE
501 }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK)
502 ? (file_wd_isfile_or_link(zPath)) : (pEntry->d_type==DT_REG) ){
503 #else
504 }else if( file_wd_isfile_or_link(zPath) ){
505 #endif
506 if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(zUtf8) ){
507 db_bind_text(&ins, ":file", &zPath[nPrefix+1]);
508 db_step(&ins);
509 db_reset(&ins);
510 }
@@ -593,11 +603,16 @@
603 zPath = blob_str(pPath);
604 if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
605 glob_match(pIgnore2, &zPath[nPrefix+1]) ||
606 glob_match(pIgnore3, &zPath[nPrefix+1]) ){
607 /* do nothing */
608 #ifdef _DIRENT_HAVE_D_TYPE
609 }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK)
610 ? (file_wd_isdir(zPath)==1) : (pEntry->d_type==DT_DIR) ){
611 #else
612 }else if( file_wd_isdir(zPath)==1 ){
613 #endif
614 if( (scanFlags & SCAN_NESTED) || !vfile_top_of_checkout(zPath) ){
615 char *zSavePath = mprintf("%s", zPath);
616 int count = vfile_dir_scan(pPath, nPrefix, scanFlags, pIgnore1,
617 pIgnore2, pIgnore3);
618 db_bind_text(&ins, ":file", &zSavePath[nPrefix+1]);
@@ -605,11 +620,16 @@
620 db_step(&ins);
621 db_reset(&ins);
622 fossil_free(zSavePath);
623 result += count; /* found X normal files? */
624 }
625 #ifdef _DIRENT_HAVE_D_TYPE
626 }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK)
627 ? (file_wd_isfile_or_link(zPath)) : (pEntry->d_type==DT_REG) ){
628 #else
629 }else if( file_wd_isfile_or_link(zPath) ){
630 #endif
631 db_bind_text(&upd, ":file", zOrigPath);
632 db_step(&upd);
633 db_reset(&upd);
634 result++; /* found 1 normal file */
635 }
636

Keyboard Shortcuts

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