Fossil SCM

Add (verisionable) empty-dirs setting

ben 2011-05-21 16:52 UTC bens-expr
Commit b21f47e96728496b1fdf631731b4fa5619236ec1
--- 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 ){
@@ -435,10 +438,11 @@
435438
** Clean up the mid and pid VFILE entries. Then commit the changes.
436439
*/
437440
if( nochangeFlag ){
438441
db_end_transaction(1); /* With --nochange, rollback changes */
439442
}else{
443
+ ensure_empty_dirs_created();
440444
if( g.argc<=3 ){
441445
/* All files updated. Shift the current checkout to the target. */
442446
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
443447
checkout_set_all_exe(vid);
444448
manifest_to_disk(tid);
@@ -450,10 +454,35 @@
450454
}
451455
if( !internalUpdate ) undo_finish();
452456
db_end_transaction(0);
453457
}
454458
}
459
+
460
+/*
461
+** Make sure empty directories are created
462
+*/
463
+void ensure_empty_dirs_created()
464
+{
465
+ /* Make empty directories? */
466
+ char *zEmptyDirs = db_get_versionable_setting("empty-dirs", 0);
467
+ if( zEmptyDirs!=0 ){
468
+ Blob dirsList, line;
469
+ blob_zero(&dirsList);
470
+ blob_init(&dirsList, zEmptyDirs, strlen(zEmptyDirs));
471
+ while( blob_line(&dirsList, &line) ){
472
+ if( blob_buffer(&line)[0]=='#' ) continue;
473
+ Blob dirName;
474
+ int l = blob_token(&line, &dirName);
475
+ if(l > 0) {
476
+ /* Try and create the directory */
477
+ if( file_mkdir(blob_str(&dirName), 0)!=0 ) {
478
+ fossil_warning("couldn't create empty-dir %s", blob_str(&dirName));
479
+ }
480
+ }
481
+ }
482
+ }
483
+}
455484
456485
457486
/*
458487
** Get the contents of a file within the checking "revision". If
459488
** revision==NULL then get the file content for the current checkout.
460489
--- 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 ){
@@ -435,10 +438,11 @@
435 ** Clean up the mid and pid VFILE entries. Then commit the changes.
436 */
437 if( nochangeFlag ){
438 db_end_transaction(1); /* With --nochange, rollback changes */
439 }else{
 
440 if( g.argc<=3 ){
441 /* All files updated. Shift the current checkout to the target. */
442 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
443 checkout_set_all_exe(vid);
444 manifest_to_disk(tid);
@@ -450,10 +454,35 @@
450 }
451 if( !internalUpdate ) undo_finish();
452 db_end_transaction(0);
453 }
454 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
455
456
457 /*
458 ** Get the contents of a file within the checking "revision". If
459 ** revision==NULL then get the file content for the current checkout.
460
--- 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 ){
@@ -435,10 +438,11 @@
438 ** Clean up the mid and pid VFILE entries. Then commit the changes.
439 */
440 if( nochangeFlag ){
441 db_end_transaction(1); /* With --nochange, rollback changes */
442 }else{
443 ensure_empty_dirs_created();
444 if( g.argc<=3 ){
445 /* All files updated. Shift the current checkout to the target. */
446 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
447 checkout_set_all_exe(vid);
448 manifest_to_disk(tid);
@@ -450,10 +454,35 @@
454 }
455 if( !internalUpdate ) undo_finish();
456 db_end_transaction(0);
457 }
458 }
459
460 /*
461 ** Make sure empty directories are created
462 */
463 void ensure_empty_dirs_created()
464 {
465 /* Make empty directories? */
466 char *zEmptyDirs = db_get_versionable_setting("empty-dirs", 0);
467 if( zEmptyDirs!=0 ){
468 Blob dirsList, line;
469 blob_zero(&dirsList);
470 blob_init(&dirsList, zEmptyDirs, strlen(zEmptyDirs));
471 while( blob_line(&dirsList, &line) ){
472 if( blob_buffer(&line)[0]=='#' ) continue;
473 Blob dirName;
474 int l = blob_token(&line, &dirName);
475 if(l > 0) {
476 /* Try and create the directory */
477 if( file_mkdir(blob_str(&dirName), 0)!=0 ) {
478 fossil_warning("couldn't create empty-dir %s", blob_str(&dirName));
479 }
480 }
481 }
482 }
483 }
484
485
486 /*
487 ** Get the contents of a file within the checking "revision". If
488 ** revision==NULL then get the file content for the current checkout.
489

Keyboard Shortcuts

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