Fossil SCM

Improvements to the merge UI. Fix a mostly-harmless assertion associated with merge marks.

drh 2024-12-05 19:22 better-merge
Commit 48827897cf8be8e2f1d5b878e05da4d88a9f97e9567a9064932e99bd9cfa4fe9
2 files changed +58 -54 +2 -1
+58 -54
--- src/merge.tcl
+++ src/merge.tcl
@@ -335,73 +335,77 @@
335335
bind . <$key> "scroll-$axis $args; break"
336336
bind . <Shift-$key> continue
337337
}
338338
339339
frame .bb
340
+set useOptionMenu 1
340341
if {[info exists filelist]} {
341
- label .bb.filetag -text "File:"
342342
set current_file [lindex $filelist 1]
343
- trace add variable current_file write readMerge
344
-
345
- if {$tcl_platform(os)=="Darwin"} {
346
- set fnlist {}
347
- foreach {op fn} $filelist {lappend fnlist $fn}
348
- tk_optionMenu .bb.files current_file {*}$fnlist
349
- } else {
350
- ::ttk::menubutton .bb.files -text $current_file
351
- if {[tk windowingsystem] eq "win32"} {
352
- ::ttk::style theme use winnative
353
- .bb.files configure -padding {20 1 10 2}
354
- }
355
- toplevel .wfiles
356
- wm withdraw .wfiles
357
- update idletasks
358
- wm transient .wfiles .
359
- wm overrideredirect .wfiles 1
360
- set ht [expr {[llength $filelist]/2}]
361
- if {$ht>$CFG(LB_HEIGHT)} {set ht $CFG(LB_HEIGHT)}
362
- listbox .wfiles.lb -width 0 -height $ht -activestyle none \
363
- -yscroll {.wfiles.sb set}
364
- set mx 1
365
- foreach {op fn} $filelist {
366
- set n [string length $fn]
367
- if {$n>$mx} {set mx $n}
368
- .wfiles.lb insert end [format "%-9s %s" $op $fn]
369
- }
370
- .bb.files config -width $mx
371
- ::ttk::scrollbar .wfiles.sb -command {.wfiles.lb yview}
372
- grid .wfiles.lb .wfiles.sb -sticky ns
373
- bind .bb.files <1> {
374
- set x [winfo rootx %W]
375
- set y [expr {[winfo rooty %W]+[winfo height %W]}]
376
- wm geometry .wfiles +$x+$y
377
- wm deiconify .wfiles
378
- focus .wfiles.lb
379
- }
380
- bind .wfiles <FocusOut> {wm withdraw .wfiles}
381
- bind .wfiles <Escape> {focus .}
382
- foreach evt {1 Return} {
383
- bind .wfiles.lb <$evt> {
384
- set ii [%W curselection]
385
- set ::current_file [lindex $::filelist [expr {$ii*2+1}]]
386
- .bb.files config -text $::current_file
387
- focus .
388
- break
389
- }
390
- }
391
- bind .wfiles.lb <Motion> {
392
- %W selection clear 0 end
393
- %W selection set @%x,%y
343
+ if {[llength $filelist]>2} {
344
+ label .bb.filetag -text "File:"
345
+ trace add variable current_file write readMerge
346
+
347
+ if {$tcl_platform(os)=="Darwin" || [llength $filelist]<30} {
348
+ set fnlist {}
349
+ foreach {op fn} $filelist {lappend fnlist $fn}
350
+ tk_optionMenu .bb.files current_file {*}$fnlist
351
+ } else {
352
+ set useOptionMenu 0
353
+ ::ttk::menubutton .bb.files -text $current_file
354
+ if {[tk windowingsystem] eq "win32"} {
355
+ ::ttk::style theme use winnative
356
+ .bb.files configure -padding {20 1 10 2}
357
+ }
358
+ toplevel .wfiles
359
+ wm withdraw .wfiles
360
+ update idletasks
361
+ wm transient .wfiles .
362
+ wm overrideredirect .wfiles 1
363
+ set ht [expr {[llength $filelist]/2}]
364
+ if {$ht>$CFG(LB_HEIGHT)} {set ht $CFG(LB_HEIGHT)}
365
+ listbox .wfiles.lb -width 0 -height $ht -activestyle none \
366
+ -yscroll {.wfiles.sb set}
367
+ set mx 1
368
+ foreach {op fn} $filelist {
369
+ set n [string length $fn]
370
+ if {$n>$mx} {set mx $n}
371
+ .wfiles.lb insert end $fn
372
+ }
373
+ .bb.files config -width $mx
374
+ ::ttk::scrollbar .wfiles.sb -command {.wfiles.lb yview}
375
+ grid .wfiles.lb .wfiles.sb -sticky ns
376
+ bind .bb.files <1> {
377
+ set x [winfo rootx %W]
378
+ set y [expr {[winfo rooty %W]+[winfo height %W]}]
379
+ wm geometry .wfiles +$x+$y
380
+ wm deiconify .wfiles
381
+ focus .wfiles.lb
382
+ }
383
+ bind .wfiles <FocusOut> {wm withdraw .wfiles}
384
+ bind .wfiles <Escape> {focus .}
385
+ foreach evt {1 Return} {
386
+ bind .wfiles.lb <$evt> {
387
+ set ii [%W curselection]
388
+ set ::current_file [lindex $::filelist [expr {$ii*2+1}]]
389
+ .bb.files config -text $::current_file
390
+ focus .
391
+ break
392
+ }
393
+ }
394
+ bind .wfiles.lb <Motion> {
395
+ %W selection clear 0 end
396
+ %W selection set @%x,%y
397
+ }
394398
}
395399
}
396400
}
397401
398402
label .bb.ctxtag -text "Context:"
399403
set context_choices {3 6 12 25 50 100 All}
400404
if {$ncontext<0} {set ncontext All}
401405
trace add variable ncontext write readMerge
402
-if {$tcl_platform(os)=="Darwin"} {
406
+if {$tcl_platform(os)=="Darwin" || $useOptionMenu} {
403407
tk_optionMenu .bb.ctx ncontext {*}$context_choices
404408
} else {
405409
::ttk::menubutton .bb.ctx -text $ncontext
406410
if {[tk windowingsystem] eq "win32"} {
407411
::ttk::style theme use winnative
@@ -559,11 +563,11 @@
559563
set ::search $w
560564
}
561565
::ttk::button .bb.quit -text {Quit} -command exit
562566
::ttk::button .bb.search -text {Search} -command searchOnOff
563567
pack .bb.quit -side left
564
-if {[info exists filelist]} {
568
+if {[winfo exists .bb.files]} {
565569
pack .bb.filetag .bb.files -side left
566570
}
567571
pack .bb.ctxtag .bb.ctx -side left
568572
pack .bb.search -side left
569573
grid rowconfigure . 1 -weight 1 -minsize [winfo reqheight .nameA]
570574
--- src/merge.tcl
+++ src/merge.tcl
@@ -335,73 +335,77 @@
335 bind . <$key> "scroll-$axis $args; break"
336 bind . <Shift-$key> continue
337 }
338
339 frame .bb
 
340 if {[info exists filelist]} {
341 label .bb.filetag -text "File:"
342 set current_file [lindex $filelist 1]
343 trace add variable current_file write readMerge
344
345 if {$tcl_platform(os)=="Darwin"} {
346 set fnlist {}
347 foreach {op fn} $filelist {lappend fnlist $fn}
348 tk_optionMenu .bb.files current_file {*}$fnlist
349 } else {
350 ::ttk::menubutton .bb.files -text $current_file
351 if {[tk windowingsystem] eq "win32"} {
352 ::ttk::style theme use winnative
353 .bb.files configure -padding {20 1 10 2}
354 }
355 toplevel .wfiles
356 wm withdraw .wfiles
357 update idletasks
358 wm transient .wfiles .
359 wm overrideredirect .wfiles 1
360 set ht [expr {[llength $filelist]/2}]
361 if {$ht>$CFG(LB_HEIGHT)} {set ht $CFG(LB_HEIGHT)}
362 listbox .wfiles.lb -width 0 -height $ht -activestyle none \
363 -yscroll {.wfiles.sb set}
364 set mx 1
365 foreach {op fn} $filelist {
366 set n [string length $fn]
367 if {$n>$mx} {set mx $n}
368 .wfiles.lb insert end [format "%-9s %s" $op $fn]
369 }
370 .bb.files config -width $mx
371 ::ttk::scrollbar .wfiles.sb -command {.wfiles.lb yview}
372 grid .wfiles.lb .wfiles.sb -sticky ns
373 bind .bb.files <1> {
374 set x [winfo rootx %W]
375 set y [expr {[winfo rooty %W]+[winfo height %W]}]
376 wm geometry .wfiles +$x+$y
377 wm deiconify .wfiles
378 focus .wfiles.lb
379 }
380 bind .wfiles <FocusOut> {wm withdraw .wfiles}
381 bind .wfiles <Escape> {focus .}
382 foreach evt {1 Return} {
383 bind .wfiles.lb <$evt> {
384 set ii [%W curselection]
385 set ::current_file [lindex $::filelist [expr {$ii*2+1}]]
386 .bb.files config -text $::current_file
387 focus .
388 break
389 }
390 }
391 bind .wfiles.lb <Motion> {
392 %W selection clear 0 end
393 %W selection set @%x,%y
 
 
 
 
394 }
395 }
396 }
397
398 label .bb.ctxtag -text "Context:"
399 set context_choices {3 6 12 25 50 100 All}
400 if {$ncontext<0} {set ncontext All}
401 trace add variable ncontext write readMerge
402 if {$tcl_platform(os)=="Darwin"} {
403 tk_optionMenu .bb.ctx ncontext {*}$context_choices
404 } else {
405 ::ttk::menubutton .bb.ctx -text $ncontext
406 if {[tk windowingsystem] eq "win32"} {
407 ::ttk::style theme use winnative
@@ -559,11 +563,11 @@
559 set ::search $w
560 }
561 ::ttk::button .bb.quit -text {Quit} -command exit
562 ::ttk::button .bb.search -text {Search} -command searchOnOff
563 pack .bb.quit -side left
564 if {[info exists filelist]} {
565 pack .bb.filetag .bb.files -side left
566 }
567 pack .bb.ctxtag .bb.ctx -side left
568 pack .bb.search -side left
569 grid rowconfigure . 1 -weight 1 -minsize [winfo reqheight .nameA]
570
--- src/merge.tcl
+++ src/merge.tcl
@@ -335,73 +335,77 @@
335 bind . <$key> "scroll-$axis $args; break"
336 bind . <Shift-$key> continue
337 }
338
339 frame .bb
340 set useOptionMenu 1
341 if {[info exists filelist]} {
 
342 set current_file [lindex $filelist 1]
343 if {[llength $filelist]>2} {
344 label .bb.filetag -text "File:"
345 trace add variable current_file write readMerge
346
347 if {$tcl_platform(os)=="Darwin" || [llength $filelist]<30} {
348 set fnlist {}
349 foreach {op fn} $filelist {lappend fnlist $fn}
350 tk_optionMenu .bb.files current_file {*}$fnlist
351 } else {
352 set useOptionMenu 0
353 ::ttk::menubutton .bb.files -text $current_file
354 if {[tk windowingsystem] eq "win32"} {
355 ::ttk::style theme use winnative
356 .bb.files configure -padding {20 1 10 2}
357 }
358 toplevel .wfiles
359 wm withdraw .wfiles
360 update idletasks
361 wm transient .wfiles .
362 wm overrideredirect .wfiles 1
363 set ht [expr {[llength $filelist]/2}]
364 if {$ht>$CFG(LB_HEIGHT)} {set ht $CFG(LB_HEIGHT)}
365 listbox .wfiles.lb -width 0 -height $ht -activestyle none \
366 -yscroll {.wfiles.sb set}
367 set mx 1
368 foreach {op fn} $filelist {
369 set n [string length $fn]
370 if {$n>$mx} {set mx $n}
371 .wfiles.lb insert end $fn
372 }
373 .bb.files config -width $mx
374 ::ttk::scrollbar .wfiles.sb -command {.wfiles.lb yview}
375 grid .wfiles.lb .wfiles.sb -sticky ns
376 bind .bb.files <1> {
377 set x [winfo rootx %W]
378 set y [expr {[winfo rooty %W]+[winfo height %W]}]
379 wm geometry .wfiles +$x+$y
380 wm deiconify .wfiles
381 focus .wfiles.lb
382 }
383 bind .wfiles <FocusOut> {wm withdraw .wfiles}
384 bind .wfiles <Escape> {focus .}
385 foreach evt {1 Return} {
386 bind .wfiles.lb <$evt> {
387 set ii [%W curselection]
388 set ::current_file [lindex $::filelist [expr {$ii*2+1}]]
389 .bb.files config -text $::current_file
390 focus .
391 break
392 }
393 }
394 bind .wfiles.lb <Motion> {
395 %W selection clear 0 end
396 %W selection set @%x,%y
397 }
398 }
399 }
400 }
401
402 label .bb.ctxtag -text "Context:"
403 set context_choices {3 6 12 25 50 100 All}
404 if {$ncontext<0} {set ncontext All}
405 trace add variable ncontext write readMerge
406 if {$tcl_platform(os)=="Darwin" || $useOptionMenu} {
407 tk_optionMenu .bb.ctx ncontext {*}$context_choices
408 } else {
409 ::ttk::menubutton .bb.ctx -text $ncontext
410 if {[tk windowingsystem] eq "win32"} {
411 ::ttk::style theme use winnative
@@ -559,11 +563,11 @@
563 set ::search $w
564 }
565 ::ttk::button .bb.quit -text {Quit} -command exit
566 ::ttk::button .bb.search -text {Search} -command searchOnOff
567 pack .bb.quit -side left
568 if {[winfo exists .bb.files]} {
569 pack .bb.filetag .bb.files -side left
570 }
571 pack .bb.ctxtag .bb.ctx -side left
572 pack .bb.search -side left
573 grid rowconfigure . 1 -weight 1 -minsize [winfo reqheight .nameA]
574
+2 -1
--- src/merge3.c
+++ src/merge3.c
@@ -881,11 +881,12 @@
881881
const char *z = blob_buffer(p);
882882
int n = blob_size(p) - len + 1;
883883
assert( len==(int)strlen(mergeMarker[1]) );
884884
assert( len==(int)strlen(mergeMarker[2]) );
885885
assert( len==(int)strlen(mergeMarker[3]) );
886
- assert( count(mergeMarker)==4 );
886
+ assert( len==(int)strlen(mergeMarker[4]) );
887
+ assert( count(mergeMarker)==5 );
887888
for(i=0; i<n; ){
888889
for(j=0; j<4; j++){
889890
if( (memcmp(&z[i], mergeMarker[j], len)==0) ){
890891
return 1;
891892
}
892893
--- src/merge3.c
+++ src/merge3.c
@@ -881,11 +881,12 @@
881 const char *z = blob_buffer(p);
882 int n = blob_size(p) - len + 1;
883 assert( len==(int)strlen(mergeMarker[1]) );
884 assert( len==(int)strlen(mergeMarker[2]) );
885 assert( len==(int)strlen(mergeMarker[3]) );
886 assert( count(mergeMarker)==4 );
 
887 for(i=0; i<n; ){
888 for(j=0; j<4; j++){
889 if( (memcmp(&z[i], mergeMarker[j], len)==0) ){
890 return 1;
891 }
892
--- src/merge3.c
+++ src/merge3.c
@@ -881,11 +881,12 @@
881 const char *z = blob_buffer(p);
882 int n = blob_size(p) - len + 1;
883 assert( len==(int)strlen(mergeMarker[1]) );
884 assert( len==(int)strlen(mergeMarker[2]) );
885 assert( len==(int)strlen(mergeMarker[3]) );
886 assert( len==(int)strlen(mergeMarker[4]) );
887 assert( count(mergeMarker)==5 );
888 for(i=0; i<n; ){
889 for(j=0; j<4; j++){
890 if( (memcmp(&z[i], mergeMarker[j], len)==0) ){
891 return 1;
892 }
893

Keyboard Shortcuts

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