Fossil SCM
Add '--metadata-only' option to the 'mv' and 'rm' commands.
Commit
65d5f2756add237613096a82dc07e28821e2d316
Parent
ae5c35ef4127e7d…
1 file changed
+30
-4
+30
-4
| --- src/add.c | ||
| +++ src/add.c | ||
| @@ -394,10 +394,20 @@ | ||
| 394 | 394 | fossil_print("DELETED_FILE %s\n", zOldName); |
| 395 | 395 | } |
| 396 | 396 | db_finalize(&remove); |
| 397 | 397 | db_multi_exec("DROP TABLE fremove;"); |
| 398 | 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 | +} | |
| 399 | 409 | |
| 400 | 410 | /* |
| 401 | 411 | ** COMMAND: rm |
| 402 | 412 | ** COMMAND: delete* |
| 403 | 413 | ** |
| @@ -409,10 +419,12 @@ | ||
| 409 | 419 | ** This command does NOT remove the files from disk. It just marks the |
| 410 | 420 | ** files as no longer being part of the project. In other words, future |
| 411 | 421 | ** changes to the named files will not be versioned. |
| 412 | 422 | ** |
| 413 | 423 | ** Options: |
| 424 | +** --metadata-only <BOOL> Non-zero to skip removing files from the | |
| 425 | +** checkout. | |
| 414 | 426 | ** --case-sensitive <BOOL> Override the case-sensitive setting. |
| 415 | 427 | ** -n|--dry-run If given, display instead of run actions. |
| 416 | 428 | ** |
| 417 | 429 | ** See also: addremove, add |
| 418 | 430 | */ |
| @@ -421,21 +433,27 @@ | ||
| 421 | 433 | int removeFiles; |
| 422 | 434 | int dryRunFlag; |
| 423 | 435 | Stmt loop; |
| 424 | 436 | |
| 425 | 437 | dryRunFlag = find_option("dry-run","n",0)!=0; |
| 438 | + | |
| 439 | + capture_metadata_only_option(); | |
| 426 | 440 | |
| 427 | 441 | /* We should be done with options.. */ |
| 428 | 442 | verify_all_options(); |
| 429 | 443 | |
| 430 | 444 | db_must_be_within_tree(); |
| 431 | 445 | db_begin_transaction(); |
| 446 | + if( zMetadataOnly ){ | |
| 447 | + removeFiles = is_false(zMetadataOnly); | |
| 448 | + }else{ | |
| 432 | 449 | #if FOSSIL_ENABLE_LEGACY_MV_RM |
| 433 | - removeFiles = db_get_boolean("remove-files",0); | |
| 450 | + removeFiles = db_get_boolean("remove-files",0); | |
| 434 | 451 | #else |
| 435 | - removeFiles = FOSSIL_RM_CHECKOUT_FILE_ON_RM; | |
| 452 | + removeFiles = FOSSIL_RM_CHECKOUT_FILE_ON_RM; | |
| 436 | 453 | #endif |
| 454 | + } | |
| 437 | 455 | if( removeFiles ) init_files_to_remove(); |
| 438 | 456 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)", |
| 439 | 457 | filename_collation()); |
| 440 | 458 | for(i=2; i<g.argc; i++){ |
| 441 | 459 | Blob treeName; |
| @@ -749,10 +767,12 @@ | ||
| 749 | 767 | ** This command does NOT rename or move the files on disk. This command merely |
| 750 | 768 | ** records the fact that filenames have changed so that appropriate notations |
| 751 | 769 | ** can be made at the next commit/check-in. |
| 752 | 770 | ** |
| 753 | 771 | ** Options: |
| 772 | +** --metadata-only <BOOL> Non-zero to skip moving files within the | |
| 773 | +** checkout. | |
| 754 | 774 | ** --case-sensitive <BOOL> Override the case-sensitive setting. |
| 755 | 775 | ** -n|--dry-run If given, display instead of run actions. |
| 756 | 776 | ** |
| 757 | 777 | ** See also: changes, status |
| 758 | 778 | */ |
| @@ -765,10 +785,12 @@ | ||
| 765 | 785 | Blob dest; |
| 766 | 786 | Stmt q; |
| 767 | 787 | |
| 768 | 788 | db_must_be_within_tree(); |
| 769 | 789 | dryRunFlag = find_option("dry-run","n",0)!=0; |
| 790 | + | |
| 791 | + capture_metadata_only_option(); | |
| 770 | 792 | |
| 771 | 793 | /* We should be done with options.. */ |
| 772 | 794 | verify_all_options(); |
| 773 | 795 | |
| 774 | 796 | vid = db_lget_int("checkout", 0); |
| @@ -778,15 +800,19 @@ | ||
| 778 | 800 | if( g.argc<4 ){ |
| 779 | 801 | usage("OLDNAME NEWNAME"); |
| 780 | 802 | } |
| 781 | 803 | zDest = g.argv[g.argc-1]; |
| 782 | 804 | db_begin_transaction(); |
| 805 | + if( zMetadataOnly ){ | |
| 806 | + moveFiles = is_false(zMetadataOnly); | |
| 807 | + }else{ | |
| 783 | 808 | #if FOSSIL_ENABLE_LEGACY_MV_RM |
| 784 | - moveFiles = db_get_boolean("move-files",0); | |
| 809 | + moveFiles = db_get_boolean("move-files",0); | |
| 785 | 810 | #else |
| 786 | - moveFiles = FOSSIL_MV_CHECKOUT_FILE_ON_MV; | |
| 811 | + moveFiles = FOSSIL_MV_CHECKOUT_FILE_ON_MV; | |
| 787 | 812 | #endif |
| 813 | + } | |
| 788 | 814 | if( moveFiles ) init_files_to_move(); |
| 789 | 815 | file_tree_name(zDest, &dest, 1); |
| 790 | 816 | db_multi_exec( |
| 791 | 817 | "UPDATE vfile SET origname=pathname WHERE origname IS NULL;" |
| 792 | 818 | ); |
| 793 | 819 |
| --- 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 |