author | Paul Mackerras <paulus@samba.org> | |
Wed, 19 Dec 2007 23:25:50 +0000 (10:25 +1100) | ||
committer | Paul Mackerras <paulus@samba.org> | |
Wed, 19 Dec 2007 23:25:50 +0000 (10:25 +1100) |
1 | 2 | |||
---|---|---|---|---|
gitk | patch | | diff1 | | diff2 | | blob | history |
diff --cc gitk
index 53106018197da8a71e93138c2cd23f9717987d1b,684e6141ebb7c6363c7c1d279807144e8f961e4e..86dd575ca71655606c1be4293d0bcd6e0cdb34ef
+++ b/gitk
set startmsecs [clock clicks -milliseconds]
set commitidx($view) 0
set viewcomplete($view) 0
+ set viewactive($view) 1
set vnextroot($view) 0
- set order "--topo-order"
- if {$datemode} {
- set order "--date-order"
+ varcinit $view
+
+ set commits [eval exec git rev-parse --default HEAD --revs-only \
+ $viewargs($view)]
+ set viewincl($view) {}
+ foreach c $commits {
+ if {![string match "^*" $c]} {
+ lappend viewincl($view) $c
+ }
}
if {[catch {
- set fd [open [concat | git log --no-color -z --pretty=raw $order --parents \
- --boundary $viewargs($view) "--" $viewfiles($view)] r]
+ set fd [open [concat | git log --no-color -z --pretty=raw --parents \
+ --boundary $commits "--" $viewfiles($view)] r]
} err]} {
- error_popup "Error executing git log: $err"
- error_popup "[mc "Error executing git rev-list:"] $err"
++ error_popup "[mc "Error executing git log:"] $err"
exit 1
}
- set commfd($view) $fd
- set leftover($view) {}
+ set i [incr loginstance]
+ set viewinstances($view) [list $i]
+ set commfd($i) $fd
+ set leftover($i) {}
if {$showlocalchanges} {
lappend commitinterest($mainheadid) {dodiffindex}
}
if {$tclencoding != {}} {
fconfigure $fd -encoding $tclencoding
}
- filerun $fd [list getcommitlines $fd $view]
+ filerun $fd [list getcommitlines $fd $i $view]
- nowbusy $view "Reading"
+ nowbusy $view [mc "Reading"]
if {$view == $curview} {
set progressdirn 1
set progresscoords {0 0}
}
proc getcommits {} {
- global phase canv curview
+ global canv curview
- set phase getcommits
initlayout
start_rev_list $curview
- show_status "Reading commits..."
+ show_status [mc "Reading commits..."]
}
+proc updatecommits {} {
+ global curview viewargs viewfiles viewincl viewinstances
+ global viewactive viewcomplete loginstance tclencoding mainheadid
+ global varcid startmsecs commfd showneartags showlocalchanges leftover
+
+ if {$showlocalchanges && [commitinview $mainheadid $curview]} {
+ dodiffindex
+ }
+ set view $curview
+ set commits [exec git rev-parse --default HEAD --revs-only \
+ $viewargs($view)]
+ set pos {}
+ set neg {}
+ foreach c $commits {
+ if {[string match "^*" $c]} {
+ lappend neg $c
+ } else {
+ if {!([info exists varcid($view,$c)] ||
+ [lsearch -exact $viewincl($view) $c] >= 0)} {
+ lappend pos $c
+ }
+ }
+ }
+ if {$pos eq {}} {
+ return
+ }
+ foreach id $viewincl($view) {
+ lappend neg "^$id"
+ }
+ set viewincl($view) [concat $viewincl($view) $pos]
+ if {[catch {
+ set fd [open [concat | git log --no-color -z --pretty=raw --parents \
+ --boundary $pos $neg "--" $viewfiles($view)] r]
+ } err]} {
+ error_popup "Error executing git log: $err"
+ exit 1
+ }
+ if {$viewactive($view) == 0} {
+ set startmsecs [clock clicks -milliseconds]
+ }
+ set i [incr loginstance]
+ lappend viewinstances($view) $i
+ set commfd($i) $fd
+ set leftover($i) {}
+ fconfigure $fd -blocking 0 -translation lf -eofchar {}
+ if {$tclencoding != {}} {
+ fconfigure $fd -encoding $tclencoding
+ }
+ filerun $fd [list getcommitlines $fd $i $view]
+ incr viewactive($view)
+ set viewcomplete($view) 0
+ nowbusy $view "Reading"
+ readrefs
+ changedrefs
+ if {$showneartags} {
+ getallcommits
+ }
+}
+
+proc reloadcommits {} {
+ global curview viewcomplete selectedline currentid thickerline
+ global showneartags treediffs commitinterest cached_commitrow
+ global progresscoords
+
+ if {!$viewcomplete($curview)} {
+ stop_rev_list $curview
+ set progresscoords {0 0}
+ adjustprogress
+ }
+ resetvarcs $curview
+ catch {unset selectedline}
+ catch {unset currentid}
+ catch {unset thickerline}
+ catch {unset treediffs}
+ readrefs
+ changedrefs
+ if {$showneartags} {
+ getallcommits
+ }
+ clear_display
+ catch {unset commitinterest}
+ catch {unset cached_commitrow}
+ setcanvscroll
+ getcommits
+}
+
# This makes a string representation of a positive integer which
# sorts as a string in numerical order
proc strrep {n} {
if {$commitidx($curview) > 0} {
#set ms [expr {[clock clicks -milliseconds] - $startmsecs}]
#puts "overall $ms ms for $numcommits commits"
+ #puts "[llength $varctok($view)] arcs, $commitidx($view) commits"
} else {
- show_status "No commits selected"
+ show_status [mc "No commits selected"]
}
notbusy layout
- set phase {}
}
}
if {[info exists hlview] && $view == $hlview} {
global have_tk85
menu .bar
- .bar add cascade -label "File" -menu .bar.file
+ .bar add cascade -label [mc "File"] -menu .bar.file
.bar configure -font uifont
menu .bar.file
- .bar.file add command -label "Update" -command updatecommits
- .bar.file add command -label "Reload" -command reloadcommits
- .bar.file add command -label "Reread references" -command rereadrefs
- .bar.file add command -label "List references" -command showrefs
- .bar.file add command -label "Quit" -command doquit
+ .bar.file add command -label [mc "Update"] -command updatecommits
++ .bar.file add command -label [mc "Reload"] -command reloadcommits
+ .bar.file add command -label [mc "Reread references"] -command rereadrefs
+ .bar.file add command -label [mc "List references"] -command showrefs
+ .bar.file add command -label [mc "Quit"] -command doquit
.bar.file configure -font uifont
menu .bar.edit
- .bar add cascade -label "Edit" -menu .bar.edit
- .bar.edit add command -label "Preferences" -command doprefs
+ .bar add cascade -label [mc "Edit"] -menu .bar.edit
+ .bar.edit add command -label [mc "Preferences"] -command doprefs
.bar.edit configure -font uifont
menu .bar.view -font uifont
clear_display
if {[info exists hlview] && $hlview == $n} {
unset hlview
- set selectedhlview None
+ set selectedhlview [mc "None"]
}
catch {unset commitinterest}
+ catch {unset cached_commitrow}
+ catch {unset ordertok}
set curview $n
set selectedview $n
- .bar.view entryconf Edit* -state [expr {$n == 0? "disabled": "normal"}]
- .bar.view entryconf Delete* -state [expr {$n == 0? "disabled": "normal"}]
+ .bar.view entryconf [mc "Edit view..."] -state [expr {$n == 0? "disabled": "normal"}]
+ .bar.view entryconf [mc "Delete view"] -state [expr {$n == 0? "disabled": "normal"}]
run refill_reflist
- if {![info exists viewdata($n)]} {
+ if {![info exists viewcomplete($n)]} {
if {$selid ne {}} {
set pending_select $selid
}
set selectfirst 1
}
}
- if {$phase ne {}} {
- if {$phase eq "getcommits"} {
+ if {!$viewcomplete($n)} {
+ if {$numcommits == 0} {
- show_status "Reading commits..."
- } else {
- run chewcommits $n
+ show_status [mc "Reading commits..."]
}
- run chewcommits $n
} elseif {$numcommits == 0} {
- show_status "No commits selected"
+ show_status [mc "No commits selected"]
}
}
# we only need to see one line and we don't really care what it says...
close $fd
- # now see if there are any local changes not checked in to the index
- if {$serial == $lserial} {
- set fd [open "|git diff-files" r]
- fconfigure $fd -blocking 0
- filerun $fd [list readdifffiles $fd $serial]
+ if {$serial != $lserial} {
+ return 0
}
- if {$isdiff && $serial == $lserial && $localirow == -1} {
+ # now see if there are any local changes not checked in to the index
+ set fd [open "|git diff-files" r]
+ fconfigure $fd -blocking 0
+ filerun $fd [list readdifffiles $fd $serial]
+
+ if {$isdiff && ![commitinview $nullid2 $curview]} {
# add the line for the changes in the index to the graph
- set hl "Local changes checked in to index but not committed"
- set localirow $commitrow($curview,$mainheadid)
+ set hl [mc "Local changes checked in to index but not committed"]
set commitinfo($nullid2) [list $hl {} {} {} {} " $hl\n"]
set commitdata($nullid2) "\n $hl\n"
- insertrow $localirow $nullid2
+ insertrow $nullid2 $mainheadid $curview
+ } elseif {!$isdiff && [commitinview $nullid2 $curview]} {
+ removerow $nullid2 $curview
}
return 0
}
# we only need to see one line and we don't really care what it says...
close $fd
- if {$isdiff && $serial == $lserial && $localfrow == -1} {
+ if {$serial != $lserial} {
+ return 0
+ }
+
+ if {$isdiff && ![commitinview $nullid $curview]} {
# add the line for the local diff to the graph
- set hl "Local uncommitted changes, not checked in to index"
- if {$localirow >= 0} {
- set localfrow $localirow
- incr localirow
- } else {
- set localfrow $commitrow($curview,$mainheadid)
- }
+ set hl [mc "Local uncommitted changes, not checked in to index"]
set commitinfo($nullid) [list $hl {} {} {} {} " $hl\n"]
set commitdata($nullid) "\n $hl\n"
- insertrow $localfrow $nullid
+ if {[commitinview $nullid2 $curview]} {
+ set p $nullid2
+ } else {
+ set p $mainheadid
+ }
+ insertrow $nullid $p $curview
+ } elseif {!$isdiff && [commitinview $nullid $curview]} {
+ removerow $nullid $curview
}
return 0
}
}
set found 0
set domore 1
- if {$gdttype eq "containing:"} {
+ set ai [bsearch $vrownum($curview) $l]
+ set a [lindex $varcorder($curview) $ai]
+ set arow [lindex $vrownum($curview) $ai]
+ set ids [lindex $varccommits($curview,$a)]
+ set arowend [expr {$arow + [llength $ids]}]
+ if {$gdttype eq [mc "containing:"]} {
for {} {$n > 0} {incr n -1; incr l $find_dirn} {
- set id [lindex $displayorder $l]
+ if {$l < $arow || $l >= $arowend} {
+ incr ai $find_dirn
+ set a [lindex $varcorder($curview) $ai]
+ set arow [lindex $vrownum($curview) $ai]
+ set ids [lindex $varccommits($curview,$a)]
+ set arowend [expr {$arow + [llength $ids]}]
+ }
+ set id [lindex $ids [expr {$l - $arow}]]
# shouldn't happen unless git log doesn't give all the commits...
- if {![info exists commitdata($id)]} continue
- if {![doesmatch $commitdata($id)]} continue
+ if {![info exists commitdata($id)] ||
+ ![doesmatch $commitdata($id)]} {
+ continue
+ }
if {![info exists commitinfo($id)]} {
getcommit $id
}
} else {
set id [string tolower $sha1string]
if {[regexp {^[0-9a-f]{4,39}$} $id]} {
- set matches {}
- foreach i $displayorder {
- if {[string match $id* $i]} {
- lappend matches $i
- }
- }
+ set matches [array names varcid "$curview,$id*"]
if {$matches ne {}} {
if {[llength $matches] > 1} {
- error_popup "Short SHA1 id $id is ambiguous"
+ error_popup [mc "Short SHA1 id %s is ambiguous" $id]
return
}
- set id [lindex $matches 0]
+ set id [lindex [split [lindex $matches 0] ","] 1]
}
}
}