22# Tcl ignores the next line -*- tcl -*- \
33exec wish "$0" -- "$@"
44
5- # Copyright © 2005-2014 Paul Mackerras. All rights reserved.
5+ # Copyright © 2005-2016 Paul Mackerras. All rights reserved.
66# This program is free software; it may be used, copied, modified
77# and distributed under the terms of the GNU General Public Licence,
88# either version 2, or (at your option) any later version.
@@ -588,7 +588,7 @@ proc updatecommits {} {
588588proc reloadcommits {} {
589589 global curview viewcomplete selectedline currentid thickerline
590590 global showneartags treediffs commitinterest cached_commitrow
591- global targetid
591+ global targetid commitinfo
592592
593593 set selid {}
594594 if {$selectedline ne {}} {
@@ -609,6 +609,7 @@ proc reloadcommits {} {
609609 getallcommits
610610 }
611611 clear_display
612+ unset -nocomplain commitinfo
612613 unset -nocomplain commitinterest
613614 unset -nocomplain cached_commitrow
614615 unset -nocomplain targetid
@@ -1315,7 +1316,7 @@ proc commitonrow {row} {
13151316
13161317proc closevarcs {v} {
13171318 global varctok varccommits varcid parents children
1318- global cmitlisted commitidx vtokmod
1319+ global cmitlisted commitidx vtokmod curview numcommits
13191320
13201321 set missing_parents 0
13211322 set scripts {}
@@ -1340,6 +1341,9 @@ proc closevarcs {v} {
13401341 }
13411342 lappend varccommits($v ,$b ) $p
13421343 incr commitidx($v )
1344+ if {$v == $curview } {
1345+ set numcommits $commitidx($v)
1346+ }
13431347 set scripts [check_interest $p $scripts ]
13441348 }
13451349 }
@@ -2265,7 +2269,7 @@ proc makewindow {} {
22652269 set h [expr {[font metrics uifont -linespace] + 2}]
22662270 set progresscanv .tf.bar.progress
22672271 canvas $progresscanv -relief sunken -height $h -borderwidth 2
2268- set progressitem [$progresscanv create rect -1 0 0 $h -fill lime ]
2272+ set progressitem [$progresscanv create rect -1 0 0 $h -fill " #00ff00 " ]
22692273 set fprogitem [$progresscanv create rect -1 0 0 $h -fill yellow]
22702274 set rprogitem [$progresscanv create rect -1 0 0 $h -fill red]
22712275 }
@@ -2403,7 +2407,7 @@ proc makewindow {} {
24032407
24042408 set ctext .bleft.bottom.ctext
24052409 text $ctext -background $bgcolor -foreground $fgcolor \
2406- -state disabled -font textfont \
2410+ -state disabled -undo 0 - font textfont \
24072411 -yscrollcommand scrolltext -wrap none \
24082412 -xscrollcommand " .bleft.bottom.sbhorizontal set"
24092413 if {$have_tk85 } {
@@ -2664,6 +2668,7 @@ proc makewindow {} {
26642668 set headctxmenu .headctxmenu
26652669 makemenu $headctxmenu {
26662670 {mc " Check out this branch" command cobranch}
2671+ {mc " Rename this branch" command mvbranch}
26672672 {mc " Remove this branch" command rmbranch}
26682673 {mc " Copy branch name" command {clipboard clear; clipboard append $headmenuhead }}
26692674 }
@@ -3033,7 +3038,7 @@ proc about {} {
30333038 message $w .m -text [mc "
30343039Gitk - a commit viewer for git
30353040
3036- Copyright \u00a9 2005-2014 Paul Mackerras
3041+ Copyright \u00a9 2005-2016 Paul Mackerras
30373042
30383043Use and redistribute under the terms of the GNU General Public License" ] \
30393044 -justify center -aspect 400 -border 2 -bg $bgcolor -relief groove
@@ -3397,7 +3402,7 @@ set rectmask {
33973402 0x00, 0x00, 0xfc, 0x0f, 0xfc, 0x0f, 0xfc, 0x0f,
33983403 0xfc, 0x0f, 0xfc, 0x0f, 0xfc, 0x0f, 0xfc, 0x0f, 0x00, 0x00};
33993404}
3400- image create bitmap reficon-H -background black -foreground lime \
3405+ image create bitmap reficon-H -background black -foreground " #00ff00 " \
34013406 -data $rectdata -maskdata $rectmask
34023407image create bitmap reficon-o -background black -foreground " #ddddff" \
34033408 -data $rectdata -maskdata $rectmask
@@ -8069,7 +8074,11 @@ proc getblobdiffline {bdf ids} {
80698074 $ctext conf -state normal
80708075 while {[incr nr] <= 1000 && [gets $bdf line] >= 0} {
80718076 if {$ids != $diffids || $bdf != $blobdifffd($ids) } {
8077+ # Older diff read. Abort it.
80728078 catch {close $bdf }
8079+ if {$ids != $diffids } {
8080+ array unset blobdifffd $ids
8081+ }
80738082 return 0
80748083 }
80758084 parseblobdiffline $ids $line
@@ -8078,6 +8087,7 @@ proc getblobdiffline {bdf ids} {
80788087 blobdiffmaybeseehere [eof $bdf ]
80798088 if {[eof $bdf ]} {
80808089 catch {close $bdf }
8090+ array unset blobdifffd $ids
80818091 return 0
80828092 }
80838093 return [expr {$nr >= 1000? 2: 1}]
@@ -9452,26 +9462,63 @@ proc wrcomcan {} {
94529462}
94539463
94549464proc mkbranch {} {
9455- global rowmenuid mkbrtop NS
9465+ global NS rowmenuid
9466+
9467+ set top .branchdialog
9468+
9469+ set val(name) " "
9470+ set val(id) $rowmenuid
9471+ set val(command) [list mkbrgo $top ]
9472+
9473+ set ui(title) [mc " Create branch" ]
9474+ set ui(accept) [mc " Create" ]
9475+
9476+ branchdia $top val ui
9477+ }
9478+
9479+ proc mvbranch {} {
9480+ global NS
9481+ global headmenuid headmenuhead
9482+
9483+ set top .branchdialog
9484+
9485+ set val(name) $headmenuhead
9486+ set val(id) $headmenuid
9487+ set val(command) [list mvbrgo $top $headmenuhead ]
9488+
9489+ set ui(title) [mc " Rename branch %s" $headmenuhead ]
9490+ set ui(accept) [mc " Rename" ]
9491+
9492+ branchdia $top val ui
9493+ }
9494+
9495+ proc branchdia {top valvar uivar} {
9496+ global NS commitinfo
9497+ upvar $valvar val $uivar ui
94569498
9457- set top .makebranch
94589499 catch {destroy $top }
94599500 ttk_toplevel $top
94609501 make_transient $top .
9461- ${NS} ::label $top .title -text [mc " Create new branch " ]
9502+ ${NS} ::label $top .title -text $ui(title)
94629503 grid $top .title - -pady 10
94639504 ${NS} ::label $top .id -text [mc " ID:" ]
94649505 ${NS} ::entry $top .sha1 -width 40
9465- $top .sha1 insert 0 $rowmenuid
9506+ $top .sha1 insert 0 $val(id)
94669507 $top .sha1 conf -state readonly
94679508 grid $top .id $top .sha1 -sticky w
9509+ ${NS} ::entry $top .head -width 60
9510+ $top .head insert 0 [lindex $commitinfo($val(id) ) 0]
9511+ $top .head conf -state readonly
9512+ grid x $top .head -sticky ew
9513+ grid columnconfigure $top 1 -weight 1
94689514 ${NS} ::label $top .nlab -text [mc " Name:" ]
94699515 ${NS} ::entry $top .name -width 40
9516+ $top .name insert 0 $val(name)
94709517 grid $top .nlab $top .name -sticky w
94719518 ${NS} ::frame $top .buts
9472- ${NS} ::button $top .buts.go -text [mc " Create " ] -command [ list mkbrgo $top ]
9519+ ${NS} ::button $top .buts.go -text $ui(accept) -command $val(command)
94739520 ${NS} ::button $top .buts.can -text [mc " Cancel" ] -command " catch {destroy $top }"
9474- bind $top <Key-Return> [ list mkbrgo $top ]
9521+ bind $top <Key-Return> $val(command)
94759522 bind $top <Key-Escape> " catch {destroy $top }"
94769523 grid $top .buts.go $top .buts.can
94779524 grid columnconfigure $top .buts 0 -weight 1 -uniform a
@@ -9526,6 +9573,46 @@ proc mkbrgo {top} {
95269573 }
95279574}
95289575
9576+ proc mvbrgo {top prevname} {
9577+ global headids idheads mainhead mainheadid
9578+
9579+ set name [$top .name get]
9580+ set id [$top .sha1 get]
9581+ set cmdargs {}
9582+ if {$name eq $prevname } {
9583+ catch {destroy $top }
9584+ return
9585+ }
9586+ if {$name eq {}} {
9587+ error_popup [mc " Please specify a new name for the branch" ] $top
9588+ return
9589+ }
9590+ catch {destroy $top }
9591+ lappend cmdargs -m $prevname $name
9592+ nowbusy renamebranch
9593+ update
9594+ if {[catch {
9595+ eval exec git branch $cmdargs
9596+ } err]} {
9597+ notbusy renamebranch
9598+ error_popup $err
9599+ } else {
9600+ notbusy renamebranch
9601+ removehead $id $prevname
9602+ removedhead $id $prevname
9603+ set headids($name ) $id
9604+ lappend idheads($id ) $name
9605+ addedhead $id $name
9606+ if {$prevname eq $mainhead } {
9607+ set mainhead $name
9608+ set mainheadid $id
9609+ }
9610+ redrawtags $id
9611+ dispneartags 0
9612+ run refill_reflist
9613+ }
9614+ }
9615+
95299616proc exec_citool {tool_args {baseid {}}} {
95309617 global commitinfo env
95319618
@@ -9751,20 +9838,25 @@ proc readresetstat {fd} {
97519838
97529839# context menu for a head
97539840proc headmenu {x y id head} {
9754- global headmenuid headmenuhead headctxmenu mainhead
9841+ global headmenuid headmenuhead headctxmenu mainhead headids
97559842
97569843 stopfinding
97579844 set headmenuid $id
97589845 set headmenuhead $head
9759- set state normal
9846+ array set state {0 normal 1 normal 2 normal}
97609847 if {[string match " remotes/*" $head ]} {
9761- set state disabled
9848+ set localhead [string range $head [expr [string last / $head ] + 1] end]
9849+ if {[info exists headids($localhead )]} {
9850+ set state(0) disabled
9851+ }
9852+ array set state {1 disabled 2 disabled}
97629853 }
97639854 if {$head eq $mainhead } {
9764- set state disabled
9855+ array set state {0 disabled 2 disabled}
9856+ }
9857+ foreach i {0 1 2} {
9858+ $headctxmenu entryconfigure $i -state $state($i)
97659859 }
9766- $headctxmenu entryconfigure 0 -state $state
9767- $headctxmenu entryconfigure 1 -state $state
97689860 tk_popup $headctxmenu $x $y
97699861}
97709862
@@ -9773,24 +9865,40 @@ proc cobranch {} {
97739865 global showlocalchanges
97749866
97759867 # check the tree is clean first??
9868+ set newhead $headmenuhead
9869+ set command [list | git checkout]
9870+ if {[string match " remotes/*" $newhead ]} {
9871+ set remote $newhead
9872+ set newhead [string range $newhead [expr [string last / $newhead ] + 1] end]
9873+ # The following check is redundant - the menu option should
9874+ # be disabled to begin with...
9875+ if {[info exists headids($newhead )]} {
9876+ error_popup [mc " A local branch named %s exists already" $newhead ]
9877+ return
9878+ }
9879+ lappend command -b $newhead --track $remote
9880+ } else {
9881+ lappend command $newhead
9882+ }
9883+ lappend command 2>@1
97769884 nowbusy checkout [mc " Checking out" ]
97779885 update
97789886 dohidelocalchanges
97799887 if {[catch {
9780- set fd [open [ list | git checkout $headmenuhead 2>@1] r]
9888+ set fd [open $command r]
97819889 } err]} {
97829890 notbusy checkout
97839891 error_popup $err
97849892 if {$showlocalchanges } {
97859893 dodiffindex
97869894 }
97879895 } else {
9788- filerun $fd [list readcheckoutstat $fd $headmenuhead $headmenuid ]
9896+ filerun $fd [list readcheckoutstat $fd $newhead $headmenuid ]
97899897 }
97909898}
97919899
97929900proc readcheckoutstat {fd newhead newheadid} {
9793- global mainhead mainheadid headids showlocalchanges progresscoords
9901+ global mainhead mainheadid headids idheads showlocalchanges progresscoords
97949902 global viewmainheadid curview
97959903
97969904 if {[gets $fd line] >= 0} {
@@ -9805,8 +9913,14 @@ proc readcheckoutstat {fd newhead newheadid} {
98059913 notbusy checkout
98069914 if {[catch {close $fd } err]} {
98079915 error_popup $err
9916+ return
98089917 }
98099918 set oldmainid $mainheadid
9919+ if {! [info exists headids($newhead )]} {
9920+ set headids($newhead ) $newheadid
9921+ lappend idheads($newheadid ) $newhead
9922+ addedhead $newheadid $newhead
9923+ }
98109924 set mainhead $newhead
98119925 set mainheadid $newheadid
98129926 set viewmainheadid($curview ) $newheadid
@@ -12188,7 +12302,7 @@ if {[tk windowingsystem] eq "aqua"} {
1218812302 set extdifftool " meld"
1218912303}
1219012304
12191- set colors {lime red blue magenta darkgrey brown orange}
12305+ set colors {" #00ff00 " red blue magenta darkgrey brown orange}
1219212306if {[tk windowingsystem] eq " win32" } {
1219312307 set uicolor SystemButtonFace
1219412308 set uifgcolor SystemButtonText
@@ -12206,12 +12320,12 @@ if {[tk windowingsystem] eq "win32"} {
1220612320}
1220712321set diffcolors {red " #00a000" blue}
1220812322set diffcontext 3
12209- set mergecolors {red blue lime purple brown " #009090" magenta " #808000" " #009000" " #ff0080" cyan " #b07070" " #70b0f0" " #70f0b0" " #f0b070" " #ff70b0" }
12323+ set mergecolors {red blue " #00ff00 " purple brown " #009090" magenta " #808000" " #009000" " #ff0080" cyan " #b07070" " #70b0f0" " #70f0b0" " #f0b070" " #ff70b0" }
1221012324set ignorespace 0
1221112325set worddiff " "
1221212326set markbgcolor " #e0e0ff"
1221312327
12214- set headbgcolor lime
12328+ set headbgcolor " #00ff00 "
1221512329set headfgcolor black
1221612330set headoutlinecolor black
1221712331set remotebgcolor #ffddaa
@@ -12226,7 +12340,7 @@ set linehoverfgcolor black
1222612340set linehoveroutlinecolor black
1222712341set mainheadcirclecolor yellow
1222812342set workingfilescirclecolor red
12229- set indexcirclecolor lime
12343+ set indexcirclecolor " #00ff00 "
1223012344set circlecolors {white blue gray blue blue}
1223112345set linkfgcolor blue
1223212346set circleoutlinecolor $fgcolor
0 commit comments