Fossil SCM

Add versionable empty-dirs setting which specifies a newline separated list of empty directories to be created after checkout and update commands.

ben 2011-05-22 09:52 versionable-settings
Commit 3fa5cfaec83f357a52e86b77439c27a0d88517b9
--- src/checkout.c
+++ src/checkout.c
@@ -242,10 +242,11 @@
242242
if( !keepFlag ){
243243
vfile_to_disk(vid, 0, 1, promptFlag);
244244
}
245245
checkout_set_all_exe(vid);
246246
manifest_to_disk(vid);
247
+ ensure_empty_dirs_created();
247248
db_lset_int("checkout", vid);
248249
undo_reset();
249250
db_multi_exec("DELETE FROM vmerge");
250251
if( !keepFlag && db_get_boolean("repo-cksum",1) ){
251252
vfile_aggregate_checksum_manifest(vid, &cksum1, &cksum1b);
252253
--- src/checkout.c
+++ src/checkout.c
@@ -242,10 +242,11 @@
242 if( !keepFlag ){
243 vfile_to_disk(vid, 0, 1, promptFlag);
244 }
245 checkout_set_all_exe(vid);
246 manifest_to_disk(vid);
 
247 db_lset_int("checkout", vid);
248 undo_reset();
249 db_multi_exec("DELETE FROM vmerge");
250 if( !keepFlag && db_get_boolean("repo-cksum",1) ){
251 vfile_aggregate_checksum_manifest(vid, &cksum1, &cksum1b);
252
--- src/checkout.c
+++ src/checkout.c
@@ -242,10 +242,11 @@
242 if( !keepFlag ){
243 vfile_to_disk(vid, 0, 1, promptFlag);
244 }
245 checkout_set_all_exe(vid);
246 manifest_to_disk(vid);
247 ensure_empty_dirs_created();
248 db_lset_int("checkout", vid);
249 undo_reset();
250 db_multi_exec("DELETE FROM vmerge");
251 if( !keepFlag && db_get_boolean("repo-cksum",1) ){
252 vfile_aggregate_checksum_manifest(vid, &cksum1, &cksum1b);
253
--- src/configure.c
+++ src/configure.c
@@ -81,10 +81,11 @@
8181
{ "project-name", CONFIGSET_PROJ },
8282
{ "project-description", CONFIGSET_PROJ },
8383
{ "manifest", CONFIGSET_PROJ },
8484
{ "ignore-glob", CONFIGSET_PROJ },
8585
{ "crnl-glob", CONFIGSET_PROJ },
86
+ { "empty-dirs", CONFIGSET_PROJ },
8687
{ "index-page", CONFIGSET_SKIN },
8788
{ "timeline-block-markup", CONFIGSET_SKIN },
8889
{ "timeline-max-comment", CONFIGSET_SKIN },
8990
{ "ticket-table", CONFIGSET_TKT },
9091
{ "ticket-common", CONFIGSET_TKT },
9192
--- src/configure.c
+++ src/configure.c
@@ -81,10 +81,11 @@
81 { "project-name", CONFIGSET_PROJ },
82 { "project-description", CONFIGSET_PROJ },
83 { "manifest", CONFIGSET_PROJ },
84 { "ignore-glob", CONFIGSET_PROJ },
85 { "crnl-glob", CONFIGSET_PROJ },
 
86 { "index-page", CONFIGSET_SKIN },
87 { "timeline-block-markup", CONFIGSET_SKIN },
88 { "timeline-max-comment", CONFIGSET_SKIN },
89 { "ticket-table", CONFIGSET_TKT },
90 { "ticket-common", CONFIGSET_TKT },
91
--- src/configure.c
+++ src/configure.c
@@ -81,10 +81,11 @@
81 { "project-name", CONFIGSET_PROJ },
82 { "project-description", CONFIGSET_PROJ },
83 { "manifest", CONFIGSET_PROJ },
84 { "ignore-glob", CONFIGSET_PROJ },
85 { "crnl-glob", CONFIGSET_PROJ },
86 { "empty-dirs", CONFIGSET_PROJ },
87 { "index-page", CONFIGSET_SKIN },
88 { "timeline-block-markup", CONFIGSET_SKIN },
89 { "timeline-max-comment", CONFIGSET_SKIN },
90 { "ticket-table", CONFIGSET_TKT },
91 { "ticket-common", CONFIGSET_TKT },
92
+1
--- src/db.c
+++ src/db.c
@@ -1688,10 +1688,11 @@
16881688
{ "editor", 0, 16, "" },
16891689
{ "gdiff-command", 0, 16, "gdiff" },
16901690
{ "gmerge-command",0, 40, "" },
16911691
{ "https-login", 0, 0, "off" },
16921692
{ "ignore-glob", 0, 40, "" },
1693
+ { "empty-dirs", 0, 40, "" },
16931694
{ "http-port", 0, 16, "8080" },
16941695
{ "localauth", 0, 0, "off" },
16951696
{ "main-branch", 0, 40, "trunk" },
16961697
{ "manifest", 0, 0, "off" },
16971698
{ "max-upload", 0, 25, "250000" },
16981699
--- src/db.c
+++ src/db.c
@@ -1688,10 +1688,11 @@
1688 { "editor", 0, 16, "" },
1689 { "gdiff-command", 0, 16, "gdiff" },
1690 { "gmerge-command",0, 40, "" },
1691 { "https-login", 0, 0, "off" },
1692 { "ignore-glob", 0, 40, "" },
 
1693 { "http-port", 0, 16, "8080" },
1694 { "localauth", 0, 0, "off" },
1695 { "main-branch", 0, 40, "trunk" },
1696 { "manifest", 0, 0, "off" },
1697 { "max-upload", 0, 25, "250000" },
1698
--- src/db.c
+++ src/db.c
@@ -1688,10 +1688,11 @@
1688 { "editor", 0, 16, "" },
1689 { "gdiff-command", 0, 16, "gdiff" },
1690 { "gmerge-command",0, 40, "" },
1691 { "https-login", 0, 0, "off" },
1692 { "ignore-glob", 0, 40, "" },
1693 { "empty-dirs", 0, 40, "" },
1694 { "http-port", 0, 16, "8080" },
1695 { "localauth", 0, 0, "off" },
1696 { "main-branch", 0, 40, "trunk" },
1697 { "manifest", 0, 0, "off" },
1698 { "max-upload", 0, 25, "250000" },
1699
+29
--- src/update.c
+++ src/update.c
@@ -115,10 +115,13 @@
115115
}
116116
if( !nochangeFlag && db_exists("SELECT 1 FROM vmerge") ){
117117
fossil_fatal("cannot update an uncommitted merge");
118118
}
119119
if( !nochangeFlag && !internalUpdate ) autosync(AUTOSYNC_PULL);
120
+
121
+ /* Create any empty directories now, as well as after the update, so changes in settings are reflected now */
122
+ ensure_empty_dirs_created();
120123
121124
if( internalUpdate ){
122125
tid = internalUpdate;
123126
}else if( g.argc>=3 ){
124127
if( strcmp(g.argv[2], "current")==0 ){
@@ -440,10 +443,11 @@
440443
** Clean up the mid and pid VFILE entries. Then commit the changes.
441444
*/
442445
if( nochangeFlag ){
443446
db_end_transaction(1); /* With --nochange, rollback changes */
444447
}else{
448
+ ensure_empty_dirs_created();
445449
if( g.argc<=3 ){
446450
/* All files updated. Shift the current checkout to the target. */
447451
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
448452
checkout_set_all_exe(vid);
449453
manifest_to_disk(tid);
@@ -455,10 +459,35 @@
455459
}
456460
if( !internalUpdate ) undo_finish();
457461
db_end_transaction(0);
458462
}
459463
}
464
+
465
+/*
466
+** Make sure empty directories are created
467
+*/
468
+void ensure_empty_dirs_created()
469
+{
470
+ /* Make empty directories? */
471
+ char *zEmptyDirs = db_get_versionable_setting("empty-dirs", 0);
472
+ if( zEmptyDirs!=0 ){
473
+ Blob dirsList, line;
474
+ blob_zero(&dirsList);
475
+ blob_init(&dirsList, zEmptyDirs, strlen(zEmptyDirs));
476
+ while( blob_line(&dirsList, &line) ){
477
+ if( blob_buffer(&line)[0]=='#' ) continue;
478
+ Blob dirName;
479
+ int l = blob_token(&line, &dirName);
480
+ if(l > 0) {
481
+ /* Try and create the directory */
482
+ if( file_mkdir(blob_str(&dirName), 0)!=0 ) {
483
+ fossil_warning("couldn't create empty-dir %s", blob_str(&dirName));
484
+ }
485
+ }
486
+ }
487
+ }
488
+}
460489
461490
462491
/*
463492
** Get the contents of a file within the checking "revision". If
464493
** revision==NULL then get the file content for the current checkout.
465494
--- src/update.c
+++ src/update.c
@@ -115,10 +115,13 @@
115 }
116 if( !nochangeFlag && db_exists("SELECT 1 FROM vmerge") ){
117 fossil_fatal("cannot update an uncommitted merge");
118 }
119 if( !nochangeFlag && !internalUpdate ) autosync(AUTOSYNC_PULL);
 
 
 
120
121 if( internalUpdate ){
122 tid = internalUpdate;
123 }else if( g.argc>=3 ){
124 if( strcmp(g.argv[2], "current")==0 ){
@@ -440,10 +443,11 @@
440 ** Clean up the mid and pid VFILE entries. Then commit the changes.
441 */
442 if( nochangeFlag ){
443 db_end_transaction(1); /* With --nochange, rollback changes */
444 }else{
 
445 if( g.argc<=3 ){
446 /* All files updated. Shift the current checkout to the target. */
447 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
448 checkout_set_all_exe(vid);
449 manifest_to_disk(tid);
@@ -455,10 +459,35 @@
455 }
456 if( !internalUpdate ) undo_finish();
457 db_end_transaction(0);
458 }
459 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
460
461
462 /*
463 ** Get the contents of a file within the checking "revision". If
464 ** revision==NULL then get the file content for the current checkout.
465
--- src/update.c
+++ src/update.c
@@ -115,10 +115,13 @@
115 }
116 if( !nochangeFlag && db_exists("SELECT 1 FROM vmerge") ){
117 fossil_fatal("cannot update an uncommitted merge");
118 }
119 if( !nochangeFlag && !internalUpdate ) autosync(AUTOSYNC_PULL);
120
121 /* Create any empty directories now, as well as after the update, so changes in settings are reflected now */
122 ensure_empty_dirs_created();
123
124 if( internalUpdate ){
125 tid = internalUpdate;
126 }else if( g.argc>=3 ){
127 if( strcmp(g.argv[2], "current")==0 ){
@@ -440,10 +443,11 @@
443 ** Clean up the mid and pid VFILE entries. Then commit the changes.
444 */
445 if( nochangeFlag ){
446 db_end_transaction(1); /* With --nochange, rollback changes */
447 }else{
448 ensure_empty_dirs_created();
449 if( g.argc<=3 ){
450 /* All files updated. Shift the current checkout to the target. */
451 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
452 checkout_set_all_exe(vid);
453 manifest_to_disk(tid);
@@ -455,10 +459,35 @@
459 }
460 if( !internalUpdate ) undo_finish();
461 db_end_transaction(0);
462 }
463 }
464
465 /*
466 ** Make sure empty directories are created
467 */
468 void ensure_empty_dirs_created()
469 {
470 /* Make empty directories? */
471 char *zEmptyDirs = db_get_versionable_setting("empty-dirs", 0);
472 if( zEmptyDirs!=0 ){
473 Blob dirsList, line;
474 blob_zero(&dirsList);
475 blob_init(&dirsList, zEmptyDirs, strlen(zEmptyDirs));
476 while( blob_line(&dirsList, &line) ){
477 if( blob_buffer(&line)[0]=='#' ) continue;
478 Blob dirName;
479 int l = blob_token(&line, &dirName);
480 if(l > 0) {
481 /* Try and create the directory */
482 if( file_mkdir(blob_str(&dirName), 0)!=0 ) {
483 fossil_warning("couldn't create empty-dir %s", blob_str(&dirName));
484 }
485 }
486 }
487 }
488 }
489
490
491 /*
492 ** Get the contents of a file within the checking "revision". If
493 ** revision==NULL then get the file content for the current checkout.
494

Keyboard Shortcuts

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