Skip to content

Commit d59a604

Browse files
author
Junio C Hamano
committed
Merge with gitk.
This merges commit fa4da7b from gitk into our head commit 6b7242a Sincerely, jit-merge command.
2 parents 6b7242a + fa4da7b commit d59a604

File tree

1 file changed

+92
-41
lines changed

1 file changed

+92
-41
lines changed

gitk

Lines changed: 92 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ proc bindline {t id} {
715715
$canv bind $t <Enter> "lineenter %x %y $id"
716716
$canv bind $t <Motion> "linemotion %x %y $id"
717717
$canv bind $t <Leave> "lineleave $id"
718-
$canv bind $t <Button-1> "lineclick %x %y $id"
718+
$canv bind $t <Button-1> "lineclick %x %y $id 1"
719719
}
720720

721721
proc drawcommitline {level} {
@@ -1687,7 +1687,7 @@ proc unmarkmatches {} {
16871687
}
16881688

16891689
proc selcanvline {w x y} {
1690-
global canv canvy0 ctext linespc selectedline
1690+
global canv canvy0 ctext linespc
16911691
global lineid linehtag linentag linedtag rowtextx
16921692
set ymax [lindex [$canv cget -scrollregion] 3]
16931693
if {$ymax == {}} return
@@ -1710,7 +1710,6 @@ proc selectline {l isnew} {
17101710
global canvy0 linespc parents nparents
17111711
global cflist currentid sha1entry
17121712
global commentend idtags idline
1713-
global history historyindex
17141713

17151714
$canv delete hover
17161715
if {![info exists lineid($l)] || ![info exists linehtag($l)]} return
@@ -1761,19 +1760,8 @@ proc selectline {l isnew} {
17611760
allcanvs yview moveto [expr $newtop * 1.0 / $ymax]
17621761
}
17631762

1764-
if {$isnew && (![info exists selectedline] || $selectedline != $l)} {
1765-
if {$historyindex < [llength $history]} {
1766-
set history [lreplace $history $historyindex end $l]
1767-
} else {
1768-
lappend history $l
1769-
}
1770-
incr historyindex
1771-
if {$historyindex > 1} {
1772-
.ctop.top.bar.leftbut conf -state normal
1773-
} else {
1774-
.ctop.top.bar.leftbut conf -state disabled
1775-
}
1776-
.ctop.top.bar.rightbut conf -state disabled
1763+
if {$isnew} {
1764+
addtohistory [list selectline $l 0]
17771765
}
17781766

17791767
set selectedline $l
@@ -1799,9 +1787,21 @@ proc selectline {l isnew} {
17991787
}
18001788
$ctext insert end "\n"
18011789
}
1802-
$ctext insert end "\n"
1790+
18031791
set commentstart [$ctext index "end - 1c"]
1804-
set comment [lindex $info 5]
1792+
set comment {}
1793+
foreach p $parents($id) {
1794+
set l "..."
1795+
if {[info exists commitinfo($p)]} {
1796+
set l [lindex $commitinfo($p) 0]
1797+
if {[string length $l] > 32} {
1798+
set l "[string range $l 0 28] ..."
1799+
}
1800+
}
1801+
append comment "Parent: $p ($l)\n"
1802+
}
1803+
append comment "\n"
1804+
append comment [lindex $info 5]
18051805
$ctext insert end $comment
18061806
$ctext insert end "\n"
18071807

@@ -1845,12 +1845,42 @@ proc selnextline {dir} {
18451845
selectline $l 1
18461846
}
18471847

1848+
proc unselectline {} {
1849+
global selectedline
1850+
1851+
catch {unset selectedline}
1852+
allcanvs delete secsel
1853+
}
1854+
1855+
proc addtohistory {cmd} {
1856+
global history historyindex
1857+
1858+
if {$historyindex > 0
1859+
&& [lindex $history [expr {$historyindex - 1}]] == $cmd} {
1860+
return
1861+
}
1862+
1863+
if {$historyindex < [llength $history]} {
1864+
set history [lreplace $history $historyindex end $cmd]
1865+
} else {
1866+
lappend history $cmd
1867+
}
1868+
incr historyindex
1869+
if {$historyindex > 1} {
1870+
.ctop.top.bar.leftbut conf -state normal
1871+
} else {
1872+
.ctop.top.bar.leftbut conf -state disabled
1873+
}
1874+
.ctop.top.bar.rightbut conf -state disabled
1875+
}
1876+
18481877
proc goback {} {
18491878
global history historyindex
18501879

18511880
if {$historyindex > 1} {
18521881
incr historyindex -1
1853-
selectline [lindex $history [expr {$historyindex - 1}]] 0
1882+
set cmd [lindex $history [expr {$historyindex - 1}]]
1883+
eval $cmd
18541884
.ctop.top.bar.rightbut conf -state normal
18551885
}
18561886
if {$historyindex <= 1} {
@@ -1862,9 +1892,9 @@ proc goforw {} {
18621892
global history historyindex
18631893

18641894
if {$historyindex < [llength $history]} {
1865-
set l [lindex $history $historyindex]
1895+
set cmd [lindex $history $historyindex]
18661896
incr historyindex
1867-
selectline $l 0
1897+
eval $cmd
18681898
.ctop.top.bar.leftbut conf -state normal
18691899
}
18701900
if {$historyindex >= [llength $history]} {
@@ -2612,7 +2642,7 @@ proc setcoords {} {
26122642
}
26132643

26142644
proc redisplay {} {
2615-
global selectedline stopped redisplaying phase
2645+
global stopped redisplaying phase
26162646
if {$stopped > 1} return
26172647
if {$phase == "getcommits"} return
26182648
set redisplaying 1
@@ -2624,7 +2654,7 @@ proc redisplay {} {
26242654
}
26252655

26262656
proc incrfont {inc} {
2627-
global mainfont namefont textfont selectedline ctext canv phase
2657+
global mainfont namefont textfont ctext canv phase
26282658
global stopped entries
26292659
unmarkmatches
26302660
set mainfont [lreplace $mainfont 1 1 [expr {[lindex $mainfont 1] + $inc}]]
@@ -2766,34 +2796,40 @@ proc linehover {} {
27662796
$canv raise $t
27672797
}
27682798

2769-
proc lineclick {x y id} {
2799+
proc lineclick {x y id isnew} {
27702800
global ctext commitinfo children cflist canv
27712801

27722802
unmarkmatches
2803+
unselectline
2804+
if {$isnew} {
2805+
addtohistory [list lineclick $x $x $id 0]
2806+
}
27732807
$canv delete hover
27742808
# fill the details pane with info about this line
27752809
$ctext conf -state normal
27762810
$ctext delete 0.0 end
2777-
$ctext insert end "Parent:\n "
2778-
catch {destroy $ctext.$id}
2779-
button $ctext.$id -text "Go:" -command "selbyid $id" \
2780-
-padx 4 -pady 0
2781-
$ctext window create end -window $ctext.$id -align center
2811+
$ctext tag conf link -foreground blue -underline 1
2812+
$ctext tag bind link <Enter> { %W configure -cursor hand2 }
2813+
$ctext tag bind link <Leave> { %W configure -cursor $curtextcursor }
2814+
$ctext insert end "Parent:\t"
2815+
$ctext insert end $id [list link link0]
2816+
$ctext tag bind link0 <1> [list selbyid $id]
27822817
set info $commitinfo($id)
2783-
$ctext insert end "\t[lindex $info 0]\n"
2818+
$ctext insert end "\n\t[lindex $info 0]\n"
27842819
$ctext insert end "\tAuthor:\t[lindex $info 1]\n"
27852820
$ctext insert end "\tDate:\t[lindex $info 2]\n"
2786-
$ctext insert end "\tID:\t$id\n"
27872821
if {[info exists children($id)]} {
27882822
$ctext insert end "\nChildren:"
2823+
set i 0
27892824
foreach child $children($id) {
2790-
$ctext insert end "\n "
2791-
catch {destroy $ctext.$child}
2792-
button $ctext.$child -text "Go:" -command "selbyid $child" \
2793-
-padx 4 -pady 0
2794-
$ctext window create end -window $ctext.$child -align center
2825+
incr i
27952826
set info $commitinfo($child)
2796-
$ctext insert end "\t[lindex $info 0]"
2827+
$ctext insert end "\n\t"
2828+
$ctext insert end $child [list link link$i]
2829+
$ctext tag bind link$i <1> [list selbyid $child]
2830+
$ctext insert end "\n\t[lindex $info 0]"
2831+
$ctext insert end "\n\tAuthor:\t[lindex $info 1]"
2832+
$ctext insert end "\n\tDate:\t[lindex $info 2]\n"
27972833
}
27982834
}
27992835
$ctext conf -state disabled
@@ -2833,8 +2869,6 @@ proc rowmenu {x y id} {
28332869

28342870
proc diffvssel {dirn} {
28352871
global rowmenuid selectedline lineid
2836-
global ctext cflist
2837-
global commitinfo
28382872

28392873
if {![info exists selectedline]} return
28402874
if {$dirn} {
@@ -2844,15 +2878,32 @@ proc diffvssel {dirn} {
28442878
set oldid $rowmenuid
28452879
set newid $lineid($selectedline)
28462880
}
2881+
addtohistory [list doseldiff $oldid $newid]
2882+
doseldiff $oldid $newid
2883+
}
2884+
2885+
proc doseldiff {oldid newid} {
2886+
global ctext cflist
2887+
global commitinfo
2888+
28472889
$ctext conf -state normal
28482890
$ctext delete 0.0 end
28492891
$ctext mark set fmark.0 0.0
28502892
$ctext mark gravity fmark.0 left
28512893
$cflist delete 0 end
28522894
$cflist insert end "Top"
2853-
$ctext insert end "From $oldid\n "
2895+
$ctext insert end "From "
2896+
$ctext tag conf link -foreground blue -underline 1
2897+
$ctext tag bind link <Enter> { %W configure -cursor hand2 }
2898+
$ctext tag bind link <Leave> { %W configure -cursor $curtextcursor }
2899+
$ctext tag bind link0 <1> [list selbyid $oldid]
2900+
$ctext insert end $oldid [list link link0]
2901+
$ctext insert end "\n "
28542902
$ctext insert end [lindex $commitinfo($oldid) 0]
2855-
$ctext insert end "\n\nTo $newid\n "
2903+
$ctext insert end "\n\nTo "
2904+
$ctext tag bind link1 <1> [list selbyid $newid]
2905+
$ctext insert end $newid [list link link1]
2906+
$ctext insert end "\n "
28562907
$ctext insert end [lindex $commitinfo($newid) 0]
28572908
$ctext insert end "\n"
28582909
$ctext conf -state disabled

0 commit comments

Comments
 (0)