Fossil SCM
Add the --debug option to "fossil merge-info --tk". Document that and the --script option.
Commit
97aee327ef8e144910243ea42d71ea32ab66650842753a9044c430b2a0b31815
Parent
ea94e4c1b20a2af…
2 files changed
+11
+6
-1
+11
| --- src/merge.c | ||
| +++ src/merge.c | ||
| @@ -28,10 +28,11 @@ | ||
| 28 | 28 | */ |
| 29 | 29 | static void merge_info_tk(int bDark, int bAll, int nContext){ |
| 30 | 30 | int i; |
| 31 | 31 | Blob script; |
| 32 | 32 | const char *zTempFile = 0; |
| 33 | + int bDebug; | |
| 33 | 34 | char *zCmd; |
| 34 | 35 | const char *zTclsh; |
| 35 | 36 | zTclsh = find_option("tclsh",0,1); |
| 36 | 37 | if( zTclsh==0 ){ |
| 37 | 38 | zTclsh = db_get("tclsh",0); |
| @@ -38,10 +39,11 @@ | ||
| 38 | 39 | } |
| 39 | 40 | /* The undocumented --script FILENAME option causes the Tk script to |
| 40 | 41 | ** be written into the FILENAME instead of being run. This is used |
| 41 | 42 | ** for testing and debugging. */ |
| 42 | 43 | zTempFile = find_option("script",0,1); |
| 44 | + bDebug = find_option("debug",0,0)!=0; | |
| 43 | 45 | verify_all_options(); |
| 44 | 46 | |
| 45 | 47 | blob_zero(&script); |
| 46 | 48 | blob_appendf(&script, "set ncontext %d\n", nContext); |
| 47 | 49 | blob_appendf(&script, "set fossilcmd {| \"%/\" merge-info}\n", |
| @@ -93,10 +95,11 @@ | ||
| 93 | 95 | blob_reset(&fname); |
| 94 | 96 | } |
| 95 | 97 | } |
| 96 | 98 | blob_appendf(&script, "]\n"); |
| 97 | 99 | blob_appendf(&script, "set darkmode %d\n", bDark!=0); |
| 100 | + blob_appendf(&script, "set debug %d\n", bDebug!=0); | |
| 98 | 101 | blob_appendf(&script, "%s", builtin_file("merge.tcl", 0)); |
| 99 | 102 | if( zTempFile ){ |
| 100 | 103 | blob_write_to_file(&script, zTempFile); |
| 101 | 104 | fossil_print("To see the merge, run: %s \"%s\"\n", zTclsh, zTempFile); |
| 102 | 105 | }else{ |
| @@ -114,10 +117,14 @@ | ||
| 114 | 117 | * to using the external "tclsh", if available. |
| 115 | 118 | */ |
| 116 | 119 | #endif |
| 117 | 120 | zTempFile = write_blob_to_temp_file(&script); |
| 118 | 121 | zCmd = mprintf("%$ %$", zTclsh, zTempFile); |
| 122 | + if( bDebug ){ | |
| 123 | + fossil_print("%s\n", zCmd); | |
| 124 | + fflush(stdout); | |
| 125 | + } | |
| 119 | 126 | fossil_system(zCmd); |
| 120 | 127 | file_delete(zTempFile); |
| 121 | 128 | fossil_free(zCmd); |
| 122 | 129 | } |
| 123 | 130 | blob_reset(&script); |
| @@ -257,10 +264,14 @@ | ||
| 257 | 264 | ** FILE caused by the most recent merge. FILE must |
| 258 | 265 | ** be a pathname relative to the root of the check-out. |
| 259 | 266 | ** --tk Bring up a Tcl/Tk GUI that shows the changes |
| 260 | 267 | ** associated with the most recent merge. |
| 261 | 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 | + | |
| 262 | 273 | */ |
| 263 | 274 | void merge_info_cmd(void){ |
| 264 | 275 | const char *zCnt; |
| 265 | 276 | const char *zTcl; |
| 266 | 277 | int bTk; |
| 267 | 278 |
| --- 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 @@ | ||
| 93 | 93 | regexp {[a-z]+} $c type |
| 94 | 94 | return $type |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | proc readMerge {args} { |
| 98 | - global fossilcmd ncontext current_file | |
| 98 | + global fossilcmd ncontext current_file debug | |
| 99 | 99 | if {$ncontext=="All"} { |
| 100 | 100 | set cmd "$fossilcmd -c -1" |
| 101 | 101 | } else { |
| 102 | 102 | set cmd "$fossilcmd -c $ncontext" |
| 103 | 103 | } |
| 104 | 104 | if {[info exists current_file]} { |
| 105 | 105 | regsub {^[A-Z]+ } $current_file {} fn |
| 106 | 106 | append cmd " -tcl [list $fn]" |
| 107 | 107 | } |
| 108 | + if {$debug} { | |
| 109 | + regsub {^\| +} $cmd {} cmd2 | |
| 110 | + puts $cmd2 | |
| 111 | + flush stdout | |
| 112 | + } | |
| 108 | 113 | if {[catch { |
| 109 | 114 | set in [open $cmd r] |
| 110 | 115 | fconfigure $in -encoding utf-8 |
| 111 | 116 | set mergetxt [read $in] |
| 112 | 117 | close $in |
| 113 | 118 |
| --- 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 |