Fossil SCM

Add '--metadata-only' option to the 'mv' and 'rm' commands.

mistachkin 2015-03-04 01:27 mvAndRmFiles
Commit 65d5f2756add237613096a82dc07e28821e2d316
1 file changed +30 -4
+30 -4
--- src/add.c
+++ src/add.c
@@ -394,10 +394,20 @@
394394
fossil_print("DELETED_FILE %s\n", zOldName);
395395
}
396396
db_finalize(&remove);
397397
db_multi_exec("DROP TABLE fremove;");
398398
}
399
+
400
+/*
401
+** Capture the command-line --metadata-only option.
402
+*/
403
+static const char *zMetadataOnly = 0;
404
+void capture_metadata_only_option(void){
405
+ if( zMetadataOnly==0 ){
406
+ zMetadataOnly = find_option("metadata-only",0,1);
407
+ }
408
+}
399409
400410
/*
401411
** COMMAND: rm
402412
** COMMAND: delete*
403413
**
@@ -409,10 +419,12 @@
409419
** This command does NOT remove the files from disk. It just marks the
410420
** files as no longer being part of the project. In other words, future
411421
** changes to the named files will not be versioned.
412422
**
413423
** Options:
424
+** --metadata-only <BOOL> Non-zero to skip removing files from the
425
+** checkout.
414426
** --case-sensitive <BOOL> Override the case-sensitive setting.
415427
** -n|--dry-run If given, display instead of run actions.
416428
**
417429
** See also: addremove, add
418430
*/
@@ -421,21 +433,27 @@
421433
int removeFiles;
422434
int dryRunFlag;
423435
Stmt loop;
424436
425437
dryRunFlag = find_option("dry-run","n",0)!=0;
438
+
439
+ capture_metadata_only_option();
426440
427441
/* We should be done with options.. */
428442
verify_all_options();
429443
430444
db_must_be_within_tree();
431445
db_begin_transaction();
446
+ if( zMetadataOnly ){
447
+ removeFiles = is_false(zMetadataOnly);
448
+ }else{
432449
#if FOSSIL_ENABLE_LEGACY_MV_RM
433
- removeFiles = db_get_boolean("remove-files",0);
450
+ removeFiles = db_get_boolean("remove-files",0);
434451
#else
435
- removeFiles = FOSSIL_RM_CHECKOUT_FILE_ON_RM;
452
+ removeFiles = FOSSIL_RM_CHECKOUT_FILE_ON_RM;
436453
#endif
454
+ }
437455
if( removeFiles ) init_files_to_remove();
438456
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
439457
filename_collation());
440458
for(i=2; i<g.argc; i++){
441459
Blob treeName;
@@ -749,10 +767,12 @@
749767
** This command does NOT rename or move the files on disk. This command merely
750768
** records the fact that filenames have changed so that appropriate notations
751769
** can be made at the next commit/check-in.
752770
**
753771
** Options:
772
+** --metadata-only <BOOL> Non-zero to skip moving files within the
773
+** checkout.
754774
** --case-sensitive <BOOL> Override the case-sensitive setting.
755775
** -n|--dry-run If given, display instead of run actions.
756776
**
757777
** See also: changes, status
758778
*/
@@ -765,10 +785,12 @@
765785
Blob dest;
766786
Stmt q;
767787
768788
db_must_be_within_tree();
769789
dryRunFlag = find_option("dry-run","n",0)!=0;
790
+
791
+ capture_metadata_only_option();
770792
771793
/* We should be done with options.. */
772794
verify_all_options();
773795
774796
vid = db_lget_int("checkout", 0);
@@ -778,15 +800,19 @@
778800
if( g.argc<4 ){
779801
usage("OLDNAME NEWNAME");
780802
}
781803
zDest = g.argv[g.argc-1];
782804
db_begin_transaction();
805
+ if( zMetadataOnly ){
806
+ moveFiles = is_false(zMetadataOnly);
807
+ }else{
783808
#if FOSSIL_ENABLE_LEGACY_MV_RM
784
- moveFiles = db_get_boolean("move-files",0);
809
+ moveFiles = db_get_boolean("move-files",0);
785810
#else
786
- moveFiles = FOSSIL_MV_CHECKOUT_FILE_ON_MV;
811
+ moveFiles = FOSSIL_MV_CHECKOUT_FILE_ON_MV;
787812
#endif
813
+ }
788814
if( moveFiles ) init_files_to_move();
789815
file_tree_name(zDest, &dest, 1);
790816
db_multi_exec(
791817
"UPDATE vfile SET origname=pathname WHERE origname IS NULL;"
792818
);
793819
--- src/add.c
+++ src/add.c
@@ -394,10 +394,20 @@
394 fossil_print("DELETED_FILE %s\n", zOldName);
395 }
396 db_finalize(&remove);
397 db_multi_exec("DROP TABLE fremove;");
398 }
 
 
 
 
 
 
 
 
 
 
399
400 /*
401 ** COMMAND: rm
402 ** COMMAND: delete*
403 **
@@ -409,10 +419,12 @@
409 ** This command does NOT remove the files from disk. It just marks the
410 ** files as no longer being part of the project. In other words, future
411 ** changes to the named files will not be versioned.
412 **
413 ** Options:
 
 
414 ** --case-sensitive <BOOL> Override the case-sensitive setting.
415 ** -n|--dry-run If given, display instead of run actions.
416 **
417 ** See also: addremove, add
418 */
@@ -421,21 +433,27 @@
421 int removeFiles;
422 int dryRunFlag;
423 Stmt loop;
424
425 dryRunFlag = find_option("dry-run","n",0)!=0;
 
 
426
427 /* We should be done with options.. */
428 verify_all_options();
429
430 db_must_be_within_tree();
431 db_begin_transaction();
 
 
 
