Fossil SCM

Add the --debug option to "fossil merge-info --tk". Document that and the --script option.

drh 2025-02-19 17:10 trunk
Commit 97aee327ef8e144910243ea42d71ea32ab66650842753a9044c430b2a0b31815
2 files changed +11 +6 -1
+11
--- src/merge.c
+++ src/merge.c
@@ -28,10 +28,11 @@
2828
*/
2929
static void merge_info_tk(int bDark, int bAll, int nContext){
3030
int i;
3131
Blob script;
3232
const char *zTempFile = 0;
33
+ int bDebug;
3334
char *zCmd;
3435
const char *zTclsh;
3536
zTclsh = find_option("tclsh",0,1);
3637
if( zTclsh==0 ){
3738
zTclsh = db_get("tclsh",0);
@@ -38,10 +39,11 @@
3839
}
3940
/* The undocumented --script FILENAME option causes the Tk script to
4041
** be written into the FILENAME instead of being run. This is used
4142
** for testing and debugging. */
4243
zTempFile = find_option("script",0,1);
44
+ bDebug = find_option("debug",0,0)!=0;
4345
verify_all_options();
4446
4547
blob_zero(&script);
4648
blob_appendf(&script, "set ncontext %d\n", nContext);
4749
blob_appendf(&script, "set fossilcmd {| \"%/\" merge-info}\n",
@@ -93,10 +95,11 @@
9395
blob_reset(&fname);
9496
}
9597
}
9698
blob_appendf(&script, "]\n");
9799
blob_appendf(&script, "set darkmode %d\n", bDark!=0);
100
+ blob_appendf(&script, "set debug %d\n", bDebug!=0);
98101
blob_appendf(&script, "%s", builtin_file("merge.tcl", 0));
99102
if( zTempFile ){
100103
blob_write_to_file(&script, zTempFile);
101104
fossil_print("To see the merge, run: %s \"%s\"\n", zTclsh, zTempFile);
102105
}else{
@@ -114,10 +117,14 @@
114117
* to using the external "tclsh", if available.
115118
*/
116119
#endif
117120
zTempFile = write_blob_to_temp_file(&script);
118121
zCmd = mprintf("%$ %$", zTclsh, zTempFile);
122
+ if( bDebug ){
123
+ fossil_print("%s\n", zCmd);
124
+ fflush(stdout);
125
+ }
119126
fossil_system(zCmd);
120127
file_delete(zTempFile);
121128
fossil_free(zCmd);
122129
}
123130
blob_reset(&script);
@@ -257,10 +264,14 @@
257264
** FILE caused by the most recent merge. FILE must
258265
** be a pathname relative to the root of the check-out.
259266
** --tk Bring up a Tcl/Tk GUI that shows the changes
260267
** associated with the most recent merge.
261268
**
269
+** Additional debugging options available only when --tk is used:
270
+** --debug Show sub-commands run to implement --tk
271
+** --script FILE Write script used to implement --tk into FILE
272
+
262273
*/
263274
void merge_info_cmd(void){
264275
const char *zCnt;
265276
const char *zTcl;
266277
int bTk;
267278
--- src/merge.c
+++ src/merge.c
@@ -28,10 +28,11 @@
28 */
29 static void merge_info_tk(int bDark, int bAll, int nContext){
30 int i;
31 Blob script;
32 const char *zTempFile = 0;
 
33 char *zCmd;
34 const char *zTclsh;
35 zTclsh = find_option("tclsh",0,1);
36 if( zTclsh==0 ){
37 zTclsh = db_get("tclsh",0);
@@ -38,10 +39,11 @@
38 }
39 /* The undocumented --script FILENAME option causes the Tk script to
40 ** be written into the FILENAME instead of being run. This is used
41 ** for testing and debugging. */
42 zTempFile = find_option("script",0,1);
 
43 verify_all_options();
44
45 blob_zero(&script);
46 blob_appendf(&script, "set ncontext %d\n", nContext);
47 blob_appendf(&script, "set fossilcmd {| \"%/\" merge-info}\n",
@@ -93,10 +95,11 @@
93 blob_reset(&fname);
94 }
95 }
96 blob_appendf(&script, "]\n");
97 blob_appendf(&script, "set darkmode %d\n", bDark!=0);
 
98 blob_appendf(&script, "%s", builtin_file("merge.tcl", 0));
99 if( zTempFile ){
100 blob_write_to_file(&script, zTempFile);
101 fossil_print("To see the merge, run: %s \"%s\"\n", zTclsh, zTempFile);
102 }else{
@@ -114,10 +117,14 @@
114 * to using the external "tclsh", if available.
115 */
116 #endif
117 zTempFile = write_blob_to_temp_file(&script);
118 zCmd = mprintf("%$ %$", zTclsh, zTempFile);
 
 
 
 
119 fossil_system(zCmd);
120 file_delete(zTempFile);
121 fossil_free(zCmd);
122 }
123 blob_reset(&script);
@@ -257,10 +264,14 @@
257 ** FILE caused by the most recent merge. FILE must
258 ** be a pathname relative to the root of the check-out.
259 ** --tk Bring up a Tcl/Tk GUI that shows the changes
260 ** associated with the most recent merge.
261 **
 
 
 
 
262 */
263 void merge_info_cmd(void){
264 const char *zCnt;
265 const char *zTcl;
266 int bTk;
267
--- src/merge.c
+++ src/merge.c
@@ -28,10 +28,11 @@
28 */
29 static void merge_info_tk(int bDark, int bAll, int nContext){
30 int i;
31 Blob script;
32 const char *zTempFile = 0;
33 int bDebug;
34 char *zCmd;
35 const char *zTclsh;
36 zTclsh = find_option("tclsh",0,1);
37 if( zTclsh==0 ){
38 zTclsh = db_get("tclsh",0);
@@ -38,10 +39,11 @@
39 }
40 /* The undocumented --script FILENAME option causes the Tk script to
41 ** be written into the FILENAME instead of being run. This is used
42 ** for testing and debugging. */
43 zTempFile = find_option("script",0,1);
44 bDebug = find_option("debug",0,0)!=0;
45 verify_all_options();
46
47 blob_zero(&script);
48 blob_appendf(&script, "set ncontext %d\n", nContext);
49 blob_appendf(&script, "set fossilcmd {| \"%/\" merge-info}\n",
@@ -93,10 +95,11 @@
95 blob_reset(&fname);
96 }
97 }
98 blob_appendf(&script, "]\n");
99 blob_appendf(&script, "set darkmode %d\n", bDark!=0);
100 blob_appendf(&script, "set debug %d\n", bDebug!=0);
101 blob_appendf(&script, "%s", builtin_file("merge.tcl", 0));
102 if( zTempFile ){
103 blob_write_to_file(&script, zTempFile);
104 fossil_print("To see the merge, run: %s \"%s\"\n", zTclsh, zTempFile);
105 }else{
@@ -114,10 +117,14 @@
117 * to using the external "tclsh", if available.
118 */
119 #endif
120 zTempFile = write_blob_to_temp_file(&script);
121 zCmd = mprintf("%$ %$", zTclsh, zTempFile);
122 if( bDebug ){
123 fossil_print("%s\n", zCmd);
124 fflush(stdout);
125 }
126 fossil_system(zCmd);
127 file_delete(zTempFile);
128 fossil_free(zCmd);
129 }
130 blob_reset(&script);
@@ -257,10 +264,14 @@
264 ** FILE caused by the most recent merge. FILE must
265 ** be a pathname relative to the root of the check-out.
266 ** --tk Bring up a Tcl/Tk GUI that shows the changes
267 ** associated with the most recent merge.
268 **
269 ** Additional debugging options available only when --tk is used:
270 ** --debug Show sub-commands run to implement --tk
271 ** --script FILE Write script used to implement --tk into FILE
272
273 */
274 void merge_info_cmd(void){
275 const char *zCnt;
276 const char *zTcl;
277 int bTk;
278
+6 -1
--- src/merge.tcl
+++ src/merge.tcl
@@ -93,20 +93,25 @@
9393
regexp {[a-z]+} $c type
9494
return $type
9595
}
9696
9797
proc readMerge {args} {
98
- global fossilcmd ncontext current_file
98
+ global fossilcmd ncontext current_file debug
9999
if {$ncontext=="All"} {
100100
set cmd "$fossilcmd -c -1"
101101
} else {
102102
set cmd "$fossilcmd -c $ncontext"
103103
}
104104
if {[info exists current_file]} {
105105
regsub {^[A-Z]+ } $current_file {} fn
106106
append cmd " -tcl [list $fn]"
107107
}
108
+ if {$debug} {
109
+ regsub {^\| +} $cmd {} cmd2
110
+ puts $cmd2
111
+ flush stdout
112
+ }
108113
if {[catch {
109114
set in [open $cmd r]
110115
fconfigure $in -encoding utf-8
111116
set mergetxt [read $in]
112117
close $in
113118
--- src/merge.tcl
+++ src/merge.tcl
@@ -93,20 +93,25 @@
93 regexp {[a-z]+} $c type
94 return $type
95 }
96
97 proc readMerge {args} {
98 global fossilcmd ncontext current_file
99 if {$ncontext=="All"} {
100 set cmd "$fossilcmd -c -1"
101 } else {
102 set cmd "$fossilcmd -c $ncontext"
103 }
104 if {[info exists current_file]} {
105 regsub {^[A-Z]+ } $current_file {} fn
106 append cmd " -tcl [list $fn]"
107 }
 
 
 
 
 
108 if {[catch {
109 set in [open $cmd r]
110 fconfigure $in -encoding utf-8
111 set mergetxt [read $in]
112 close $in
113
--- src/merge.tcl
+++ src/merge.tcl
@@ -93,20 +93,25 @@
93 regexp {[a-z]+} $c type
94 return $type
95 }
96
97 proc readMerge {args} {
98 global fossilcmd ncontext current_file debug
99 if {$ncontext=="All"} {
100 set cmd "$fossilcmd -c -1"
101 } else {
102 set cmd "$fossilcmd -c $ncontext"
103 }
104 if {[info exists current_file]} {
105 regsub {^[A-Z]+ } $current_file {} fn
106 append cmd " -tcl [list $fn]"
107 }
108 if {$debug} {
109 regsub {^\| +} $cmd {} cmd2
110 puts $cmd2
111 flush stdout
112 }
113 if {[catch {
114 set in [open $cmd r]
115 fconfigure $in -encoding utf-8
116 set mergetxt [read $in]
117 close $in
118

Keyboard Shortcuts

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