Fossil SCM
The "-f" flag on "fossil patch create" causes an existing patch with the same name to be overwritten.
Commit
a332f1a64fb890b37dc25c9decd083a12e57f3e6b18a49398f3240934a069e7e
Parent
5a28d7c094d41a8…
1 file changed
+17
-4
+17
-4
| --- src/patch.c | ||
| +++ src/patch.c | ||
| @@ -145,16 +145,21 @@ | ||
| 145 | 145 | |
| 146 | 146 | /* |
| 147 | 147 | ** Generate a binary patch file and store it into the file |
| 148 | 148 | ** named zOut. |
| 149 | 149 | */ |
| 150 | -void patch_create(const char *zOut, FILE *out){ | |
| 150 | +void patch_create(unsigned mFlags, const char *zOut, FILE *out){ | |
| 151 | 151 | int vid; |
| 152 | 152 | char *z; |
| 153 | 153 | |
| 154 | 154 | if( zOut && file_isdir(zOut, ExtFILE)!=0 ){ |
| 155 | - fossil_fatal("patch file already exists: %s", zOut); | |
| 155 | + if( mFlags & PATCH_FORCE ){ | |
| 156 | + file_delete(zOut); | |
| 157 | + } | |
| 158 | + if( file_isdir(zOut, ExtFILE)!=0 ){ | |
| 159 | + fossil_fatal("patch file already exists: %s", zOut); | |
| 160 | + } | |
| 156 | 161 | } |
| 157 | 162 | add_content_sql_commands(g.db); |
| 158 | 163 | deltafunc_init(g.db); |
| 159 | 164 | sqlite3_create_function(g.db, "read_co_file", 1, SQLITE_UTF8, 0, |
| 160 | 165 | readfileFunc, 0, 0); |
| @@ -775,10 +780,12 @@ | ||
| 775 | 780 | ** Create a new binary patch in FILENAME that captures all uncommitted |
| 776 | 781 | ** changes in the check-out at DIRECTORY, or the current directory if |
| 777 | 782 | ** DIRECTORY is omitted. If FILENAME is "-" then the binary patch |
| 778 | 783 | ** is written to standard output. |
| 779 | 784 | ** |
| 785 | +** -f|--force Overwrite an existing patch with the same name. | |
| 786 | +** | |
| 780 | 787 | ** > fossil patch apply [DIRECTORY] FILENAME |
| 781 | 788 | ** |
| 782 | 789 | ** Apply the changes in FILENAME to the check-out a DIRECTORY, or |
| 783 | 790 | ** in the current directory if DIRECTORY is omitted. Options: |
| 784 | 791 | ** |
| @@ -816,10 +823,13 @@ | ||
| 816 | 823 | ** -v|--verbose Extra output explaining what happens. |
| 817 | 824 | ** |
| 818 | 825 | ** > fossil patch view FILENAME |
| 819 | 826 | ** |
| 820 | 827 | ** View a summary of the the changes in the binary patch FILENAME. |
| 828 | +** Use "fossil patch diff" for detailed patch content. | |
| 829 | +** | |
| 830 | +** -v|--verbose Show extra detail about the patch. | |
| 821 | 831 | ** |
| 822 | 832 | */ |
| 823 | 833 | void patch_cmd(void){ |
| 824 | 834 | const char *zCmd; |
| 825 | 835 | size_t n; |
| @@ -841,13 +851,16 @@ | ||
| 841 | 851 | patch_apply(flags); |
| 842 | 852 | fossil_free(zIn); |
| 843 | 853 | }else |
| 844 | 854 | if( strncmp(zCmd, "create", n)==0 ){ |
| 845 | 855 | char *zOut; |
| 856 | + unsigned flags = 0; | |
| 857 | + if( find_option("force","f",0) ) flags |= PATCH_FORCE; | |
| 846 | 858 | zOut = patch_find_patch_filename("create"); |
| 859 | + verify_all_options(); | |
| 847 | 860 | db_must_be_within_tree(); |
| 848 | - patch_create(zOut, stdout); | |
| 861 | + patch_create(flags, zOut, stdout); | |
| 849 | 862 | fossil_free(zOut); |
| 850 | 863 | }else |
| 851 | 864 | if( strncmp(zCmd, "diff", n)==0 ){ |
| 852 | 865 | const char *zDiffCmd = 0; |
| 853 | 866 | const char *zBinGlob = 0; |
| @@ -899,11 +912,11 @@ | ||
| 899 | 912 | if( find_option("force","f",0) ) flags |= PATCH_FORCE; |
| 900 | 913 | db_must_be_within_tree(); |
| 901 | 914 | verify_all_options(); |
| 902 | 915 | pOut = patch_remote_command(flags, "push", "apply", "w"); |
| 903 | 916 | if( pOut ){ |
| 904 | - patch_create(0, pOut); | |
| 917 | + patch_create(0, 0, pOut); | |
| 905 | 918 | pclose(pOut); |
| 906 | 919 | } |
| 907 | 920 | }else |
| 908 | 921 | if( strncmp(zCmd, "view", n)==0 ){ |
| 909 | 922 | const char *zIn; |
| 910 | 923 |
| --- src/patch.c | |
| +++ src/patch.c | |
| @@ -145,16 +145,21 @@ | |
| 145 | |
| 146 | /* |
| 147 | ** Generate a binary patch file and store it into the file |
| 148 | ** named zOut. |
| 149 | */ |
| 150 | void patch_create(const char *zOut, FILE *out){ |
| 151 | int vid; |
| 152 | char *z; |
| 153 | |
| 154 | if( zOut && file_isdir(zOut, ExtFILE)!=0 ){ |
| 155 | fossil_fatal("patch file already exists: %s", zOut); |
| 156 | } |
| 157 | add_content_sql_commands(g.db); |
| 158 | deltafunc_init(g.db); |
| 159 | sqlite3_create_function(g.db, "read_co_file", 1, SQLITE_UTF8, 0, |
| 160 | readfileFunc, 0, 0); |
| @@ -775,10 +780,12 @@ | |
| 775 | ** Create a new binary patch in FILENAME that captures all uncommitted |
| 776 | ** changes in the check-out at DIRECTORY, or the current directory if |
| 777 | ** DIRECTORY is omitted. If FILENAME is "-" then the binary patch |
| 778 | ** is written to standard output. |
| 779 | ** |
| 780 | ** > fossil patch apply [DIRECTORY] FILENAME |
| 781 | ** |
| 782 | ** Apply the changes in FILENAME to the check-out a DIRECTORY, or |
| 783 | ** in the current directory if DIRECTORY is omitted. Options: |
| 784 | ** |
| @@ -816,10 +823,13 @@ | |
| 816 | ** -v|--verbose Extra output explaining what happens. |
| 817 | ** |
| 818 | ** > fossil patch view FILENAME |
| 819 | ** |
| 820 | ** View a summary of the the changes in the binary patch FILENAME. |
| 821 | ** |
| 822 | */ |
| 823 | void patch_cmd(void){ |
| 824 | const char *zCmd; |
| 825 | size_t n; |
| @@ -841,13 +851,16 @@ | |
| 841 | patch_apply(flags); |
| 842 | fossil_free(zIn); |
| 843 | }else |
| 844 | if( strncmp(zCmd, "create", n)==0 ){ |
| 845 | char *zOut; |
| 846 | zOut = patch_find_patch_filename("create"); |
| 847 | db_must_be_within_tree(); |
| 848 | patch_create(zOut, stdout); |
| 849 | fossil_free(zOut); |
| 850 | }else |
| 851 | if( strncmp(zCmd, "diff", n)==0 ){ |
| 852 | const char *zDiffCmd = 0; |
| 853 | const char *zBinGlob = 0; |
| @@ -899,11 +912,11 @@ | |
| 899 | if( find_option("force","f",0) ) flags |= PATCH_FORCE; |
| 900 | db_must_be_within_tree(); |
| 901 | verify_all_options(); |
| 902 | pOut = patch_remote_command(flags, "push", "apply", "w"); |
| 903 | if( pOut ){ |
| 904 | patch_create(0, pOut); |
| 905 | pclose(pOut); |
| 906 | } |
| 907 | }else |
| 908 | if( strncmp(zCmd, "view", n)==0 ){ |
| 909 | const char *zIn; |
| 910 |
| --- src/patch.c | |
| +++ src/patch.c | |
| @@ -145,16 +145,21 @@ | |
| 145 | |
| 146 | /* |
| 147 | ** Generate a binary patch file and store it into the file |
| 148 | ** named zOut. |
| 149 | */ |
| 150 | void patch_create(unsigned mFlags, const char *zOut, FILE *out){ |
| 151 | int vid; |
| 152 | char *z; |
| 153 | |
| 154 | if( zOut && file_isdir(zOut, ExtFILE)!=0 ){ |
| 155 | if( mFlags & PATCH_FORCE ){ |
| 156 | file_delete(zOut); |
| 157 | } |
| 158 | if( file_isdir(zOut, ExtFILE)!=0 ){ |
| 159 | fossil_fatal("patch file already exists: %s", zOut); |
| 160 | } |
| 161 | } |
| 162 | add_content_sql_commands(g.db); |
| 163 | deltafunc_init(g.db); |
| 164 | sqlite3_create_function(g.db, "read_co_file", 1, SQLITE_UTF8, 0, |
| 165 | readfileFunc, 0, 0); |
| @@ -775,10 +780,12 @@ | |
| 780 | ** Create a new binary patch in FILENAME that captures all uncommitted |
| 781 | ** changes in the check-out at DIRECTORY, or the current directory if |
| 782 | ** DIRECTORY is omitted. If FILENAME is "-" then the binary patch |
| 783 | ** is written to standard output. |
| 784 | ** |
| 785 | ** -f|--force Overwrite an existing patch with the same name. |
| 786 | ** |
| 787 | ** > fossil patch apply [DIRECTORY] FILENAME |
| 788 | ** |
| 789 | ** Apply the changes in FILENAME to the check-out a DIRECTORY, or |
| 790 | ** in the current directory if DIRECTORY is omitted. Options: |
| 791 | ** |
| @@ -816,10 +823,13 @@ | |
| 823 | ** -v|--verbose Extra output explaining what happens. |
| 824 | ** |
| 825 | ** > fossil patch view FILENAME |
| 826 | ** |
| 827 | ** View a summary of the the changes in the binary patch FILENAME. |
| 828 | ** Use "fossil patch diff" for detailed patch content. |
| 829 | ** |
| 830 | ** -v|--verbose Show extra detail about the patch. |
| 831 | ** |
| 832 | */ |
| 833 | void patch_cmd(void){ |
| 834 | const char *zCmd; |
| 835 | size_t n; |
| @@ -841,13 +851,16 @@ | |
| 851 | patch_apply(flags); |
| 852 | fossil_free(zIn); |
| 853 | }else |
| 854 | if( strncmp(zCmd, "create", n)==0 ){ |
| 855 | char *zOut; |
| 856 | unsigned flags = 0; |
| 857 | if( find_option("force","f",0) ) flags |= PATCH_FORCE; |
| 858 | zOut = patch_find_patch_filename("create"); |
| 859 | verify_all_options(); |
| 860 | db_must_be_within_tree(); |
| 861 | patch_create(flags, zOut, stdout); |
| 862 | fossil_free(zOut); |
| 863 | }else |
| 864 | if( strncmp(zCmd, "diff", n)==0 ){ |
| 865 | const char *zDiffCmd = 0; |
| 866 | const char *zBinGlob = 0; |
| @@ -899,11 +912,11 @@ | |
| 912 | if( find_option("force","f",0) ) flags |= PATCH_FORCE; |
| 913 | db_must_be_within_tree(); |
| 914 | verify_all_options(); |
| 915 | pOut = patch_remote_command(flags, "push", "apply", "w"); |
| 916 | if( pOut ){ |
| 917 | patch_create(0, 0, pOut); |
| 918 | pclose(pOut); |
| 919 | } |
| 920 | }else |
| 921 | if( strncmp(zCmd, "view", n)==0 ){ |
| 922 | const char *zIn; |
| 923 |