432 #if FOSSIL_ENABLE_LEGACY_MV_RM
433 removeFiles = db_get_boolean("remove-files",0);
434 #else
435 removeFiles = FOSSIL_RM_CHECKOUT_FILE_ON_RM;
436 #endif
 
437 if( removeFiles ) init_files_to_remove();
438 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
439 filename_collation());
440 for(i=2; i<g.argc; i++){
441 Blob treeName;
@@ -749,10 +767,12 @@
749 ** This command does NOT rename or move the files on disk. This command merely
750 ** records the fact that filenames have changed so that appropriate notations
751 ** can be made at the next commit/check-in.
752 **
753 ** Options:
 
 
754 ** --case-sensitive <BOOL> Override the case-sensitive setting.
755 ** -n|--dry-run If given, display instead of run actions.
756 **
757 ** See also: changes, status
758 */
@@ -765,10 +785,12 @@
765 Blob dest;
766 Stmt q;
767
768 db_must_be_within_tree();
769 dryRunFlag = find_option("dry-run","n",0)!=0;
 
 
770
771 /* We should be done with options.. */
772 verify_all_options();
773
774 vid = db_lget_int("checkout", 0);
@@ -778,15 +800,19 @@
778 if( g.argc<4 ){
779 usage("OLDNAME NEWNAME");
780 }
781 zDest = g.argv[g.argc-1];
782 db_begin_transaction();
 
 
 
783 #if FOSSIL_ENABLE_LEGACY_MV_RM
784 moveFiles = db_get_boolean("move-files",0);
785 #else
786 moveFiles = FOSSIL_MV_CHECKOUT_FILE_ON_MV;
787 #endif
 
788 if( moveFiles ) init_files_to_move();
789 file_tree_name(zDest, &dest, 1);
790 db_multi_exec(
791 "UPDATE vfile SET origname=pathname WHERE origname IS NULL;"
792 );
793
--- src/add.c
+++ src/add.c
@@ -394,10 +394,20 @@
394 fossil_print("DELETED_FILE %s\n", zOldName);
395 }
396 db_finalize(&remove);
397 db_multi_exec("DROP TABLE fremove;");
398 }
399
400 /*
401 ** Capture the command-line --metadata-only option.
402 */
403 static const char *zMetadataOnly = 0;
404 void capture_metadata_only_option(void){
405 if( zMetadataOnly==0 ){
406 zMetadataOnly = find_option("metadata-only",0,1);
407 }
408 }
409
410 /*
411 ** COMMAND: rm
412 ** COMMAND: delete*
413 **
@@ -409,10 +419,12 @@
419 ** This command does NOT remove the files from disk. It just marks the
420 ** files as no longer being part of the project. In other words, future
421 ** changes to the named files will not be versioned.
422 **
423 ** Options:
424 ** --metadata-only <BOOL> Non-zero to skip removing files from the
425 ** checkout.
426 ** --case-sensitive <BOOL> Override the case-sensitive setting.
427 ** -n|--dry-run If given, display instead of run actions.
428 **
429 ** See also: addremove, add
430 */
@@ -421,21 +433,27 @@
433 int removeFiles;
434 int dryRunFlag;
435 Stmt loop;
436
437 dryRunFlag = find_option("dry-run","n",0)!=0;
438
439 capture_metadata_only_option();
440
441 /* We should be done with options.. */
442 verify_all_options();
443
444 db_must_be_within_tree();
445 db_begin_transaction();
446 if( zMetadataOnly ){
447 removeFiles = is_false(zMetadataOnly);
448 }else{
449 #if FOSSIL_ENABLE_LEGACY_MV_RM
450 removeFiles = db_get_boolean("remove-files",0);
451 #else
452 removeFiles = FOSSIL_RM_CHECKOUT_FILE_ON_RM;
453 #endif
454 }
455 if( removeFiles ) init_files_to_remove();
456 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
457 filename_collation());
458 for(i=2; i<g.argc; i++){
459 Blob treeName;
@@ -749,10 +767,12 @@
767 ** This command does NOT rename or move the files on disk. This command merely
768 ** records the fact that filenames have changed so that appropriate notations
769 ** can be made at the next commit/check-in.
770 **
771 ** Options:
772 ** --metadata-only <BOOL> Non-zero to skip moving files within the
773 ** checkout.
774 ** --case-sensitive <BOOL> Override the case-sensitive setting.
775 ** -n|--dry-run If given, display instead of run actions.
776 **
777 ** See also: changes, status
778 */
@@ -765,10 +785,12 @@
785 Blob dest;
786 Stmt q;
787
788 db_must_be_within_tree();
789 dryRunFlag = find_option("dry-run","n",0)!=0;
790
791 capture_metadata_only_option();
792
793 /* We should be done with options.. */
794 verify_all_options();
795
796 vid = db_lget_int("checkout", 0);
@@ -778,15 +800,19 @@
800 if( g.argc<4 ){
801 usage("OLDNAME NEWNAME");
802 }
803 zDest = g.argv[g.argc-1];
804 db_begin_transaction();
805 if( zMetadataOnly ){
806 moveFiles = is_false(zMetadataOnly);
807 }else{
808 #if FOSSIL_ENABLE_LEGACY_MV_RM
809 moveFiles = db_get_boolean("move-files",0);
810 #else
811 moveFiles = FOSSIL_MV_CHECKOUT_FILE_ON_MV;
812 #endif
813 }
814 if( moveFiles ) init_files_to_move();
815 file_tree_name(zDest, &dest, 1);
816 db_multi_exec(
817 "UPDATE vfile SET origname=pathname WHERE origname IS NULL;"
818 );
819

Keyboard Shortcuts

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