Fossil SCM
Add the -i or --prompt option to the "fossil clean" command.
Commit
1c9da04a39c9b06f4efcee7264b309d90ced678e
Parent
4c8b1e819c1429c…
1 file changed
+28
-9
+28
-9
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -674,10 +674,11 @@ | ||
| 674 | 674 | ** argument. Matching files, if any, are removed |
| 675 | 675 | ** prior to checking for any empty directories; |
| 676 | 676 | ** therefore, directories that contain only files |
| 677 | 677 | ** that were removed will be removed as well. |
| 678 | 678 | ** -f|--force Remove files without prompting. |
| 679 | +** -i|--prompt Prompt before removing each file. | |
| 679 | 680 | ** -x|--verily WARNING: Removes everything that is not a managed |
| 680 | 681 | ** file or the repository itself. This option |
| 681 | 682 | ** implies the --force, --emptydirs, --dotfiles, and |
| 682 | 683 | ** --disable-undo options. Furthermore, it completely |
| 683 | 684 | ** disregards the keep-glob and ignore-glob settings. |
| @@ -702,10 +703,11 @@ | ||
| 702 | 703 | */ |
| 703 | 704 | void clean_cmd(void){ |
| 704 | 705 | int allFileFlag, allDirFlag, dryRunFlag, verboseFlag; |
| 705 | 706 | int emptyDirsFlag, dirsOnlyFlag; |
| 706 | 707 | int disableUndo, noPrompt; |
| 708 | + int alwaysPrompt = 0; | |
| 707 | 709 | unsigned scanFlags = 0; |
| 708 | 710 | int verilyFlag = 0; |
| 709 | 711 | const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag; |
| 710 | 712 | Glob *pIgnore, *pKeep, *pClean; |
| 711 | 713 | int nRoot; |
| @@ -722,10 +724,11 @@ | ||
| 722 | 724 | if( !dryRunFlag ){ |
| 723 | 725 | dryRunFlag = find_option("whatif",0,0)!=0; |
| 724 | 726 | } |
| 725 | 727 | disableUndo = find_option("disable-undo",0,0)!=0; |
| 726 | 728 | noPrompt = find_option("no-prompt",0,0)!=0; |
| 729 | + alwaysPrompt = find_option("prompt","i",0)!=0; | |
| 727 | 730 | allFileFlag = allDirFlag = find_option("force","f",0)!=0; |
| 728 | 731 | dirsOnlyFlag = find_option("dirsonly",0,0)!=0; |
| 729 | 732 | emptyDirsFlag = find_option("emptydirs","d",0)!=0 || dirsOnlyFlag; |
| 730 | 733 | if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL; |
| 731 | 734 | if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP; |
| @@ -781,28 +784,44 @@ | ||
| 781 | 784 | " or \"keep-glob\")\n", zName+nRoot); |
| 782 | 785 | } |
| 783 | 786 | continue; |
| 784 | 787 | } |
| 785 | 788 | if( !dryRunFlag && !glob_match(pClean, zName+nRoot) ){ |
| 789 | + char *zPrompt = 0; | |
| 790 | + char cReply; | |
| 791 | + Blob ans = empty_blob; | |
| 786 | 792 | int undoRc = UNDO_NONE; |
| 787 | - if( !disableUndo ){ | |
| 793 | + if( alwaysPrompt ){ | |
| 794 | + zPrompt = mprintf("Remove unmanaged file \"%s\" (a=all/y/N)? ", | |
| 795 | + zName+nRoot); | |
| 796 | + prompt_user(zPrompt, &ans); | |
| 797 | + fossil_free(zPrompt); | |
| 798 | + cReply = fossil_toupper(blob_str(&ans)[0]); | |
| 799 | + blob_reset(&ans); | |
| 800 | + if( cReply=='N' ) continue; | |
| 801 | + if( cReply=='A' ){ | |
| 802 | + allFileFlag = 1; | |
| 803 | + alwaysPrompt = 0; | |
| 804 | + }else{ | |
| 805 | + undoRc = UNDO_SAVED_OK; | |
| 806 | + } | |
| 807 | + }else if( !disableUndo ){ | |
| 788 | 808 | undoRc = undo_maybe_save(zName+nRoot, UNDO_SIZE_LIMIT); |
| 789 | 809 | } |
| 790 | 810 | if( undoRc!=UNDO_SAVED_OK ){ |
| 791 | - char cReply; | |
| 792 | 811 | if( allFileFlag ){ |
| 793 | 812 | cReply = 'Y'; |
| 794 | 813 | }else if( !noPrompt ){ |
| 795 | 814 | Blob ans; |
| 796 | - char *prompt = mprintf("\nWARNING: Deletion of this file will " | |
| 797 | - "not be undoable via the 'undo'\n" | |
| 798 | - " command because %s.\n\n" | |
| 799 | - "Remove unmanaged file \"%s\" (a=all/y/N)? ", | |
| 800 | - undo_save_message(undoRc), zName+nRoot); | |
| 801 | - prompt_user(prompt, &ans); | |
| 815 | + zPrompt = mprintf("\nWARNING: Deletion of this file will " | |
| 816 | + "not be undoable via the 'undo'\n" | |
| 817 | + " command because %s.\n\n" | |
| 818 | + "Remove unmanaged file \"%s\" (a=all/y/N)? ", | |
| 819 | + undo_save_message(undoRc), zName+nRoot); | |
| 820 | + prompt_user(zPrompt, &ans); | |
| 821 | + fossil_free(zPrompt); | |
| 802 | 822 | cReply = blob_str(&ans)[0]; |
| 803 | - fossil_free(prompt); | |
| 804 | 823 | blob_reset(&ans); |
| 805 | 824 | }else{ |
| 806 | 825 | cReply = 'N'; |
| 807 | 826 | } |
| 808 | 827 | if( cReply=='a' || cReply=='A' ){ |
| 809 | 828 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -674,10 +674,11 @@ | |
| 674 | ** argument. Matching files, if any, are removed |
| 675 | ** prior to checking for any empty directories; |
| 676 | ** therefore, directories that contain only files |
| 677 | ** that were removed will be removed as well. |
| 678 | ** -f|--force Remove files without prompting. |
| 679 | ** -x|--verily WARNING: Removes everything that is not a managed |
| 680 | ** file or the repository itself. This option |
| 681 | ** implies the --force, --emptydirs, --dotfiles, and |
| 682 | ** --disable-undo options. Furthermore, it completely |
| 683 | ** disregards the keep-glob and ignore-glob settings. |
| @@ -702,10 +703,11 @@ | |
| 702 | */ |
| 703 | void clean_cmd(void){ |
| 704 | int allFileFlag, allDirFlag, dryRunFlag, verboseFlag; |
| 705 | int emptyDirsFlag, dirsOnlyFlag; |
| 706 | int disableUndo, noPrompt; |
| 707 | unsigned scanFlags = 0; |
| 708 | int verilyFlag = 0; |
| 709 | const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag; |
| 710 | Glob *pIgnore, *pKeep, *pClean; |
| 711 | int nRoot; |
| @@ -722,10 +724,11 @@ | |
| 722 | if( !dryRunFlag ){ |
| 723 | dryRunFlag = find_option("whatif",0,0)!=0; |
| 724 | } |
| 725 | disableUndo = find_option("disable-undo",0,0)!=0; |
| 726 | noPrompt = find_option("no-prompt",0,0)!=0; |
| 727 | allFileFlag = allDirFlag = find_option("force","f",0)!=0; |
| 728 | dirsOnlyFlag = find_option("dirsonly",0,0)!=0; |
| 729 | emptyDirsFlag = find_option("emptydirs","d",0)!=0 || dirsOnlyFlag; |
| 730 | if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL; |
| 731 | if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP; |
| @@ -781,28 +784,44 @@ | |
| 781 | " or \"keep-glob\")\n", zName+nRoot); |
| 782 | } |
| 783 | continue; |
| 784 | } |
| 785 | if( !dryRunFlag && !glob_match(pClean, zName+nRoot) ){ |
| 786 | int undoRc = UNDO_NONE; |
| 787 | if( !disableUndo ){ |
| 788 | undoRc = undo_maybe_save(zName+nRoot, UNDO_SIZE_LIMIT); |
| 789 | } |
| 790 | if( undoRc!=UNDO_SAVED_OK ){ |
| 791 | char cReply; |
| 792 | if( allFileFlag ){ |
| 793 | cReply = 'Y'; |
| 794 | }else if( !noPrompt ){ |
| 795 | Blob ans; |
| 796 | char *prompt = mprintf("\nWARNING: Deletion of this file will " |
| 797 | "not be undoable via the 'undo'\n" |
| 798 | " command because %s.\n\n" |
| 799 | "Remove unmanaged file \"%s\" (a=all/y/N)? ", |
| 800 | undo_save_message(undoRc), zName+nRoot); |
| 801 | prompt_user(prompt, &ans); |
| 802 | cReply = blob_str(&ans)[0]; |
| 803 | fossil_free(prompt); |
| 804 | blob_reset(&ans); |
| 805 | }else{ |
| 806 | cReply = 'N'; |
| 807 | } |
| 808 | if( cReply=='a' || cReply=='A' ){ |
| 809 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -674,10 +674,11 @@ | |
| 674 | ** argument. Matching files, if any, are removed |
| 675 | ** prior to checking for any empty directories; |
| 676 | ** therefore, directories that contain only files |
| 677 | ** that were removed will be removed as well. |
| 678 | ** -f|--force Remove files without prompting. |
| 679 | ** -i|--prompt Prompt before removing each file. |
| 680 | ** -x|--verily WARNING: Removes everything that is not a managed |
| 681 | ** file or the repository itself. This option |
| 682 | ** implies the --force, --emptydirs, --dotfiles, and |
| 683 | ** --disable-undo options. Furthermore, it completely |
| 684 | ** disregards the keep-glob and ignore-glob settings. |
| @@ -702,10 +703,11 @@ | |
| 703 | */ |
| 704 | void clean_cmd(void){ |
| 705 | int allFileFlag, allDirFlag, dryRunFlag, verboseFlag; |
| 706 | int emptyDirsFlag, dirsOnlyFlag; |
| 707 | int disableUndo, noPrompt; |
| 708 | int alwaysPrompt = 0; |
| 709 | unsigned scanFlags = 0; |
| 710 | int verilyFlag = 0; |
| 711 | const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag; |
| 712 | Glob *pIgnore, *pKeep, *pClean; |
| 713 | int nRoot; |
| @@ -722,10 +724,11 @@ | |
| 724 | if( !dryRunFlag ){ |
| 725 | dryRunFlag = find_option("whatif",0,0)!=0; |
| 726 | } |
| 727 | disableUndo = find_option("disable-undo",0,0)!=0; |
| 728 | noPrompt = find_option("no-prompt",0,0)!=0; |
| 729 | alwaysPrompt = find_option("prompt","i",0)!=0; |
| 730 | allFileFlag = allDirFlag = find_option("force","f",0)!=0; |
| 731 | dirsOnlyFlag = find_option("dirsonly",0,0)!=0; |
| 732 | emptyDirsFlag = find_option("emptydirs","d",0)!=0 || dirsOnlyFlag; |
| 733 | if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL; |
| 734 | if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP; |
| @@ -781,28 +784,44 @@ | |
| 784 | " or \"keep-glob\")\n", zName+nRoot); |
| 785 | } |
| 786 | continue; |
| 787 | } |
| 788 | if( !dryRunFlag && !glob_match(pClean, zName+nRoot) ){ |
| 789 | char *zPrompt = 0; |
| 790 | char cReply; |
| 791 | Blob ans = empty_blob; |
| 792 | int undoRc = UNDO_NONE; |
| 793 | if( alwaysPrompt ){ |
| 794 | zPrompt = mprintf("Remove unmanaged file \"%s\" (a=all/y/N)? ", |
| 795 | zName+nRoot); |
| 796 | prompt_user(zPrompt, &ans); |
| 797 | fossil_free(zPrompt); |
| 798 | cReply = fossil_toupper(blob_str(&ans)[0]); |
| 799 | blob_reset(&ans); |
| 800 | if( cReply=='N' ) continue; |
| 801 | if( cReply=='A' ){ |
| 802 | allFileFlag = 1; |
| 803 | alwaysPrompt = 0; |
| 804 | }else{ |
| 805 | undoRc = UNDO_SAVED_OK; |
| 806 | } |
| 807 | }else if( !disableUndo ){ |
| 808 | undoRc = undo_maybe_save(zName+nRoot, UNDO_SIZE_LIMIT); |
| 809 | } |
| 810 | if( undoRc!=UNDO_SAVED_OK ){ |
| 811 | if( allFileFlag ){ |
| 812 | cReply = 'Y'; |
| 813 | }else if( !noPrompt ){ |
| 814 | Blob ans; |
| 815 | zPrompt = mprintf("\nWARNING: Deletion of this file will " |
| 816 | "not be undoable via the 'undo'\n" |
| 817 | " command because %s.\n\n" |
| 818 | "Remove unmanaged file \"%s\" (a=all/y/N)? ", |
| 819 | undo_save_message(undoRc), zName+nRoot); |
| 820 | prompt_user(zPrompt, &ans); |
| 821 | fossil_free(zPrompt); |
| 822 | cReply = blob_str(&ans)[0]; |
| 823 | blob_reset(&ans); |
| 824 | }else{ |
| 825 | cReply = 'N'; |
| 826 | } |
| 827 | if( cReply=='a' || cReply=='A' ){ |
| 828 |