Fossil

Check-in [fe9990adc7]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Cleanup use of Tcl integration for launching the Tk diff viewer internally.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: fe9990adc72f76d759f1df450965c4f33155fd60
User & Date: mistachkin 2014-02-04 20:30:41.122
Context
2014-02-14
13:37
Cherrypick [252aff3e62] and related clean-ups: Use built-in Tcl for "diff --tk" implementation if possible. Fallback is to spawn an external "tclsh" as before. This makes "fossil diff --tk" work with ActiveState Tcl on Win32 out-of-the-box. check-in: f325b2343e user: jan.nijtmans tags: branch-1.28
2014-02-04
20:32
Fix a couple corner cases for the TH1 expr command. check-in: e4e2b2e40e user: mistachkin tags: trunk
20:30
Cleanup use of Tcl integration for launching the Tk diff viewer internally. check-in: fe9990adc7 user: mistachkin tags: trunk
20:14
Potential fix for ticket [d752140c7a]. The reconstruct op appears to have been importing raw directory entries into the blob table. check-in: 8e110293ed user: stephan tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/diffcmd.c.
945
946
947
948
949
950
951
952

953
954
955
956
957
958
959
960
  }
  blob_appendf(&script, "}\n%s", zDiffScript);
  if( zTempFile ){
    blob_write_to_file(&script, zTempFile);
    fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile);
  }else{
#if defined(FOSSIL_ENABLE_TCL)
    Th_FossilInit(TH_INIT_DEFAULT | TH_INIT_FORCE_TCL);

    if (runTclGui(g.interp, &g.tcl, blob_str(&script)) == TCL_OK){
      blob_reset(&script);
      return;
    }
    /* If evaluation of the script fails, the reason could be that Tk
     * cannot be found by the built-in Tcl, or that Tcl cannot be
     * loaded dynamically (e.g. Win64 Tcl in Win32 fossil). Try again
     * using an external "tclsh", which might work in those two cases. */







|
>
|







945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
  }
  blob_appendf(&script, "}\n%s", zDiffScript);
  if( zTempFile ){
    blob_write_to_file(&script, zTempFile);
    fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile);
  }else{
#if defined(FOSSIL_ENABLE_TCL)
    Th_FossilInit(TH_INIT_DEFAULT);
    if( evaluateTclWithEvents(
        g.interp, &g.tcl, blob_str(&script), blob_size(&script), 1)==TCL_OK ){
      blob_reset(&script);
      return;
    }
    /* If evaluation of the script fails, the reason could be that Tk
     * cannot be found by the built-in Tcl, or that Tcl cannot be
     * loaded dynamically (e.g. Win64 Tcl in Win32 fossil). Try again
     * using an external "tclsh", which might work in those two cases. */
Changes to src/th.h.
155
156
157
158
159
160
161



162
163
164
165
166
167
168
169
170
171
*/
int th_register_language(Th_Interp *interp);            /* th_lang.c */
int th_register_sqlite(Th_Interp *interp);              /* th_sqlite.c */
int th_register_vfs(Th_Interp *interp);                 /* th_vfs.c */
int th_register_testvfs(Th_Interp *interp);             /* th_testvfs.c */

#ifdef FOSSIL_ENABLE_TCL



int th_register_tcl(Th_Interp *interp, void *pContext); /* th_tcl.c */
int unloadTcl(Th_Interp *interp, void *pContext);       /* th_tcl.c */
int runTclGui(Th_Interp *, void *, const char *);       /* th_tcl.c */
#endif

/*
** General purpose hash table from th_lang.c.
*/
typedef struct Th_Hash      Th_Hash;
typedef struct Th_HashEntry Th_HashEntry;







>
>
>
|
|
|







155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
*/
int th_register_language(Th_Interp *interp);            /* th_lang.c */
int th_register_sqlite(Th_Interp *interp);              /* th_sqlite.c */
int th_register_vfs(Th_Interp *interp);                 /* th_vfs.c */
int th_register_testvfs(Th_Interp *interp);             /* th_testvfs.c */

#ifdef FOSSIL_ENABLE_TCL
/*
** Interfaces to the full Tcl core library from "th_tcl.c".
*/
int th_register_tcl(Th_Interp *, void *);
int unloadTcl(Th_Interp *, void *);
int evaluateTclWithEvents(Th_Interp *, void *, const char *, int, int);
#endif

/*
** General purpose hash table from th_lang.c.
*/
typedef struct Th_Hash      Th_Hash;
typedef struct Th_HashEntry Th_HashEntry;
Changes to src/th_tcl.c.
766
767
768
769
770
771
772

773
774


775

776





777

778

779
780
781
782
783

784

785
786
787
788
789
790
791
792
793
794
    }
  }
  Tcl_DecrRefCount(listPtr);
  return rc;
}

/*

** Run a Tcl script. If the script succeeds, start the main loop until
** there is no more work to be done or the script calls "exit".


*/

int runTclGui(Th_Interp *interp, void *pContext, const char *script){





  struct TclContext *tclContext = (struct TclContext *)pContext;

  int rc;


  if( createTclInterp(interp, pContext)!=TH_OK ){
    return TH_ERROR;
  }
  rc = Tcl_EvalEx(tclContext->interp, script, -1, TCL_EVAL_GLOBAL);

  if (rc == TCL_OK){

    while (Tcl_DoOneEvent(0)) {
      /* do nothing */
    }
  }
  return rc;
}

/*
** Creates and initializes a Tcl interpreter for use with the specified TH1
** interpreter.  Stores the created Tcl interpreter in the Tcl context supplied







>
|
|
>
>

>
|
>
>
>
>
>

>

>




|
>
|
>
|
|
<







766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799

800
801
802
803
804
805
806
    }
  }
  Tcl_DecrRefCount(listPtr);
  return rc;
}

/*
** Evaluate a Tcl script, creating the Tcl interpreter if necessary. If the
** Tcl script succeeds, start a Tcl event loop until there are no more events
** remaining to process -OR- the script calls [exit].  If the bWait argument
** is zero, only process events that are already in the queue; otherwise,
** process events until the script terminates the Tcl event loop.
*/
int evaluateTclWithEvents(
  Th_Interp *interp,
  void *pContext,
  const char *zScript,
  int nScript,
  int bWait
){
  struct TclContext *tclContext = (struct TclContext *)pContext;
  Tcl_Interp *tclInterp;
  int rc;
  int flags = TCL_ALL_EVENTS;

  if( createTclInterp(interp, pContext)!=TH_OK ){
    return TH_ERROR;
  }
  tclInterp = tclContext->interp;
  rc = Tcl_EvalEx(tclInterp, zScript, nScript, TCL_EVAL_GLOBAL);
  if( rc!=TCL_OK ) return rc;
  if( !bWait ) flags |= TCL_DONT_WAIT;
  while( Tcl_DoOneEvent(flags) ){
    /* do nothing */

  }
  return rc;
}

/*
** Creates and initializes a Tcl interpreter for use with the specified TH1
** interpreter.  Stores the created Tcl interpreter in the Tcl context supplied