Fossil SCM

Add the --fossilcmd option to the "patch push" and "patch pull" commands. Also improve the "patch" documentation slightly.

drh 2021-08-19 19:38 trunk
Commit 280e12a35685a8679451a1a76f072120450f17577a11ff547a87943f116ac30d
1 file changed +22 -15
+22 -15
--- src/patch.c
+++ src/patch.c
@@ -661,10 +661,11 @@
661661
*/
662662
static FILE *patch_remote_command(
663663
unsigned mFlags, /* flags */
664664
const char *zThisCmd, /* "push" or "pull" */
665665
const char *zRemoteCmd, /* "apply" or "create" */
666
+ const char *zFossilCmd, /* Name of "fossil" on remote system */
666667
const char *zRW /* "w" or "r" */
667668
){
668669
char *zRemote;
669670
char *zDir;
670671
Blob cmd;
@@ -692,12 +693,13 @@
692693
*(char*)(zDir-1) = 0;
693694
transport_ssh_command(&cmd);
694695
blob_appendf(&cmd, " -T");
695696
blob_append_escaped_arg(&cmd, zRemote, 0);
696697
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));
699701
blob_append_escaped_arg(&cmd, blob_str(&remote), 0);
700702
blob_reset(&remote);
701703
}
702704
if( mFlags & PATCH_VERBOSE ){
703705
fossil_print("# %s\n", blob_str(&cmd));
@@ -885,30 +887,32 @@
885887
**
886888
** * DIRECTORY
887889
** * HOST:DIRECTORY
888890
** * USER@HOST:DIRECTORY
889891
**
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
+**
892902
**
893903
** > fossil patch pull REMOTE-CHECKOUT
894904
**
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.
903907
**
904908
** > fossil patch view FILENAME
905909
**
906910
** View a summary of the changes in the binary patch FILENAME.
907911
** Use "fossil patch diff" for detailed patch content.
908912
**
909
-** -v|--verbose Show extra detail about the patch.
913
+** -v|--verbose Show extra detail about the patch.
910914
**
911915
*/
912916
void patch_cmd(void){
913917
const char *zCmd;
914918
size_t n;
@@ -971,31 +975,34 @@
971975
fossil_free(zIn);
972976
}else
973977
if( strncmp(zCmd, "pull", n)==0 ){
974978
FILE *pIn = 0;
975979
unsigned flags = 0;
980
+ const char *zFossilCmd = find_option("fossilcmd",0,1);
976981
if( find_option("dryrun","n",0) ) flags |= PATCH_DRYRUN;
977982
if( find_option("verbose","v",0) ) flags |= PATCH_VERBOSE;
978983
if( find_option("force","f",0) ) flags |= PATCH_FORCE;
979984
db_must_be_within_tree();
980985
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");
982988
if( pIn ){
983989
patch_attach(0, pIn);
984990
pclose(pIn);
985991
patch_apply(flags);
986992
}
987993
}else
988994
if( strncmp(zCmd, "push", n)==0 ){
989995
FILE *pOut = 0;
990996
unsigned flags = 0;
997
+ const char *zFossilCmd = find_option("fossilcmd",0,1);
991998
if( find_option("dryrun","n",0) ) flags |= PATCH_DRYRUN;
992999
if( find_option("verbose","v",0) ) flags |= PATCH_VERBOSE;
9931000
if( find_option("force","f",0) ) flags |= PATCH_FORCE;
9941001
db_must_be_within_tree();
9951002
verify_all_options();
996
- pOut = patch_remote_command(flags, "push", "apply", "w");
1003
+ pOut = patch_remote_command(flags, "push", "apply", zFossilCmd, "w");
9971004
if( pOut ){
9981005
patch_create(0, 0, pOut);
9991006
pclose(pOut);
10001007
}
10011008
}else
10021009
--- 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

Keyboard Shortcuts

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