Merge branch 'master' into dev

This commit is contained in:
Paul Mackerras 2007-10-23 22:40:50 +10:00
commit 3de07118f0

148
gitk
View File

@ -95,7 +95,7 @@ proc start_rev_list {view} {
set order "--date-order" set order "--date-order"
} }
if {[catch { if {[catch {
set fd [open [concat | git log -z --pretty=raw $order --parents \ set fd [open [concat | git log --no-color -z --pretty=raw $order --parents \
--boundary $viewargs($view) "--" $viewfiles($view)] r] --boundary $viewargs($view) "--" $viewfiles($view)] r]
} err]} { } err]} {
error_popup "Error executing git rev-list: $err" error_popup "Error executing git rev-list: $err"
@ -946,6 +946,12 @@ proc makewindow {} {
} else { } else {
bindall <ButtonRelease-4> "allcanvs yview scroll -5 units" bindall <ButtonRelease-4> "allcanvs yview scroll -5 units"
bindall <ButtonRelease-5> "allcanvs yview scroll 5 units" bindall <ButtonRelease-5> "allcanvs yview scroll 5 units"
if {[tk windowingsystem] eq "aqua"} {
bindall <MouseWheel> {
set delta [expr {- (%D)}]
allcanvs yview scroll $delta units
}
}
} }
bindall <2> "canvscan mark %W %x %y" bindall <2> "canvscan mark %W %x %y"
bindall <B2-Motion> "canvscan dragto %W %x %y" bindall <B2-Motion> "canvscan dragto %W %x %y"
@ -1147,7 +1153,7 @@ proc savestuff {w} {
global stuffsaved findmergefiles maxgraphpct global stuffsaved findmergefiles maxgraphpct
global maxwidth showneartags showlocalchanges global maxwidth showneartags showlocalchanges
global viewname viewfiles viewargs viewperm nextviewnum global viewname viewfiles viewargs viewperm nextviewnum
global cmitmode wrapcomment datetimeformat global cmitmode wrapcomment datetimeformat limitdiffs
global colors bgcolor fgcolor diffcolors diffcontext selectbgcolor global colors bgcolor fgcolor diffcolors diffcontext selectbgcolor
if {$stuffsaved} return if {$stuffsaved} return
@ -1166,6 +1172,7 @@ proc savestuff {w} {
puts $f [list set showneartags $showneartags] puts $f [list set showneartags $showneartags]
puts $f [list set showlocalchanges $showlocalchanges] puts $f [list set showlocalchanges $showlocalchanges]
puts $f [list set datetimeformat $datetimeformat] puts $f [list set datetimeformat $datetimeformat]
puts $f [list set limitdiffs $limitdiffs]
puts $f [list set bgcolor $bgcolor] puts $f [list set bgcolor $bgcolor]
puts $f [list set fgcolor $fgcolor] puts $f [list set fgcolor $fgcolor]
puts $f [list set colors $colors] puts $f [list set colors $colors]
@ -3813,34 +3820,23 @@ proc drawcommits {row {endrow {}}} {
drawcmitrow $r drawcmitrow $r
if {$r == $er} break if {$r == $er} break
set nextid [lindex $displayorder [expr {$r + 1}]] set nextid [lindex $displayorder [expr {$r + 1}]]
if {$wasdrawn && [info exists iddrawn($nextid)]} { if {$wasdrawn && [info exists iddrawn($nextid)]} continue
catch {unset prevlines}
continue
}
drawparentlinks $id $r drawparentlinks $id $r
if {[info exists lineends($r)]} {
foreach lid $lineends($r) {
unset prevlines($lid)
}
}
set rowids [lindex $rowidlist $r] set rowids [lindex $rowidlist $r]
foreach lid $rowids { foreach lid $rowids {
if {$lid eq {}} continue if {$lid eq {}} continue
if {[info exists lineend($lid)] && $lineend($lid) > $r} continue
if {$lid eq $id} { if {$lid eq $id} {
# see if this is the first child of any of its parents # see if this is the first child of any of its parents
foreach p [lindex $parentlist $r] { foreach p [lindex $parentlist $r] {
if {[lsearch -exact $rowids $p] < 0} { if {[lsearch -exact $rowids $p] < 0} {
# make this line extend up to the child # make this line extend up to the child
set le [drawlineseg $p $r $er 0] set lineend($p) [drawlineseg $p $r $er 0]
lappend lineends($le) $p
set prevlines($p) 1
} }
} }
} elseif {![info exists prevlines($lid)]} { } else {
set le [drawlineseg $lid $r $er 1] set lineend($lid) [drawlineseg $lid $r $er 1]
lappend lineends($le) $lid
set prevlines($lid) 1
} }
} }
} }
@ -5137,11 +5133,15 @@ proc mergediff {id l} {
global diffmergeid mdifffd global diffmergeid mdifffd
global diffids global diffids
global parentlist global parentlist
global limitdiffs viewfiles curview
set diffmergeid $id set diffmergeid $id
set diffids $id set diffids $id
# this doesn't seem to actually affect anything... # this doesn't seem to actually affect anything...
set cmd [concat | git diff-tree --no-commit-id --cc $id] set cmd [concat | git diff-tree --no-commit-id --cc $id]
if {$limitdiffs && $viewfiles($curview) ne {}} {
set cmd [concat $cmd -- $viewfiles($curview)]
}
if {[catch {set mdf [open $cmd r]} err]} { if {[catch {set mdf [open $cmd r]} err]} {
error_popup "Error getting merge diffs: $err" error_popup "Error getting merge diffs: $err"
return return
@ -5241,9 +5241,31 @@ proc startdiff {ids} {
} }
} }
proc path_filter {filter name} {
foreach p $filter {
set l [string length $p]
if {[string compare -length $l $p $name] == 0 &&
([string length $name] == $l || [string index $name $l] eq "/")} {
return 1
}
}
return 0
}
proc addtocflist {ids} { proc addtocflist {ids} {
global treediffs cflist global treediffs cflist viewfiles curview limitdiffs
add_flist $treediffs($ids)
if {$limitdiffs && $viewfiles($curview) ne {}} {
set flist {}
foreach f $treediffs($ids) {
if {[path_filter $viewfiles($curview) $f]} {
lappend flist $f
}
}
} else {
set flist $treediffs($ids)
}
add_flist $flist
getblobdiffs $ids getblobdiffs $ids
} }
@ -5350,8 +5372,13 @@ proc getblobdiffs {ids} {
global blobdifffd diffids env global blobdifffd diffids env
global diffinhdr treediffs global diffinhdr treediffs
global diffcontext global diffcontext
global limitdiffs viewfiles curview
if {[catch {set bdf [open [diffcmd $ids "-p -C --no-commit-id -U$diffcontext"] r]} err]} { set cmd [diffcmd $ids "-p -C --no-commit-id -U$diffcontext"]
if {$limitdiffs && $viewfiles($curview) ne {}} {
set cmd [concat $cmd -- $viewfiles($curview)]
}
if {[catch {set bdf [open $cmd r]} err]} {
puts "error getting diffs: $err" puts "error getting diffs: $err"
return return
} }
@ -5435,8 +5462,7 @@ proc getblobdiffline {bdf ids} {
set diffinhdr 0 set diffinhdr 0
} elseif {$diffinhdr} { } elseif {$diffinhdr} {
if {![string compare -length 12 "rename from " $line] || if {![string compare -length 12 "rename from " $line]} {
![string compare -length 10 "copy from " $line]} {
set fname [string range $line [expr 6 + [string first " from " $line] ] end] set fname [string range $line [expr 6 + [string first " from " $line] ] end]
if {[string index $fname 0] eq "\""} { if {[string index $fname 0] eq "\""} {
set fname [lindex $fname 0] set fname [lindex $fname 0]
@ -6973,7 +6999,7 @@ proc addnewchild {id p} {
global arcnos arcids arctags arcout arcend arcstart archeads growing global arcnos arcids arctags arcout arcend arcstart archeads growing
global seeds allcommits global seeds allcommits
if {![info exists allcommits]} return if {![info exists allcommits] || ![info exists arcnos($p)]} return
set allparents($id) [list $p] set allparents($id) [list $p]
set allchildren($id) {} set allchildren($id) {}
set arcnos($id) {} set arcnos($id) {}
@ -8007,7 +8033,7 @@ proc doprefs {} {
global maxwidth maxgraphpct global maxwidth maxgraphpct
global oldprefs prefstop showneartags showlocalchanges global oldprefs prefstop showneartags showlocalchanges
global bgcolor fgcolor ctext diffcolors selectbgcolor global bgcolor fgcolor ctext diffcolors selectbgcolor
global uifont tabstop global uifont tabstop limitdiffs
set top .gitkprefs set top .gitkprefs
set prefstop $top set prefstop $top
@ -8015,7 +8041,8 @@ proc doprefs {} {
raise $top raise $top
return return
} }
foreach v {maxwidth maxgraphpct showneartags showlocalchanges} { foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
limitdiffs tabstop} {
set oldprefs($v) [set $v] set oldprefs($v) [set $v]
} }
toplevel $top toplevel $top
@ -8041,14 +8068,19 @@ proc doprefs {} {
label $top.ddisp -text "Diff display options" label $top.ddisp -text "Diff display options"
$top.ddisp configure -font uifont $top.ddisp configure -font uifont
grid $top.ddisp - -sticky w -pady 10 grid $top.ddisp - -sticky w -pady 10
label $top.tabstopl -text "Tab spacing" -font optionfont
spinbox $top.tabstop -from 1 -to 20 -width 4 -textvariable tabstop
grid x $top.tabstopl $top.tabstop -sticky w
frame $top.ntag frame $top.ntag
label $top.ntag.l -text "Display nearby tags" -font optionfont label $top.ntag.l -text "Display nearby tags" -font optionfont
checkbutton $top.ntag.b -variable showneartags checkbutton $top.ntag.b -variable showneartags
pack $top.ntag.b $top.ntag.l -side left pack $top.ntag.b $top.ntag.l -side left
grid x $top.ntag -sticky w grid x $top.ntag -sticky w
label $top.tabstopl -text "tabstop" -font optionfont frame $top.ldiff
spinbox $top.tabstop -from 1 -to 20 -width 4 -textvariable tabstop label $top.ldiff.l -text "Limit diffs to listed paths" -font optionfont
grid x $top.tabstopl $top.tabstop -sticky w checkbutton $top.ldiff.b -variable limitdiffs
pack $top.ldiff.b $top.ldiff.l -side left
grid x $top.ldiff -sticky w
label $top.cdisp -text "Colors: press to choose" label $top.cdisp -text "Colors: press to choose"
$top.cdisp configure -font uifont $top.cdisp configure -font uifont
@ -8141,10 +8173,11 @@ proc setfg {c} {
} }
proc prefscan {} { proc prefscan {} {
global maxwidth maxgraphpct global oldprefs prefstop
global oldprefs prefstop showneartags showlocalchanges
foreach v {maxwidth maxgraphpct showneartags showlocalchanges} { foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
limitdiffs tabstop} {
global $v
set $v $oldprefs($v) set $v $oldprefs($v)
} }
catch {destroy $prefstop} catch {destroy $prefstop}
@ -8156,6 +8189,7 @@ proc prefsok {} {
global maxwidth maxgraphpct global maxwidth maxgraphpct
global oldprefs prefstop showneartags showlocalchanges global oldprefs prefstop showneartags showlocalchanges
global fontpref mainfont textfont uifont global fontpref mainfont textfont uifont
global limitdiffs
catch {destroy $prefstop} catch {destroy $prefstop}
unset prefstop unset prefstop
@ -8191,7 +8225,8 @@ proc prefsok {} {
if {$fontchanged || $maxwidth != $oldprefs(maxwidth) if {$fontchanged || $maxwidth != $oldprefs(maxwidth)
|| $maxgraphpct != $oldprefs(maxgraphpct)} { || $maxgraphpct != $oldprefs(maxgraphpct)} {
redisplay redisplay
} elseif {$showneartags != $oldprefs(showneartags)} { } elseif {$showneartags != $oldprefs(showneartags) ||
$limitdiffs != $oldprefs(limitdiffs)} {
reselectline reselectline
} }
} }
@ -8477,6 +8512,13 @@ proc tcl_encoding {enc} {
return {} return {}
} }
# First check that Tcl/Tk is recent enough
if {[catch {package require Tk 8.4} err]} {
show_error {} . "Sorry, gitk cannot run with this version of Tcl/Tk.\n\
Gitk requires at least Tcl/Tk 8.4."
exit 1
}
# defaults... # defaults...
set datemode 0 set datemode 0
set wrcomcmd "git diff-tree --stdin -p --pretty" set wrcomcmd "git diff-tree --stdin -p --pretty"
@ -8511,6 +8553,7 @@ set showneartags 1
set maxrefs 20 set maxrefs 20
set maxlinelen 200 set maxlinelen 200
set showlocalchanges 1 set showlocalchanges 1
set limitdiffs 1
set datetimeformat "%Y-%m-%d %H:%M:%S" set datetimeformat "%Y-%m-%d %H:%M:%S"
set colors {green red blue magenta darkgrey brown orange} set colors {green red blue magenta darkgrey brown orange}
@ -8545,6 +8588,7 @@ if {![file isdirectory $gitdir]} {
exit 1 exit 1
} }
set mergeonly 0
set revtreeargs {} set revtreeargs {}
set cmdline_files {} set cmdline_files {}
set i 0 set i 0
@ -8552,6 +8596,10 @@ foreach arg $argv {
switch -- $arg { switch -- $arg {
"" { } "" { }
"-d" { set datemode 1 } "-d" { set datemode 1 }
"--merge" {
set mergeonly 1
lappend revtreeargs $arg
}
"--" { "--" {
set cmdline_files [lrange $argv [expr {$i + 1}] end] set cmdline_files [lrange $argv [expr {$i + 1}] end]
break break
@ -8592,6 +8640,40 @@ if {$i >= [llength $argv] && $revtreeargs ne {}} {
} }
} }
if {$mergeonly} {
# find the list of unmerged files
set mlist {}
set nr_unmerged 0
if {[catch {
set fd [open "| git ls-files -u" r]
} err]} {
show_error {} . "Couldn't get list of unmerged files: $err"
exit 1
}
while {[gets $fd line] >= 0} {
set i [string first "\t" $line]
if {$i < 0} continue
set fname [string range $line [expr {$i+1}] end]
if {[lsearch -exact $mlist $fname] >= 0} continue
incr nr_unmerged
if {$cmdline_files eq {} || [path_filter $cmdline_files $fname]} {
lappend mlist $fname
}
}
catch {close $fd}
if {$mlist eq {}} {
if {$nr_unmerged == 0} {
show_error {} . "No files selected: --merge specified but\
no files are unmerged."
} else {
show_error {} . "No files selected: --merge specified but\
no unmerged files are within file limit."
}
exit 1
}
set cmdline_files $mlist
}
set nullid "0000000000000000000000000000000000000000" set nullid "0000000000000000000000000000000000000000"
set nullid2 "0000000000000000000000000000000000000001" set nullid2 "0000000000000000000000000000000000000001"