comparison contrib/hgk @ 5394:0ad0e97345eb

hgk: add context menu visual diff action * * *
author Patrick Mezard <pmezard@gmail.com>
date Tue, 02 Oct 2007 23:28:04 +0200
parents c2ad1890fc53
children e73a83af7926
comparison
equal deleted inserted replaced
5393:c2ad1890fc53 5394:0ad0e97345eb
397 global canv canv2 canv3 linespc charspc ctext cflist textfont 397 global canv canv2 canv3 linespc charspc ctext cflist textfont
398 global findtype findtypemenu findloc findstring fstring geometry 398 global findtype findtypemenu findloc findstring fstring geometry
399 global entries sha1entry sha1string sha1but 399 global entries sha1entry sha1string sha1but
400 global maincursor textcursor curtextcursor 400 global maincursor textcursor curtextcursor
401 global rowctxmenu gaudydiff mergemax 401 global rowctxmenu gaudydiff mergemax
402 global hgvdiff
402 403
403 menu .bar 404 menu .bar
404 .bar add cascade -label "File" -menu .bar.file 405 .bar add cascade -label "File" -menu .bar.file
405 menu .bar.file 406 menu .bar.file
406 .bar.file add command -label "Reread references" -command rereadrefs 407 .bar.file add command -label "Reread references" -command rereadrefs
600 $rowctxmenu add command -label "Diff selected -> this" \ 601 $rowctxmenu add command -label "Diff selected -> this" \
601 -command {diffvssel 1} 602 -command {diffvssel 1}
602 $rowctxmenu add command -label "Make patch" -command mkpatch 603 $rowctxmenu add command -label "Make patch" -command mkpatch
603 $rowctxmenu add command -label "Create tag" -command mktag 604 $rowctxmenu add command -label "Create tag" -command mktag
604 $rowctxmenu add command -label "Write commit to file" -command writecommit 605 $rowctxmenu add command -label "Write commit to file" -command writecommit
606 if { $hgvdiff ne "" } {
607 $rowctxmenu add command -label "Visual diff with parent" \
608 -command {vdiff 1}
609 $rowctxmenu add command -label "Visual diff with selected" \
610 -command {vdiff 0}
611 }
605 } 612 }
606 613
607 # when we make a key binding for the toplevel, make sure 614 # when we make a key binding for the toplevel, make sure
608 # it doesn't get triggered when that key is pressed in the 615 # it doesn't get triggered when that key is pressed in the
609 # find string entry widget. 616 # find string entry widget.
3371 } 3378 }
3372 return [format "%.3f" [expr {([clock click -milliseconds] - $startmstime) / 1000.0}]] 3379 return [format "%.3f" [expr {([clock click -milliseconds] - $startmstime) / 1000.0}]]
3373 } 3380 }
3374 3381
3375 proc rowmenu {x y id} { 3382 proc rowmenu {x y id} {
3376 global rowctxmenu idline selectedline rowmenuid 3383 global rowctxmenu idline selectedline rowmenuid hgvdiff
3377 3384
3378 if {![info exists selectedline] || $idline($id) eq $selectedline} { 3385 if {![info exists selectedline] || $idline($id) eq $selectedline} {
3379 set state disabled 3386 set state disabled
3380 } else { 3387 } else {
3381 set state normal 3388 set state normal
3382 } 3389 }
3383 $rowctxmenu entryconfigure 0 -state $state 3390 $rowctxmenu entryconfigure 0 -state $state
3384 $rowctxmenu entryconfigure 1 -state $state 3391 $rowctxmenu entryconfigure 1 -state $state
3385 $rowctxmenu entryconfigure 2 -state $state 3392 $rowctxmenu entryconfigure 2 -state $state
3393 if { $hgvdiff ne "" } {
3394 $rowctxmenu entryconfigure 6 -state $state
3395 }
3386 set rowmenuid $id 3396 set rowmenuid $id
3387 tk_popup $rowctxmenu $x $y 3397 tk_popup $rowctxmenu $x $y
3388 } 3398 }
3389 3399
3390 proc diffvssel {dirn} { 3400 proc diffvssel {dirn} {
3693 redrawtags $id 3703 redrawtags $id
3694 } 3704 }
3695 } 3705 }
3696 } 3706 }
3697 3707
3708 proc vdiff {withparent} {
3709 global env rowmenuid selectedline lineid
3710
3711 if {![info exists rowmenuid]} return
3712 set curid $rowmenuid
3713
3714 if {$withparent} {
3715 set parents [exec $env(HG) --config ui.report_untrusted=false parents --rev $curid --template "{node}\n"]
3716 set firstparent [lindex [split $parents "\n"] 0]
3717 set otherid $firstparent
3718 } else {
3719 if {![info exists selectedline]} return
3720 set otherid $lineid($selectedline)
3721 }
3722 set range "$otherid:$curid"
3723 if {[catch {exec $env(HG) --config ui.report_untrusted=false vdiff -r $range} err]} {
3724 # Ignore errors, this is just visualization
3725 }
3726 }
3727
3698 proc showtag {tag isnew} { 3728 proc showtag {tag isnew} {
3699 global ctext cflist tagcontents tagids linknum 3729 global ctext cflist tagcontents tagids linknum
3700 3730
3701 if {$isnew} { 3731 if {$isnew} {
3702 addtohistory [list showtag $tag 0] 3732 addtohistory [list showtag $tag 0]
3772 3802
3773 set stopped 0 3803 set stopped 0
3774 set redisplaying 0 3804 set redisplaying 0
3775 set stuffsaved 0 3805 set stuffsaved 0
3776 set patchnum 0 3806 set patchnum 0
3807
3808 array set config [getconfig]
3809 set hgvdiff $config(vdiff)
3777 setcoords 3810 setcoords
3778 makewindow 3811 makewindow
3779 readrefs 3812 readrefs
3780 set hgroot [exec $env(HG) root] 3813 set hgroot [exec $env(HG) root]
3781 wm title . "hgk $hgroot" 3814 wm title . "hgk $hgroot"