Fossil SCM
Add the --fossilcmd option to the "patch push" and "patch pull" commands. Also improve the "patch" documentation slightly.
Commit
280e12a35685a8679451a1a76f072120450f17577a11ff547a87943f116ac30d
Parent
136d20040841301…
1 file changed
+22
-15
+22
-15
| --- src/patch.c | ||
| +++ src/patch.c | ||
| @@ -661,10 +661,11 @@ | ||
| 661 | 661 | */ |
| 662 | 662 | static FILE *patch_remote_command( |
| 663 | 663 | unsigned mFlags, /* flags */ |
| 664 | 664 | const char *zThisCmd, /* "push" or "pull" */ |
| 665 | 665 | const char *zRemoteCmd, /* "apply" or "create" */ |
| 666 | + const char *zFossilCmd, /* Name of "fossil" on remote system */ | |
| 666 | 667 | const char *zRW /* "w" or "r" */ |
| 667 | 668 | ){ |
| 668 | 669 | char *zRemote; |
| 669 | 670 | char *zDir; |
| 670 | 671 | Blob cmd; |
| @@ -692,12 +693,13 @@ | ||
| 692 | 693 | *(char*)(zDir-1) = 0; |
| 693 | 694 | transport_ssh_command(&cmd); |
| 694 | 695 | blob_appendf(&cmd, " -T"); |
| 695 | 696 | blob_append_escaped_arg(&cmd, zRemote, 0); |
| 696 | 697 | blob_init(&remote, 0, 0); |
| 697 | - blob_appendf(&remote, "fossil patch %s%s --dir64 %z -", | |
| 698 | - zRemoteCmd, zForce, encode64(zDir, -1)); | |
| 698 | + if( zFossilCmd==0 ) zFossilCmd = "fossil"; | |
| 699 | + blob_appendf(&remote, "%$ patch %s%s --dir64 %z -", | |
| 700 | + zFossilCmd, zRemoteCmd, zForce, encode64(zDir, -1)); | |
| 699 | 701 | blob_append_escaped_arg(&cmd, blob_str(&remote), 0); |
| 700 | 702 | blob_reset(&remote); |
| 701 | 703 | } |
| 702 | 704 | if( mFlags & PATCH_VERBOSE ){ |
| 703 | 705 | fossil_print("# %s\n", blob_str(&cmd)); |
| @@ -885,30 +887,32 @@ | ||
| 885 | 887 | ** |
| 886 | 888 | ** * DIRECTORY |
| 887 | 889 | ** * HOST:DIRECTORY |
| 888 | 890 | ** * USER@HOST:DIRECTORY |
| 889 | 891 | ** |
| 890 | -** This command will only work if "fossil" is on the default PATH | |
| 891 | -** of the remote machine. | |
| 892 | +** Command-line options: | |
| 893 | +** | |
| 894 | +** -f|--force Apply the patch even though there are unsaved | |
| 895 | +** changes in the current check-out. Unsaved | |
| 896 | +** changes will be reverted and then the patch is | |
| 897 | +** applied. | |
| 898 | +** --fossilcmd EXE Name of the "fossil" executable on the remote | |
| 899 | +** -n|--dryrun Do nothing, but print what would have happened. | |
| 900 | +** -v|--verbose Extra output explaining what happens. | |
| 901 | +** | |
| 892 | 902 | ** |
| 893 | 903 | ** > fossil patch pull REMOTE-CHECKOUT |
| 894 | 904 | ** |
| 895 | -** Create a patch on a remote check-out, transfer that patch to the | |
| 896 | -** local machine (using ssh) and apply the patch in the local checkout. | |
| 897 | -** | |
| 898 | -** -f|--force Apply the patch even though there are unsaved | |
| 899 | -** changes in the current check-out. Unsaved changes | |
| 900 | -** will be reverted and then the patch is applied. | |
| 901 | -** -n|--dryrun Do nothing, but print what would have happened. | |
| 902 | -** -v|--verbose Extra output explaining what happens. | |
| 905 | +** Like "fossil patch push" except that the transfer is from remote | |
| 906 | +** to local. All the same command-line options apply. | |
| 903 | 907 | ** |
| 904 | 908 | ** > fossil patch view FILENAME |
| 905 | 909 | ** |
| 906 | 910 | ** View a summary of the changes in the binary patch FILENAME. |
| 907 | 911 | ** Use "fossil patch diff" for detailed patch content. |
| 908 | 912 | ** |
| 909 | -** -v|--verbose Show extra detail about the patch. | |
| 913 | +** -v|--verbose Show extra detail about the patch. | |
| 910 | 914 | ** |
| 911 | 915 | */ |
| 912 | 916 | void patch_cmd(void){ |
| 913 | 917 | const char *zCmd; |
| 914 | 918 | size_t n; |
| @@ -971,31 +975,34 @@ | ||
| 971 | 975 | fossil_free(zIn); |
| 972 | 976 | }else |
| 973 | 977 | if( strncmp(zCmd, "pull", n)==0 ){ |
| 974 | 978 | FILE *pIn = 0; |
| 975 | 979 | unsigned flags = 0; |
| 980 | + const char *zFossilCmd = find_option("fossilcmd",0,1); | |
| 976 | 981 | if( find_option("dryrun","n",0) ) flags |= PATCH_DRYRUN; |
| 977 | 982 | if( find_option("verbose","v",0) ) flags |= PATCH_VERBOSE; |
| 978 | 983 | if( find_option("force","f",0) ) flags |= PATCH_FORCE; |
| 979 | 984 | db_must_be_within_tree(); |
| 980 | 985 | verify_all_options(); |
| 981 | - pIn = patch_remote_command(flags & (~PATCH_FORCE), "pull", "create", "r"); | |
| 986 | + pIn = patch_remote_command(flags & (~PATCH_FORCE), | |
| 987 | + "pull", "create", zFossilCmd, "r"); | |
| 982 | 988 | if( pIn ){ |
| 983 | 989 | patch_attach(0, pIn); |
| 984 | 990 | pclose(pIn); |
| 985 | 991 | patch_apply(flags); |
| 986 | 992 | } |
| 987 | 993 | }else |
| 988 | 994 | if( strncmp(zCmd, "push", n)==0 ){ |
| 989 | 995 | FILE *pOut = 0; |
| 990 | 996 | unsigned flags = 0; |
| 997 | + const char *zFossilCmd = find_option("fossilcmd",0,1); | |
| 991 | 998 | if( find_option("dryrun","n",0) ) flags |= PATCH_DRYRUN; |
| 992 | 999 | if( find_option("verbose","v",0) ) flags |= PATCH_VERBOSE; |
| 993 | 1000 | if( find_option("force","f",0) ) flags |= PATCH_FORCE; |
| 994 | 1001 | db_must_be_within_tree(); |
| 995 | 1002 | verify_all_options(); |
| 996 | - pOut = patch_remote_command(flags, "push", "apply", "w"); | |
| 1003 | + pOut = patch_remote_command(flags, "push", "apply", zFossilCmd, "w"); | |
| 997 | 1004 | if( pOut ){ |
| 998 | 1005 | patch_create(0, 0, pOut); |
| 999 | 1006 | pclose(pOut); |
| 1000 | 1007 | } |
| 1001 | 1008 | }else |
| 1002 | 1009 |
| --- src/patch.c | |
| +++ src/patch.c | |
| @@ -661,10 +661,11 @@ | |
| 661 | */ |
| 662 | static FILE *patch_remote_command( |
| 663 | unsigned mFlags, /* flags */ |
| 664 | const char *zThisCmd, /* "push" or "pull" */ |
| 665 | const char *zRemoteCmd, /* "apply" or "create" */ |
| 666 | const char *zRW /* "w" or "r" */ |
| 667 | ){ |
| 668 | char *zRemote; |
| 669 | char *zDir; |
| 670 | Blob cmd; |
| @@ -692,12 +693,13 @@ | |
| 692 | *(char*)(zDir-1) = 0; |
| 693 | transport_ssh_command(&cmd); |
| 694 | blob_appendf(&cmd, " -T"); |
| 695 | blob_append_escaped_arg(&cmd, zRemote, 0); |
| 696 | blob_init(&remote, 0, 0); |
| 697 | blob_appendf(&remote, "fossil patch %s%s --dir64 %z -", |
| 698 | zRemoteCmd, zForce, encode64(zDir, -1)); |
| 699 | blob_append_escaped_arg(&cmd, blob_str(&remote), 0); |
| 700 | blob_reset(&remote); |
| 701 | } |
| 702 | if( mFlags & PATCH_VERBOSE ){ |
| 703 | fossil_print("# %s\n", blob_str(&cmd)); |
| @@ -885,30 +887,32 @@ | |
| 885 | ** |
| 886 | ** * DIRECTORY |
| 887 | ** * HOST:DIRECTORY |
| 888 | ** * USER@HOST:DIRECTORY |
| 889 | ** |
| 890 | ** This command will only work if "fossil" is on the default PATH |
| 891 | ** of the remote machine. |
| 892 | ** |
| 893 | ** > fossil patch pull REMOTE-CHECKOUT |
| 894 | ** |
| 895 | ** Create a patch on a remote check-out, transfer that patch to the |
| 896 | ** local machine (using ssh) and apply the patch in the local checkout. |
| 897 | ** |
| 898 | ** -f|--force Apply the patch even though there are unsaved |
| 899 | ** changes in the current check-out. Unsaved changes |
| 900 | ** will be reverted and then the patch is applied. |
| 901 | ** -n|--dryrun Do nothing, but print what would have happened. |
| 902 | ** -v|--verbose Extra output explaining what happens. |
| 903 | ** |
| 904 | ** > fossil patch view FILENAME |
| 905 | ** |
| 906 | ** View a summary of the changes in the binary patch FILENAME. |
| 907 | ** Use "fossil patch diff" for detailed patch content. |
| 908 | ** |
| 909 | ** -v|--verbose Show extra detail about the patch. |
| 910 | ** |
| 911 | */ |
| 912 | void patch_cmd(void){ |
| 913 | const char *zCmd; |
| 914 | size_t n; |
| @@ -971,31 +975,34 @@ | |
| 971 | fossil_free(zIn); |
| 972 | }else |
| 973 | if( strncmp(zCmd, "pull", n)==0 ){ |
| 974 | FILE *pIn = 0; |
| 975 | unsigned flags = 0; |
| 976 | if( find_option("dryrun","n",0) ) flags |= PATCH_DRYRUN; |
| 977 | if( find_option("verbose","v",0) ) flags |= PATCH_VERBOSE; |
| 978 | if( find_option("force","f",0) ) flags |= PATCH_FORCE; |
| 979 | db_must_be_within_tree(); |
| 980 | verify_all_options(); |
| 981 | pIn = patch_remote_command(flags & (~PATCH_FORCE), "pull", "create", "r"); |
| 982 | if( pIn ){ |
| 983 | patch_attach(0, pIn); |
| 984 | pclose(pIn); |
| 985 | patch_apply(flags); |
| 986 | } |
| 987 | }else |
| 988 | if( strncmp(zCmd, "push", n)==0 ){ |
| 989 | FILE *pOut = 0; |
| 990 | unsigned flags = 0; |
| 991 | if( find_option("dryrun","n",0) ) flags |= PATCH_DRYRUN; |
| 992 | if( find_option("verbose","v",0) ) flags |= PATCH_VERBOSE; |
| 993 | if( find_option("force","f",0) ) flags |= PATCH_FORCE; |
| 994 | db_must_be_within_tree(); |
| 995 | verify_all_options(); |
| 996 | pOut = patch_remote_command(flags, "push", "apply", "w"); |
| 997 | if( pOut ){ |
| 998 | patch_create(0, 0, pOut); |
| 999 | pclose(pOut); |
| 1000 | } |
| 1001 | }else |
| 1002 |
| --- src/patch.c | |
| +++ src/patch.c | |
| @@ -661,10 +661,11 @@ | |
| 661 | */ |
| 662 | static FILE *patch_remote_command( |
| 663 | unsigned mFlags, /* flags */ |
| 664 | const char *zThisCmd, /* "push" or "pull" */ |
| 665 | const char *zRemoteCmd, /* "apply" or "create" */ |
| 666 | const char *zFossilCmd, /* Name of "fossil" on remote system */ |
| 667 | const char *zRW /* "w" or "r" */ |
| 668 | ){ |
| 669 | char *zRemote; |
| 670 | char *zDir; |
| 671 | Blob cmd; |
| @@ -692,12 +693,13 @@ | |
| 693 | *(char*)(zDir-1) = 0; |
| 694 | transport_ssh_command(&cmd); |
| 695 | blob_appendf(&cmd, " -T"); |
| 696 | blob_append_escaped_arg(&cmd, zRemote, 0); |
| 697 | blob_init(&remote, 0, 0); |
| 698 | if( zFossilCmd==0 ) zFossilCmd = "fossil"; |
| 699 | blob_appendf(&remote, "%$ patch %s%s --dir64 %z -", |
| 700 | zFossilCmd, zRemoteCmd, zForce, encode64(zDir, -1)); |
| 701 | blob_append_escaped_arg(&cmd, blob_str(&remote), 0); |
| 702 | blob_reset(&remote); |
| 703 | } |
| 704 | if( mFlags & PATCH_VERBOSE ){ |
| 705 | fossil_print("# %s\n", blob_str(&cmd)); |
| @@ -885,30 +887,32 @@ | |
| 887 | ** |
| 888 | ** * DIRECTORY |
| 889 | ** * HOST:DIRECTORY |
| 890 | ** * USER@HOST:DIRECTORY |
| 891 | ** |
| 892 | ** Command-line options: |
| 893 | ** |
| 894 | ** -f|--force Apply the patch even though there are unsaved |
| 895 | ** changes in the current check-out. Unsaved |
| 896 | ** changes will be reverted and then the patch is |
| 897 | ** applied. |
| 898 | ** --fossilcmd EXE Name of the "fossil" executable on the remote |
| 899 | ** -n|--dryrun Do nothing, but print what would have happened. |
| 900 | ** -v|--verbose Extra output explaining what happens. |
| 901 | ** |
| 902 | ** |
| 903 | ** > fossil patch pull REMOTE-CHECKOUT |
| 904 | ** |
| 905 | ** Like "fossil patch push" except that the transfer is from remote |
| 906 | ** to local. All the same command-line options apply. |
| 907 | ** |
| 908 | ** > fossil patch view FILENAME |
| 909 | ** |
| 910 | ** View a summary of the changes in the binary patch FILENAME. |
| 911 | ** Use "fossil patch diff" for detailed patch content. |
| 912 | ** |
| 913 | ** -v|--verbose Show extra detail about the patch. |
| 914 | ** |
| 915 | */ |
| 916 | void patch_cmd(void){ |
| 917 | const char *zCmd; |
| 918 | size_t n; |
| @@ -971,31 +975,34 @@ | |
| 975 | fossil_free(zIn); |
| 976 | }else |
| 977 | if( strncmp(zCmd, "pull", n)==0 ){ |
| 978 | FILE *pIn = 0; |
| 979 | unsigned flags = 0; |
| 980 | const char *zFossilCmd = find_option("fossilcmd",0,1); |
| 981 | if( find_option("dryrun","n",0) ) flags |= PATCH_DRYRUN; |
| 982 | if( find_option("verbose","v",0) ) flags |= PATCH_VERBOSE; |
| 983 | if( find_option("force","f",0) ) flags |= PATCH_FORCE; |
| 984 | db_must_be_within_tree(); |
| 985 | verify_all_options(); |
| 986 | pIn = patch_remote_command(flags & (~PATCH_FORCE), |
| 987 | "pull", "create", zFossilCmd, "r"); |
| 988 | if( pIn ){ |
| 989 | patch_attach(0, pIn); |
| 990 | pclose(pIn); |
| 991 | patch_apply(flags); |
| 992 | } |
| 993 | }else |
| 994 | if( strncmp(zCmd, "push", n)==0 ){ |
| 995 | FILE *pOut = 0; |
| 996 | unsigned flags = 0; |
| 997 | const char *zFossilCmd = find_option("fossilcmd",0,1); |
| 998 | if( find_option("dryrun","n",0) ) flags |= PATCH_DRYRUN; |
| 999 | if( find_option("verbose","v",0) ) flags |= PATCH_VERBOSE; |
| 1000 | if( find_option("force","f",0) ) flags |= PATCH_FORCE; |
| 1001 | db_must_be_within_tree(); |
| 1002 | verify_all_options(); |
| 1003 | pOut = patch_remote_command(flags, "push", "apply", zFossilCmd, "w"); |
| 1004 | if( pOut ){ |
| 1005 | patch_create(0, 0, pOut); |
| 1006 | pclose(pOut); |
| 1007 | } |
| 1008 | }else |
| 1009 |