Fossil SCM

Add the undocumented --script FILENAME option to all diff operations that make use of the --tk option. The --script FILENAME option is used for testing and debugging only.

drh 2013-10-08 13:11 trunk merge
Commit cee30a34d80d3fe7f8f6b275d0a5dc6f0c3aebb8
2 files changed +20 -6 +20 -6
+20 -6
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -915,11 +915,11 @@
915915
** (3) Delete the temp file.
916916
*/
917917
void diff_tk(const char *zSubCmd, int firstArg){
918918
int i;
919919
Blob script;
920
- char *zTempFile;
920
+ char *zTempFile = 0;
921921
char *zCmd;
922922
blob_zero(&script);
923923
blob_appendf(&script, "set fossilcmd {| \"%/\" %s --html -y -i -v",
924924
g.nameOfExe, zSubCmd);
925925
for(i=firstArg; i<g.argc; i++){
@@ -926,20 +926,34 @@
926926
const char *z = g.argv[i];
927927
if( z[0]=='-' ){
928928
if( strglob("*-html",z) ) continue;
929929
if( strglob("*-y",z) ) continue;
930930
if( strglob("*-i",z) ) continue;
931
+ /* The undocumented --script FILENAME option causes the Tk script to
932
+ ** be written into the FILENAME instead of being run. This is used
933
+ ** for testing and debugging. */
934
+ if( strglob("*-script",z) && i<g.argc-1 ){
935
+ i++;
936
+ zTempFile = g.argv[i];
937
+ continue;
938
+ }
931939
}
932940
blob_append(&script, " ", 1);
933941
shell_escape(&script, z);
934942
}
935943
blob_appendf(&script, "}\n%s", zDiffScript);
936
- zTempFile = write_blob_to_temp_file(&script);
937
- zCmd = mprintf("tclsh \"%s\"", zTempFile);
938
- fossil_system(zCmd);
939
- file_delete(zTempFile);
940
- fossil_free(zCmd);
944
+ if( zTempFile ){
945
+ blob_write_to_file(&script, zTempFile);
946
+ fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile);
947
+ }else{
948
+ zTempFile = write_blob_to_temp_file(&script);
949
+ zCmd = mprintf("tclsh \"%s\"", zTempFile);
950
+ fossil_system(zCmd);
951
+ file_delete(zTempFile);
952
+ fossil_free(zCmd);
953
+ }
954
+ blob_reset(&script);
941955
}
942956
943957
/*
944958
** Returns non-zero if files that may be binary should be used with external
945959
** diff programs.
946960
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -915,11 +915,11 @@
915 ** (3) Delete the temp file.
916 */
917 void diff_tk(const char *zSubCmd, int firstArg){
918 int i;
919 Blob script;
920 char *zTempFile;
921 char *zCmd;
922 blob_zero(&script);
923 blob_appendf(&script, "set fossilcmd {| \"%/\" %s --html -y -i -v",
924 g.nameOfExe, zSubCmd);
925 for(i=firstArg; i<g.argc; i++){
@@ -926,20 +926,34 @@
926 const char *z = g.argv[i];
927 if( z[0]=='-' ){
928 if( strglob("*-html",z) ) continue;
929 if( strglob("*-y",z) ) continue;
930 if( strglob("*-i",z) ) continue;
 
 
 
 
 
 
 
 
931 }
932 blob_append(&script, " ", 1);
933 shell_escape(&script, z);
934 }
935 blob_appendf(&script, "}\n%s", zDiffScript);
936 zTempFile = write_blob_to_temp_file(&script);
937 zCmd = mprintf("tclsh \"%s\"", zTempFile);
938 fossil_system(zCmd);
939 file_delete(zTempFile);
940 fossil_free(zCmd);
 
 
 
 
 
 
941 }
942
943 /*
944 ** Returns non-zero if files that may be binary should be used with external
945 ** diff programs.
946
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -915,11 +915,11 @@
915 ** (3) Delete the temp file.
916 */
917 void diff_tk(const char *zSubCmd, int firstArg){
918 int i;
919 Blob script;
920 char *zTempFile = 0;
921 char *zCmd;
922 blob_zero(&script);
923 blob_appendf(&script, "set fossilcmd {| \"%/\" %s --html -y -i -v",
924 g.nameOfExe, zSubCmd);
925 for(i=firstArg; i<g.argc; i++){
@@ -926,20 +926,34 @@
926 const char *z = g.argv[i];
927 if( z[0]=='-' ){
928 if( strglob("*-html",z) ) continue;
929 if( strglob("*-y",z) ) continue;
930 if( strglob("*-i",z) ) continue;
931 /* The undocumented --script FILENAME option causes the Tk script to
932 ** be written into the FILENAME instead of being run. This is used
933 ** for testing and debugging. */
934 if( strglob("*-script",z) && i<g.argc-1 ){
935 i++;
936 zTempFile = g.argv[i];
937 continue;
938 }
939 }
940 blob_append(&script, " ", 1);
941 shell_escape(&script, z);
942 }
943 blob_appendf(&script, "}\n%s", zDiffScript);
944 if( zTempFile ){
945 blob_write_to_file(&script, zTempFile);
946 fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile);
947 }else{
948 zTempFile = write_blob_to_temp_file(&script);
949 zCmd = mprintf("tclsh \"%s\"", zTempFile);
950 fossil_system(zCmd);
951 file_delete(zTempFile);
952 fossil_free(zCmd);
953 }
954 blob_reset(&script);
955 }
956
957 /*
958 ** Returns non-zero if files that may be binary should be used with external
959 ** diff programs.
960
+20 -6
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -915,11 +915,11 @@
915915
** (3) Delete the temp file.
916916
*/
917917
void diff_tk(const char *zSubCmd, int firstArg){
918918
int i;
919919
Blob script;
920
- char *zTempFile;
920
+ char *zTempFile = 0;
921921
char *zCmd;
922922
blob_zero(&script);
923923
blob_appendf(&script, "set fossilcmd {| \"%/\" %s --html -y -i -v",
924924
g.nameOfExe, zSubCmd);
925925
for(i=firstArg; i<g.argc; i++){
@@ -926,20 +926,34 @@
926926
const char *z = g.argv[i];
927927
if( z[0]=='-' ){
928928
if( strglob("*-html",z) ) continue;
929929
if( strglob("*-y",z) ) continue;
930930
if( strglob("*-i",z) ) continue;
931
+ /* The undocumented --script FILENAME option causes the Tk script to
932
+ ** be written into the FILENAME instead of being run. This is used
933
+ ** for testing and debugging. */
934
+ if( strglob("*-script",z) && i<g.argc-1 ){
935
+ i++;
936
+ zTempFile = g.argv[i];
937
+ continue;
938
+ }
931939
}
932940
blob_append(&script, " ", 1);
933941
shell_escape(&script, z);
934942
}
935943
blob_appendf(&script, "}\n%s", zDiffScript);
936
- zTempFile = write_blob_to_temp_file(&script);
937
- zCmd = mprintf("tclsh \"%s\"", zTempFile);
938
- fossil_system(zCmd);
939
- file_delete(zTempFile);
940
- fossil_free(zCmd);
944
+ if( zTempFile ){
945
+ blob_write_to_file(&script, zTempFile);
946
+ fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile);
947
+ }else{
948
+ zTempFile = write_blob_to_temp_file(&script);
949
+ zCmd = mprintf("tclsh \"%s\"", zTempFile);
950
+ fossil_system(zCmd);
951
+ file_delete(zTempFile);
952
+ fossil_free(zCmd);
953
+ }
954
+ blob_reset(&script);
941955
}
942956
943957
/*
944958
** Returns non-zero if files that may be binary should be used with external
945959
** diff programs.
946960
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -915,11 +915,11 @@
915 ** (3) Delete the temp file.
916 */
917 void diff_tk(const char *zSubCmd, int firstArg){
918 int i;
919 Blob script;
920 char *zTempFile;
921 char *zCmd;
922 blob_zero(&script);
923 blob_appendf(&script, "set fossilcmd {| \"%/\" %s --html -y -i -v",
924 g.nameOfExe, zSubCmd);
925 for(i=firstArg; i<g.argc; i++){
@@ -926,20 +926,34 @@
926 const char *z = g.argv[i];
927 if( z[0]=='-' ){
928 if( strglob("*-html",z) ) continue;
929 if( strglob("*-y",z) ) continue;
930 if( strglob("*-i",z) ) continue;
 
 
 
 
 
 
 
 
931 }
932 blob_append(&script, " ", 1);
933 shell_escape(&script, z);
934 }
935 blob_appendf(&script, "}\n%s", zDiffScript);
936 zTempFile = write_blob_to_temp_file(&script);
937 zCmd = mprintf("tclsh \"%s\"", zTempFile);
938 fossil_system(zCmd);
939 file_delete(zTempFile);
940 fossil_free(zCmd);
 
 
 
 
 
 
941 }
942
943 /*
944 ** Returns non-zero if files that may be binary should be used with external
945 ** diff programs.
946
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -915,11 +915,11 @@
915 ** (3) Delete the temp file.
916 */
917 void diff_tk(const char *zSubCmd, int firstArg){
918 int i;
919 Blob script;
920 char *zTempFile = 0;
921 char *zCmd;
922 blob_zero(&script);
923 blob_appendf(&script, "set fossilcmd {| \"%/\" %s --html -y -i -v",
924 g.nameOfExe, zSubCmd);
925 for(i=firstArg; i<g.argc; i++){
@@ -926,20 +926,34 @@
926 const char *z = g.argv[i];
927 if( z[0]=='-' ){
928 if( strglob("*-html",z) ) continue;
929 if( strglob("*-y",z) ) continue;
930 if( strglob("*-i",z) ) continue;
931 /* The undocumented --script FILENAME option causes the Tk script to
932 ** be written into the FILENAME instead of being run. This is used
933 ** for testing and debugging. */
934 if( strglob("*-script",z) && i<g.argc-1 ){
935 i++;
936 zTempFile = g.argv[i];
937 continue;
938 }
939 }
940 blob_append(&script, " ", 1);
941 shell_escape(&script, z);
942 }
943 blob_appendf(&script, "}\n%s", zDiffScript);
944 if( zTempFile ){
945 blob_write_to_file(&script, zTempFile);
946 fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile);
947 }else{
948 zTempFile = write_blob_to_temp_file(&script);
949 zCmd = mprintf("tclsh \"%s\"", zTempFile);
950 fossil_system(zCmd);
951 file_delete(zTempFile);
952 fossil_free(zCmd);
953 }
954 blob_reset(&script);
955 }
956
957 /*
958 ** Returns non-zero if files that may be binary should be used with external
959 ** diff programs.
960

Keyboard Shortcuts

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