Fossil SCM

Add the --tclsh command to "fossil diff" in order to specify an alternative TCL interpreter.

drh 2019-06-29 10:21 trunk
Commit 9fc945c056ac3da1e9de0628b942a16064519dd174174164708c8cb294c4ff43
2 files changed +6 +8 -2
+6
--- src/db.c
+++ src/db.c
@@ -3473,10 +3473,16 @@
34733473
** This is the setup script to be evaluated after creating
34743474
** and initializing the Tcl interpreter. By default, this
34753475
** is empty and no extra setup is performed.
34763476
*/
34773477
#endif /* FOSSIL_ENABLE_TCL */
3478
+/*
3479
+** SETTING: tclsh width=80 default=tclsh
3480
+** Name of the external TCL interpreter used for such things
3481
+** as running the GUI diff viewer launched by the --tk option
3482
+** of the various "diff" commands.
3483
+*/
34783484
#ifdef FOSSIL_ENABLE_TH1_DOCS
34793485
/*
34803486
** SETTING: th1-docs boolean default=off
34813487
** If enabled, this allows embedded documentation files to contain
34823488
** arbitrary TH1 scripts that are evaluated on the server. If native
34833489
--- src/db.c
+++ src/db.c
@@ -3473,10 +3473,16 @@
3473 ** This is the setup script to be evaluated after creating
3474 ** and initializing the Tcl interpreter. By default, this
3475 ** is empty and no extra setup is performed.
3476 */
3477 #endif /* FOSSIL_ENABLE_TCL */
 
 
 
 
 
 
3478 #ifdef FOSSIL_ENABLE_TH1_DOCS
3479 /*
3480 ** SETTING: th1-docs boolean default=off
3481 ** If enabled, this allows embedded documentation files to contain
3482 ** arbitrary TH1 scripts that are evaluated on the server. If native
3483
--- src/db.c
+++ src/db.c
@@ -3473,10 +3473,16 @@
3473 ** This is the setup script to be evaluated after creating
3474 ** and initializing the Tcl interpreter. By default, this
3475 ** is empty and no extra setup is performed.
3476 */
3477 #endif /* FOSSIL_ENABLE_TCL */
3478 /*
3479 ** SETTING: tclsh width=80 default=tclsh
3480 ** Name of the external TCL interpreter used for such things
3481 ** as running the GUI diff viewer launched by the --tk option
3482 ** of the various "diff" commands.
3483 */
3484 #ifdef FOSSIL_ENABLE_TH1_DOCS
3485 /*
3486 ** SETTING: th1-docs boolean default=off
3487 ** If enabled, this allows embedded documentation files to contain
3488 ** arbitrary TH1 scripts that are evaluated on the server. If native
3489
+8 -2
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -697,17 +697,22 @@
697697
void diff_tk(const char *zSubCmd, int firstArg){
698698
int i;
699699
Blob script;
700700
const char *zTempFile = 0;
701701
char *zCmd;
702
+ const char *zTclsh;
702703
blob_zero(&script);
703704
blob_appendf(&script, "set fossilcmd {| \"%/\" %s --html -y -i -v",
704705
g.nameOfExe, zSubCmd);
705706
find_option("html",0,0);
706707
find_option("side-by-side","y",0);
707708
find_option("internal","i",0);
708709
find_option("verbose","v",0);
710
+ zTclsh = find_option("tclsh",0,1);
711
+ if( zTclsh==0 ){
712
+ zTclsh = db_get("tclsh","tclsh");
713
+ }
709714
/* The undocumented --script FILENAME option causes the Tk script to
710715
** be written into the FILENAME instead of being run. This is used
711716
** for testing and debugging. */
712717
zTempFile = find_option("script",0,1);
713718
for(i=firstArg; i<g.argc; i++){
@@ -721,11 +726,11 @@
721726
}
722727
}
723728
blob_appendf(&script, "}\n%s", builtin_file("diff.tcl", 0));
724729
if( zTempFile ){
725730
blob_write_to_file(&script, zTempFile);
726
- fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile);
731
+ fossil_print("To see diff, run: %s \"%s\"\n", zTclsh, zTempFile);
727732
}else{
728733
#if defined(FOSSIL_ENABLE_TCL)
729734
Th_FossilInit(TH_INIT_DEFAULT);
730735
if( evaluateTclWithEvents(g.interp, &g.tcl, blob_str(&script),
731736
blob_size(&script), 1, 1, 0)==TCL_OK ){
@@ -738,11 +743,11 @@
738743
* dynamically (e.g. x64 Tcl with x86 Fossil). Therefore, fallback
739744
* to using the external "tclsh", if available.
740745
*/
741746
#endif
742747
zTempFile = write_blob_to_temp_file(&script);
743
- zCmd = mprintf("tclsh \"%s\"", zTempFile);
748
+ zCmd = mprintf("\"%s\" \"%s\"", zTclsh, zTempFile);
744749
fossil_system(zCmd);
745750
file_delete(zTempFile);
746751
fossil_free(zCmd);
747752
}
748753
blob_reset(&script);
@@ -825,10 +830,11 @@
825830
** --internal|-i Use internal diff logic
826831
** --new-file|-N Show complete text of added and deleted files
827832
** --numstat Show only the number of lines delete and added
828833
** --side-by-side|-y Side-by-side diff
829834
** --strip-trailing-cr Strip trailing CR
835
+** --tclsh PATH Tcl/Tk used for --tk (default: "tclsh")
830836
** --tk Launch a Tcl/Tk GUI for display
831837
** --to VERSION Select VERSION as target for the diff
832838
** --undo Diff against the "undo" buffer
833839
** --unified Unified diff
834840
** -v|--verbose Output complete text of added or deleted files
835841
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -697,17 +697,22 @@
697 void diff_tk(const char *zSubCmd, int firstArg){
698 int i;
699 Blob script;
700 const char *zTempFile = 0;
701 char *zCmd;
 
702 blob_zero(&script);
703 blob_appendf(&script, "set fossilcmd {| \"%/\" %s --html -y -i -v",
704 g.nameOfExe, zSubCmd);
705 find_option("html",0,0);
706 find_option("side-by-side","y",0);
707 find_option("internal","i",0);
708 find_option("verbose","v",0);
 
 
 
 
709 /* The undocumented --script FILENAME option causes the Tk script to
710 ** be written into the FILENAME instead of being run. This is used
711 ** for testing and debugging. */
712 zTempFile = find_option("script",0,1);
713 for(i=firstArg; i<g.argc; i++){
@@ -721,11 +726,11 @@
721 }
722 }
723 blob_appendf(&script, "}\n%s", builtin_file("diff.tcl", 0));
724 if( zTempFile ){
725 blob_write_to_file(&script, zTempFile);
726 fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile);
727 }else{
728 #if defined(FOSSIL_ENABLE_TCL)
729 Th_FossilInit(TH_INIT_DEFAULT);
730 if( evaluateTclWithEvents(g.interp, &g.tcl, blob_str(&script),
731 blob_size(&script), 1, 1, 0)==TCL_OK ){
@@ -738,11 +743,11 @@
738 * dynamically (e.g. x64 Tcl with x86 Fossil). Therefore, fallback
739 * to using the external "tclsh", if available.
740 */
741 #endif
742 zTempFile = write_blob_to_temp_file(&script);
743 zCmd = mprintf("tclsh \"%s\"", zTempFile);
744 fossil_system(zCmd);
745 file_delete(zTempFile);
746 fossil_free(zCmd);
747 }
748 blob_reset(&script);
@@ -825,10 +830,11 @@
825 ** --internal|-i Use internal diff logic
826 ** --new-file|-N Show complete text of added and deleted files
827 ** --numstat Show only the number of lines delete and added
828 ** --side-by-side|-y Side-by-side diff
829 ** --strip-trailing-cr Strip trailing CR
 
830 ** --tk Launch a Tcl/Tk GUI for display
831 ** --to VERSION Select VERSION as target for the diff
832 ** --undo Diff against the "undo" buffer
833 ** --unified Unified diff
834 ** -v|--verbose Output complete text of added or deleted files
835
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -697,17 +697,22 @@
697 void diff_tk(const char *zSubCmd, int firstArg){
698 int i;
699 Blob script;
700 const char *zTempFile = 0;
701 char *zCmd;
702 const char *zTclsh;
703 blob_zero(&script);
704 blob_appendf(&script, "set fossilcmd {| \"%/\" %s --html -y -i -v",
705 g.nameOfExe, zSubCmd);
706 find_option("html",0,0);
707 find_option("side-by-side","y",0);
708 find_option("internal","i",0);
709 find_option("verbose","v",0);
710 zTclsh = find_option("tclsh",0,1);
711 if( zTclsh==0 ){
712 zTclsh = db_get("tclsh","tclsh");
713 }
714 /* The undocumented --script FILENAME option causes the Tk script to
715 ** be written into the FILENAME instead of being run. This is used
716 ** for testing and debugging. */
717 zTempFile = find_option("script",0,1);
718 for(i=firstArg; i<g.argc; i++){
@@ -721,11 +726,11 @@
726 }
727 }
728 blob_appendf(&script, "}\n%s", builtin_file("diff.tcl", 0));
729 if( zTempFile ){
730 blob_write_to_file(&script, zTempFile);
731 fossil_print("To see diff, run: %s \"%s\"\n", zTclsh, zTempFile);
732 }else{
733 #if defined(FOSSIL_ENABLE_TCL)
734 Th_FossilInit(TH_INIT_DEFAULT);
735 if( evaluateTclWithEvents(g.interp, &g.tcl, blob_str(&script),
736 blob_size(&script), 1, 1, 0)==TCL_OK ){
@@ -738,11 +743,11 @@
743 * dynamically (e.g. x64 Tcl with x86 Fossil). Therefore, fallback
744 * to using the external "tclsh", if available.
745 */
746 #endif
747 zTempFile = write_blob_to_temp_file(&script);
748 zCmd = mprintf("\"%s\" \"%s\"", zTclsh, zTempFile);
749 fossil_system(zCmd);
750 file_delete(zTempFile);
751 fossil_free(zCmd);
752 }
753 blob_reset(&script);
@@ -825,10 +830,11 @@
830 ** --internal|-i Use internal diff logic
831 ** --new-file|-N Show complete text of added and deleted files
832 ** --numstat Show only the number of lines delete and added
833 ** --side-by-side|-y Side-by-side diff
834 ** --strip-trailing-cr Strip trailing CR
835 ** --tclsh PATH Tcl/Tk used for --tk (default: "tclsh")
836 ** --tk Launch a Tcl/Tk GUI for display
837 ** --to VERSION Select VERSION as target for the diff
838 ** --undo Diff against the "undo" buffer
839 ** --unified Unified diff
840 ** -v|--verbose Output complete text of added or deleted files
841

Keyboard Shortcuts

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