Merge git://git.kernel.org/pub/scm/gitk/gitk

* git://git.kernel.org/pub/scm/gitk/gitk:
  gitk: Add Russian translation
  gitk: Fix compare-commits function when we have local changes
  gitk: Avoid crash if closed while reading references
  gitk: Handle external diff tool with spaces in the path
  gitk: Remember and restore the window state with the geometry
  gitk: Map KP_Divide to focus the search box
  gitk: Mark some more strings for translation
  gitk: Mark forgotten string for translation
  gitk: Make .gitk a hidden file under windows
  gitk: Add a command to compare two strings of commits
  gitk: Add a way to mark a commit, plus a "find descendant" command
  gitk: Fixes for Mac OS X TkAqua
  gitk: Provide a 32x32 window icon based on the git logo
  gitk: Provide a window icon if possible
  gitk: Handle blobs containing a DOS end-of-file marker
This commit is contained in:
Junio C Hamano 2009-04-30 19:56:28 -07:00
commit 75b44066f3
2 changed files with 1381 additions and 25 deletions

View file

@ -521,7 +521,7 @@ proc updatecommits {} {
incr viewactive($view)
set viewcomplete($view) 0
reset_pending_select {}
nowbusy $view "Reading"
nowbusy $view [mc "Reading"]
if {$showneartags} {
getallcommits
}
@ -1830,7 +1830,9 @@ proc setoptions {} {
option add *Button.font uifont startupFile
option add *Checkbutton.font uifont startupFile
option add *Radiobutton.font uifont startupFile
option add *Menu.font uifont startupFile
if {[tk windowingsystem] ne "aqua"} {
option add *Menu.font uifont startupFile
}
option add *Menubutton.font uifont startupFile
option add *Label.font uifont startupFile
option add *Message.font uifont startupFile
@ -1910,8 +1912,8 @@ proc makewindow {} {
# The "mc" arguments here are purely so that xgettext
# sees the following string as needing to be translated
makemenu .bar {
{mc "File" cascade {
set file {
mc "File" cascade {
{mc "Update" command updatecommits -accelerator F5}
{mc "Reload" command reloadcommits -accelerator Meta1-F5}
{mc "Reread references" command rereadrefs}
@ -1921,21 +1923,41 @@ proc makewindow {} {
{xx "" separator}
{mc "Quit" command doquit -accelerator Meta1-Q}
}}
{mc "Edit" cascade {
set edit {
mc "Edit" cascade {
{mc "Preferences" command doprefs}
}}
{mc "View" cascade {
set view {
mc "View" cascade {
{mc "New view..." command {newview 0} -accelerator Shift-F4}
{mc "Edit view..." command editview -state disabled -accelerator F4}
{mc "Delete view" command delview -state disabled}
{xx "" separator}
{mc "All files" radiobutton {selectedview 0} -command {showview 0}}
}}
{mc "Help" cascade {
if {[tk windowingsystem] ne "aqua"} {
set help {
mc "Help" cascade {
{mc "About gitk" command about}
{mc "Key bindings" command keys}
}}
set bar [list $file $edit $view $help]
} else {
proc ::tk::mac::ShowPreferences {} {doprefs}
proc ::tk::mac::Quit {} {doquit}
lset file end [lreplace [lindex $file end] end-1 end]
set apple {
xx "Apple" cascade {
{mc "About gitk" command about}
{xx "" separator}
}}
set help {
mc "Help" cascade {
{mc "Key bindings" command keys}
}}
set bar [list $apple $file $view $help]
}
makemenu .bar $bar
. configure -menu .bar
# the gui has upper and lower half, parts of a paned window.
@ -2229,10 +2251,16 @@ proc makewindow {} {
}
}
if {[info exists geometry(state)] && $geometry(state) eq "zoomed"} {
wm state . $geometry(state)
}
if {[tk windowingsystem] eq {aqua}} {
set M1B M1
set ::BM "3"
} else {
set M1B Control
set ::BM "2"
}
bind .pwbottom <Configure> {resizecdetpanes %W %w}
@ -2250,10 +2278,14 @@ proc makewindow {} {
set delta [expr {- (%D)}]
allcanvs yview scroll $delta units
}
bindall <Shift-MouseWheel> {
set delta [expr {- (%D)}]
$canv xview scroll $delta units
}
}
}
bindall <2> "canvscan mark %W %x %y"
bindall <B2-Motion> "canvscan dragto %W %x %y"
bindall <$::BM> "canvscan mark %W %x %y"
bindall <B$::BM-Motion> "canvscan dragto %W %x %y"
bindkey <Home> selfirstline
bindkey <End> sellastline
bind . <Key-Up> "selnextline -1"
@ -2285,6 +2317,7 @@ proc makewindow {} {
bindkey d "$ctext yview scroll 18 units"
bindkey u "$ctext yview scroll -18 units"
bindkey / {focus $fstring}
bindkey <Key-KP_Divide> {focus $fstring}
bindkey <Key-Return> {dofind 1 1}
bindkey ? {dofind -1 1}
bindkey f nextfile
@ -2331,6 +2364,10 @@ proc makewindow {} {
{mc "Create new branch" command mkbranch}
{mc "Cherry-pick this commit" command cherrypick}
{mc "Reset HEAD branch to here" command resethead}
{mc "Mark this commit" command markhere}
{mc "Return to mark" command gotomark}
{mc "Find descendant of this and mark" command find_common_desc}
{mc "Compare with marked commit" command compare_commits}
}
$rowctxmenu configure -tearoff 0
@ -2487,6 +2524,9 @@ proc savestuff {w} {
if {![winfo viewable .]} return
catch {
set f [open "~/.gitk-new" w]
if {$::tcl_platform(platform) eq {windows}} {
file attributes "~/.gitk-new" -hidden true
}
puts $f [list set mainfont $mainfont]
puts $f [list set textfont $textfont]
puts $f [list set uifont $uifont]
@ -2512,6 +2552,7 @@ proc savestuff {w} {
puts $f [list set perfile_attrs $perfile_attrs]
puts $f "set geometry(main) [wm geometry .]"
puts $f "set geometry(state) [wm state .]"
puts $f "set geometry(topwidth) [winfo width .tf]"
puts $f "set geometry(topheight) [winfo height .tf]"
puts $f "set geometry(pwsash0) \"[.tf.histframe.pwclist sash coord 0]\""
@ -3204,9 +3245,8 @@ proc external_diff {} {
set difftofile [external_diff_get_one_file $diffidto $flist_menu_file $diffdir]
if {$difffromfile ne {} && $difftofile ne {}} {
set cmd [concat | [shellsplit $extdifftool] \
[list $difffromfile $difftofile]]
if {[catch {set fl [open $cmd r]} err]} {
set cmd [list [shellsplit $extdifftool] $difffromfile $difftofile]
if {[catch {set fl [open |$cmd r]} err]} {
file delete -force $diffdir
error_popup "$extdifftool: [mc "command failed:"] $err"
} else {
@ -3737,7 +3777,7 @@ proc editview {} {
set newviewopts($curview,perm) $viewperm($curview)
set newviewopts($curview,cmd) $viewargscmd($curview)
decode_view_opts $curview $viewargs($curview)
vieweditor $top $curview "Gitk: edit view $viewname($curview)"
vieweditor $top $curview "[mc "Gitk: edit view"] $viewname($curview)"
}
proc vieweditor {top n title} {
@ -4046,7 +4086,7 @@ proc ishighlighted {id} {
}
proc bolden {id font} {
global canv linehtag currentid boldids need_redisplay
global canv linehtag currentid boldids need_redisplay markedid
# need_redisplay = 1 means the display is stale and about to be redrawn
if {$need_redisplay} return
@ -4059,6 +4099,9 @@ proc bolden {id font} {
-fill [$canv cget -selectbackground]]
$canv lower $t
}
if {[info exists markedid] && $id eq $markedid} {
make_idmark $id
}
}
proc bolden_name {id font} {
@ -5563,7 +5606,7 @@ proc drawcmittext {id row col} {
global cmitlisted commitinfo rowidlist parentlist
global rowtextx idpos idtags idheads idotherrefs
global linehtag linentag linedtag selectedline
global canvxmax boldids boldnameids fgcolor
global canvxmax boldids boldnameids fgcolor markedid
global mainheadid nullid nullid2 circleitem circlecolors ctxbut
# listed is 0 for boundary, 1 for normal, 2 for negative, 3 for left, 4 for right
@ -5645,6 +5688,9 @@ proc drawcmittext {id row col} {
if {$selectedline == $row} {
make_secsel $id
}
if {[info exists markedid] && $markedid eq $id} {
make_idmark $id
}
set xr [expr {$xt + [font measure $font $headline]}]
if {$xr > $canvxmax} {
set canvxmax $xr
@ -6443,6 +6489,17 @@ proc setlink {id lk} {
}
}
proc appendshortlink {id {pre {}} {post {}}} {
global ctext linknum
$ctext insert end $pre
$ctext tag delete link$linknum
$ctext insert end [string range $id 0 7] link$linknum
$ctext insert end $post
setlink $id link$linknum
incr linknum
}
proc makelink {id} {
global pendinglinks
@ -6499,7 +6556,7 @@ proc appendrefs {pos ids var} {
}
}
if {[llength $tags] > $maxrefs} {
$ctext insert $pos "many ([llength $tags])"
$ctext insert $pos "[mc "many"] ([llength $tags])"
} else {
set tags [lsort -index 0 -decreasing $tags]
set sep {}
@ -6586,6 +6643,16 @@ proc make_secsel {id} {
$canv3 lower $t
}
proc make_idmark {id} {
global linehtag canv fgcolor
if {![info exists linehtag($id)]} return
$canv delete markid
set t [eval $canv create rect [$canv bbox $linehtag($id)] \
-tags markid -outline $fgcolor]
$canv raise $t
}
proc selectline {l isnew {desired_loc {}}} {
global canv ctext commitinfo selectedline
global canvy0 linespc parents children curview
@ -7216,7 +7283,7 @@ proc getblobdiffs {ids} {
set diffnparents 0
set diffinhdr 0
set diffencoding [get_path_encoding {}]
fconfigure $bdf -blocking 0 -encoding binary
fconfigure $bdf -blocking 0 -encoding binary -eofchar {}
set blobdifffd($ids) $bdf
filerun $bdf [list getblobdiffline $bdf $diffids]
}
@ -7367,7 +7434,8 @@ proc getblobdiffline {bdf ids} {
$ctext insert end "$line\n" filesep
} else {
set line [encoding convertfrom $diffencoding $line]
set line [string map {\x1A ^Z} \
[encoding convertfrom $diffencoding $line]]
# parse the prefix - one ' ', '-' or '+' for each parent
set prefix [string range $line 0 [expr {$diffnparents - 1}]]
set tag [expr {$diffnparents > 1? "m": "d"}]
@ -7970,7 +8038,7 @@ proc mstime {} {
proc rowmenu {x y id} {
global rowctxmenu selectedline rowmenuid curview
global nullid nullid2 fakerowmenu mainhead
global nullid nullid2 fakerowmenu mainhead markedid
stopfinding
set rowmenuid $id
@ -7986,6 +8054,15 @@ proc rowmenu {x y id} {
} else {
$menu entryconfigure 7 -label [mc "Detached head: can't reset" $mainhead] -state disabled
}
if {[info exists markedid] && $markedid ne $id} {
$menu entryconfigure 9 -state normal
$menu entryconfigure 10 -state normal
$menu entryconfigure 11 -state normal
} else {
$menu entryconfigure 9 -state disabled
$menu entryconfigure 10 -state disabled
$menu entryconfigure 11 -state disabled
}
} else {
set menu $fakerowmenu
}
@ -7995,6 +8072,162 @@ proc rowmenu {x y id} {
tk_popup $menu $x $y
}
proc markhere {} {
global rowmenuid markedid canv
set markedid $rowmenuid
make_idmark $markedid
}
proc gotomark {} {
global markedid
if {[info exists markedid]} {
selbyid $markedid
}
}
proc replace_by_kids {l r} {
global curview children
set id [commitonrow $r]
set l [lreplace $l 0 0]
foreach kid $children($curview,$id) {
lappend l [rowofcommit $kid]
}
return [lsort -integer -decreasing -unique $l]
}
proc find_common_desc {} {
global markedid rowmenuid curview children
if {![info exists markedid]} return
if {![commitinview $markedid $curview] ||
![commitinview $rowmenuid $curview]} return
#set t1 [clock clicks -milliseconds]
set l1 [list [rowofcommit $markedid]]
set l2 [list [rowofcommit $rowmenuid]]
while 1 {
set r1 [lindex $l1 0]
set r2 [lindex $l2 0]
if {$r1 eq {} || $r2 eq {}} break
if {$r1 == $r2} {
selectline $r1 1
break
}
if {$r1 > $r2} {
set l1 [replace_by_kids $l1 $r1]
} else {
set l2 [replace_by_kids $l2 $r2]
}
}
#set t2 [clock clicks -milliseconds]
#puts "took [expr {$t2-$t1}]ms"
}
proc compare_commits {} {
global markedid rowmenuid curview children
if {![info exists markedid]} return
if {![commitinview $markedid $curview]} return
addtohistory [list do_cmp_commits $markedid $rowmenuid]
do_cmp_commits $markedid $rowmenuid
}
proc getpatchid {id} {
global patchids
if {![info exists patchids($id)]} {
set cmd [diffcmd [list $id] {-p --root}]
# trim off the initial "|"
set cmd [lrange $cmd 1 end]
if {[catch {
set x [eval exec $cmd | git patch-id]
set patchids($id) [lindex $x 0]
}]} {
set patchids($id) "error"
}
}
return $patchids($id)
}
proc do_cmp_commits {a b} {
global ctext curview parents children patchids commitinfo
$ctext conf -state normal
clear_ctext
init_flist {}
for {set i 0} {$i < 100} {incr i} {
set skipa 0
set skipb 0
if {[llength $parents($curview,$a)] > 1} {
appendshortlink $a [mc "Skipping merge commit "] "\n"
set skipa 1
} else {
set patcha [getpatchid $a]
}
if {[llength $parents($curview,$b)] > 1} {
appendshortlink $b [mc "Skipping merge commit "] "\n"
set skipb 1
} else {
set patchb [getpatchid $b]
}
if {!$skipa && !$skipb} {
set heada [lindex $commitinfo($a) 0]
set headb [lindex $commitinfo($b) 0]
if {$patcha eq "error"} {
appendshortlink $a [mc "Error getting patch ID for "] \
[mc " - stopping\n"]
break
}
if {$patchb eq "error"} {
appendshortlink $b [mc "Error getting patch ID for "] \
[mc " - stopping\n"]
break
}
if {$patcha eq $patchb} {
if {$heada eq $headb} {
appendshortlink $a [mc "Commit "]
appendshortlink $b " == " " $heada\n"
} else {
appendshortlink $a [mc "Commit "] " $heada\n"
appendshortlink $b [mc " is the same patch as\n "] \
" $headb\n"
}
set skipa 1
set skipb 1
} else {
$ctext insert end "\n"
appendshortlink $a [mc "Commit "] " $heada\n"
appendshortlink $b [mc " differs from\n "] \
" $headb\n"
$ctext insert end [mc "- stopping\n"]
break
}
}
if {$skipa} {
if {[llength $children($curview,$a)] != 1} {
$ctext insert end "\n"
appendshortlink $a [mc "Commit "] \
[mc " has %s children - stopping\n" \
[llength $children($curview,$a)]]
break
}
set a [lindex $children($curview,$a) 0]
}
if {$skipb} {
if {[llength $children($curview,$b)] != 1} {
appendshortlink $b [mc "Commit "] \
[mc " has %s children - stopping\n" \
[llength $children($curview,$b)]]
break
}
set b [lindex $children($curview,$b) 0]
}
}
$ctext conf -state disabled
}
proc diffvssel {dirn} {
global rowmenuid selectedline
@ -8189,7 +8422,7 @@ proc domktag {} {
}
proc redrawtags {id} {
global canv linehtag idpos currentid curview cmitlisted
global canv linehtag idpos currentid curview cmitlisted markedid
global canvxmax iddrawn circleitem mainheadid circlecolors
if {![commitinview $id $curview]} return
@ -8214,6 +8447,9 @@ proc redrawtags {id} {
if {[info exists currentid] && $currentid == $id} {
make_secsel $id
}
if {[info exists markedid] && $markedid eq $id} {
make_idmark $id
}
}
proc mktagcan {} {
@ -10197,7 +10433,7 @@ proc doprefs {} {
proc choose_extdiff {} {
global extdifftool
set prog [tk_getOpenFile -title "External diff tool" -multiple false]
set prog [tk_getOpenFile -title [mc "External diff tool"] -multiple false]
if {$prog ne {}} {
set extdifftool $prog
}
@ -10240,6 +10476,7 @@ proc setfg {c} {
}
allcanvs itemconf text -fill $c
$canv itemconf circle -outline $c
$canv itemconf markid -outline $c
}
proc prefscan {} {
@ -10689,9 +10926,15 @@ catch {
}
}
set mainfont {Helvetica 9}
set textfont {Courier 9}
set uifont {Helvetica 9 bold}
if {[tk windowingsystem] eq "aqua"} {
set mainfont {{Lucida Grande} 9}
set textfont {Monaco 9}
set uifont {{Lucida Grande} 9 bold}
} else {
set mainfont {Helvetica 9}
set textfont {Courier 9}
set uifont {Helvetica 9 bold}
}
set tabstop 8
set findmergefiles 0
set maxgraphpct 50
@ -10712,7 +10955,11 @@ set datetimeformat "%Y-%m-%d %H:%M:%S"
set autoselect 1
set perfile_attrs 0
set extdifftool "meld"
if {[tk windowingsystem] eq "aqua"} {
set extdifftool "opendiff"
} else {
set extdifftool "meld"
}
set colors {green red blue magenta darkgrey brown orange}
set bgcolor white
@ -10883,9 +11130,33 @@ set lserial 0
set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == "true"}]
setcoords
makewindow
catch {
image create photo gitlogo -width 16 -height 16
image create photo gitlogominus -width 4 -height 2
gitlogominus put #C00000 -to 0 0 4 2
gitlogo copy gitlogominus -to 1 5
gitlogo copy gitlogominus -to 6 5
gitlogo copy gitlogominus -to 11 5
image delete gitlogominus
image create photo gitlogoplus -width 4 -height 4
gitlogoplus put #008000 -to 1 0 3 4
gitlogoplus put #008000 -to 0 1 4 3
gitlogo copy gitlogoplus -to 1 9
gitlogo copy gitlogoplus -to 6 9
gitlogo copy gitlogoplus -to 11 9
image delete gitlogoplus
image create photo gitlogo32 -width 32 -height 32
gitlogo32 copy gitlogo -zoom 2 2
wm iconphoto . -default gitlogo gitlogo32
}
# wait for the window to become visible
tkwait visibility .
wm title . "[file tail $argv0]: [file tail [pwd]]"
update
readrefs
if {$cmdline_files ne {} || $revtreeargs ne {} || $revtreeargscmd ne {}} {

1085
gitk-git/po/ru.po Normal file

File diff suppressed because it is too large Load diff