@@ -2664,6 +2664,7 @@ proc makewindow {} {
2664
2664
set headctxmenu .headctxmenu
2665
2665
makemenu $headctxmenu {
2666
2666
{mc " Check out this branch" command cobranch}
2667
+ {mc " Rename this branch" command mvbranch}
2667
2668
{mc " Remove this branch" command rmbranch}
2668
2669
{mc " Copy branch name" command {clipboard clear; clipboard append $headmenuhead }}
2669
2670
}
@@ -9452,26 +9453,58 @@ proc wrcomcan {} {
9452
9453
}
9453
9454
9454
9455
proc mkbranch {} {
9455
- global rowmenuid mkbrtop NS
9456
+ global NS rowmenuid
9457
+
9458
+ set top .branchdialog
9459
+
9460
+ set val(name) " "
9461
+ set val(id) $rowmenuid
9462
+ set val(command) [list mkbrgo $top ]
9463
+
9464
+ set ui(title) [mc " Create branch" ]
9465
+ set ui(accept) [mc " Create" ]
9466
+
9467
+ branchdia $top val ui
9468
+ }
9469
+
9470
+ proc mvbranch {} {
9471
+ global NS
9472
+ global headmenuid headmenuhead
9473
+
9474
+ set top .branchdialog
9475
+
9476
+ set val(name) $headmenuhead
9477
+ set val(id) $headmenuid
9478
+ set val(command) [list mvbrgo $top $headmenuhead ]
9479
+
9480
+ set ui(title) [mc " Rename branch %s" $headmenuhead ]
9481
+ set ui(accept) [mc " Rename" ]
9482
+
9483
+ branchdia $top val ui
9484
+ }
9485
+
9486
+ proc branchdia {top valvar uivar} {
9487
+ global NS
9488
+ upvar $valvar val $uivar ui
9456
9489
9457
- set top .makebranch
9458
9490
catch {destroy $top }
9459
9491
ttk_toplevel $top
9460
9492
make_transient $top .
9461
- ${NS} ::label $top .title -text [mc " Create new branch " ]
9493
+ ${NS} ::label $top .title -text $ui(title)
9462
9494
grid $top .title - -pady 10
9463
9495
${NS} ::label $top .id -text [mc " ID:" ]
9464
9496
${NS} ::entry $top .sha1 -width 40
9465
- $top .sha1 insert 0 $rowmenuid
9497
+ $top .sha1 insert 0 $val(id)
9466
9498
$top .sha1 conf -state readonly
9467
9499
grid $top .id $top .sha1 -sticky w
9468
9500
${NS} ::label $top .nlab -text [mc " Name:" ]
9469
9501
${NS} ::entry $top .name -width 40
9502
+ $top .name insert 0 $val(name)
9470
9503
grid $top .nlab $top .name -sticky w
9471
9504
${NS} ::frame $top .buts
9472
- ${NS} ::button $top .buts.go -text [mc " Create " ] -command [ list mkbrgo $top ]
9505
+ ${NS} ::button $top .buts.go -text $ui(accept) -command $val(command)
9473
9506
${NS} ::button $top .buts.can -text [mc " Cancel" ] -command " catch {destroy $top }"
9474
- bind $top <Key-Return> [ list mkbrgo $top ]
9507
+ bind $top <Key-Return> $val(command)
9475
9508
bind $top <Key-Escape> " catch {destroy $top }"
9476
9509
grid $top .buts.go $top .buts.can
9477
9510
grid columnconfigure $top .buts 0 -weight 1 -uniform a
@@ -9526,6 +9559,46 @@ proc mkbrgo {top} {
9526
9559
}
9527
9560
}
9528
9561
9562
+ proc mvbrgo {top prevname} {
9563
+ global headids idheads mainhead mainheadid
9564
+
9565
+ set name [$top .name get]
9566
+ set id [$top .sha1 get]
9567
+ set cmdargs {}
9568
+ if {$name eq $prevname } {
9569
+ catch {destroy $top }
9570
+ return
9571
+ }
9572
+ if {$name eq {}} {
9573
+ error_popup [mc " Please specify a new name for the branch" ] $top
9574
+ return
9575
+ }
9576
+ catch {destroy $top }
9577
+ lappend cmdargs -m $prevname $name
9578
+ nowbusy renamebranch
9579
+ update
9580
+ if {[catch {
9581
+ eval exec git branch $cmdargs
9582
+ } err]} {
9583
+ notbusy renamebranch
9584
+ error_popup $err
9585
+ } else {
9586
+ notbusy renamebranch
9587
+ removehead $id $prevname
9588
+ removedhead $id $prevname
9589
+ set headids($name ) $id
9590
+ lappend idheads($id ) $name
9591
+ addedhead $id $name
9592
+ if {$prevname eq $mainhead } {
9593
+ set mainhead $name
9594
+ set mainheadid $id
9595
+ }
9596
+ redrawtags $id
9597
+ dispneartags 0
9598
+ run refill_reflist
9599
+ }
9600
+ }
9601
+
9529
9602
proc exec_citool {tool_args {baseid {}}} {
9530
9603
global commitinfo env
9531
9604
@@ -9756,15 +9829,16 @@ proc headmenu {x y id head} {
9756
9829
stopfinding
9757
9830
set headmenuid $id
9758
9831
set headmenuhead $head
9759
- set state normal
9832
+ array set state {0 normal 1 normal 2 normal}
9760
9833
if {[string match " remotes/*" $head ]} {
9761
- set state disabled
9834
+ array set state {0 disabled 1 disabled 2 disabled}
9762
9835
}
9763
9836
if {$head eq $mainhead } {
9764
- set state disabled
9837
+ array set state {0 disabled 2 disabled}
9838
+ }
9839
+ foreach i {0 1 2} {
9840
+ $headctxmenu entryconfigure $i -state $state($i)
9765
9841
}
9766
- $headctxmenu entryconfigure 0 -state $state
9767
- $headctxmenu entryconfigure 1 -state $state
9768
9842
tk_popup $headctxmenu $x $y
9769
9843
}
9770
9844
0 commit comments