@@ -1874,6 +1874,28 @@ proc removehead {id name} {
1874
1874
unset headids($name )
1875
1875
}
1876
1876
1877
+ proc movetag {id name} {
1878
+ global tagids idtags
1879
+
1880
+ removetag $tagids($name) $name
1881
+ set tagids($name ) $id
1882
+ lappend idtags($id ) $name
1883
+ }
1884
+
1885
+ proc removetag {id name} {
1886
+ global tagids idtags
1887
+
1888
+ if {$idtags($id) eq $name } {
1889
+ unset idtags($id )
1890
+ } else {
1891
+ set i [lsearch -exact $idtags($id) $name ]
1892
+ if {$i >= 0} {
1893
+ set idtags($id ) [lreplace $idtags($id) $i $i ]
1894
+ }
1895
+ }
1896
+ unset tagids($name )
1897
+ }
1898
+
1877
1899
proc ttk_toplevel {w args} {
1878
1900
global use_ttk
1879
1901
eval [linsert $args 0 ::toplevel $w ]
@@ -2077,6 +2099,7 @@ proc makewindow {} {
2077
2099
global filesepbgcolor filesepfgcolor
2078
2100
global mergecolors foundbgcolor currentsearchhitbgcolor
2079
2101
global headctxmenu progresscanv progressitem progresscoords statusw
2102
+ global tagctxmenu
2080
2103
global fprogitem fprogcoord lastprogupdate progupdatepending
2081
2104
global rprogitem rprogcoord rownumsel numcommits
2082
2105
global have_tk85 use_ttk NS
@@ -2685,6 +2708,14 @@ proc makewindow {} {
2685
2708
}
2686
2709
$headctxmenu configure -tearoff 0
2687
2710
2711
+ set tagctxmenu .tagctxmenu
2712
+ makemenu $tagctxmenu {
2713
+ {mc " Rename this tag" command mvtag}
2714
+ {mc " Remove this tag" command rmtag}
2715
+ {mc " Copy tag name" command {clipboard clear; clipboard append $tagmenutag }}
2716
+ }
2717
+ $tagctxmenu configure -tearoff 0
2718
+
2688
2719
global flist_menu
2689
2720
set flist_menu .flistctxmenu
2690
2721
makemenu $flist_menu {
@@ -6581,6 +6612,7 @@ proc drawtags {id x xt y1} {
6581
6612
6582
6613
set marks {}
6583
6614
set ntags 0
6615
+ set ntags_copy 0
6584
6616
set nheads 0
6585
6617
set singletag 0
6586
6618
set maxtags 3
@@ -6592,6 +6624,7 @@ proc drawtags {id x xt y1} {
6592
6624
if {[info exists idtags($id )]} {
6593
6625
set marks $idtags($id)
6594
6626
set ntags [llength $marks ]
6627
+ set ntags_copy $ntags
6595
6628
if {$ntags > $maxtags ||
6596
6629
[totalwidth $marks mainfont $extra ] > $maxwidth } {
6597
6630
# show just a single "n tags..." tag
@@ -6678,6 +6711,9 @@ proc drawtags {id x xt y1} {
6678
6711
-font $font -tags [list tag.$id text]]
6679
6712
if {$ntags >= 0} {
6680
6713
$canv bind $t <1> $tagclick
6714
+ if {$ntags_copy < $maxtags } {
6715
+ $canv bind $t $ctxbut [list tagmenu %X %Y $id $tag_quoted ]
6716
+ }
6681
6717
} elseif {$nheads >= 0} {
6682
6718
$canv bind $t $ctxbut [list headmenu %X %Y $id $tag_quoted ]
6683
6719
}
@@ -9531,6 +9567,57 @@ proc mkbranch {} {
9531
9567
branchdia $top val ui
9532
9568
}
9533
9569
9570
+ proc mvtag {} {
9571
+ global NS
9572
+ global tagmenuid tagmenutag
9573
+
9574
+ set top .tagdialog
9575
+
9576
+ set val(name) $tagmenutag
9577
+ set val(id) $tagmenuid
9578
+ set val(command) [list mvtago $top $tagmenutag ]
9579
+
9580
+ set ui(title) [mc " Rename tag %s" $tagmenutag ]
9581
+ set ui(accept) [mc " Rename" ]
9582
+
9583
+ tagdia $top val ui
9584
+ }
9585
+
9586
+ proc tagdia {top valvar uivar} {
9587
+ global NS commitinfo
9588
+ upvar $valvar val $uivar ui
9589
+
9590
+ catch {destroy $top }
9591
+ ttk_toplevel $top
9592
+ make_transient $top .
9593
+ ${NS} ::label $top .title -text $ui(title)
9594
+ grid $top .title - -pady 10
9595
+ ${NS} ::label $top .id -text [mc " ID:" ]
9596
+ ${NS} ::entry $top .sha1 -width 40
9597
+ $top .sha1 insert 0 $val(id)
9598
+ $top .sha1 conf -state readonly
9599
+ grid $top .id $top .sha1 -sticky w
9600
+ ${NS} ::entry $top .head -width 60
9601
+ $top .head insert 0 [lindex $commitinfo($val(id) ) 0]
9602
+ $top .head conf -state readonly
9603
+ grid x $top .head -sticky ew
9604
+ grid columnconfigure $top 1 -weight 1
9605
+ ${NS} ::label $top .nlab -text [mc " Name:" ]
9606
+ ${NS} ::entry $top .name -width 40
9607
+ $top .name insert 0 $val(name)
9608
+ grid $top .nlab $top .name -sticky w
9609
+ ${NS} ::frame $top .buts
9610
+ ${NS} ::button $top .buts.go -text $ui(accept) -command $val(command)
9611
+ ${NS} ::button $top .buts.can -text [mc " Cancel" ] -command " catch {destroy $top }"
9612
+ bind $top <Key-Return> $val(command)
9613
+ bind $top <Key-Escape> " catch {destroy $top }"
9614
+ grid $top .buts.go $top .buts.can
9615
+ grid columnconfigure $top .buts 0 -weight 1 -uniform a
9616
+ grid columnconfigure $top .buts 1 -weight 1 -uniform a
9617
+ grid $top .buts - -pady 10 -sticky ew
9618
+ focus $top .name
9619
+ }
9620
+
9534
9621
proc mvbranch {} {
9535
9622
global NS
9536
9623
global headmenuid headmenuhead
@@ -9582,6 +9669,38 @@ proc branchdia {top valvar uivar} {
9582
9669
focus $top .name
9583
9670
}
9584
9671
9672
+ proc mvtago {top prevname} {
9673
+ global tagids idheads mainhead mainheadid
9674
+
9675
+ set name [$top .name get]
9676
+ set id [$top .sha1 get]
9677
+ if {$name eq $prevname } {
9678
+ catch {destroy $top }
9679
+ return
9680
+ }
9681
+ if {$name eq {}} {
9682
+ error_popup [mc " Please specify a new name for the tag" ] $top
9683
+ return
9684
+ }
9685
+ catch {destroy $top }
9686
+ nowbusy renametag
9687
+ update
9688
+ if {[catch {
9689
+ eval exec " git tag $name $prevname "
9690
+ eval exec " git tag -d $prevname "
9691
+ } err]} {
9692
+ notbusy renametag
9693
+ error_popup $err
9694
+ } else {
9695
+ notbusy renametag
9696
+ removetag $id $prevname
9697
+ set tagids($name ) $id
9698
+ lappend idtags($id ) $name
9699
+ run refill_reflist
9700
+ }
9701
+
9702
+ }
9703
+
9585
9704
proc mkbrgo {top} {
9586
9705
global headids idheads
9587
9706
@@ -9915,6 +10034,17 @@ proc headmenu {x y id head} {
9915
10034
tk_popup $headctxmenu $x $y
9916
10035
}
9917
10036
10037
+ # context menu for a tag
10038
+ proc tagmenu {x y id tag} {
10039
+ global tagmenuid tagmenutag tagctxmenu mainhead
10040
+
10041
+ stopfinding
10042
+ set tagmenuid $id
10043
+ set tagmenutag $tag
10044
+
10045
+ tk_popup $tagctxmenu $x $y
10046
+ }
10047
+
9918
10048
proc cobranch {} {
9919
10049
global headmenuid headmenuhead headids
9920
10050
global showlocalchanges
@@ -10019,6 +10149,25 @@ proc rmbranch {} {
10019
10149
run refill_reflist
10020
10150
}
10021
10151
10152
+ proc rmtag {} {
10153
+ global tagmenuid tagmenutag
10154
+ global idtags
10155
+
10156
+ set tag $tagmenutag
10157
+ set id $tagmenuid
10158
+
10159
+ nowbusy rmtag
10160
+ update
10161
+ if {[catch {exec git tag -d $tag } err]} {
10162
+ notbusy rmtag
10163
+ error_popup $err
10164
+ return
10165
+ }
10166
+ removetag $id $tag
10167
+ notbusy rmtag
10168
+ run refill_reflist
10169
+ }
10170
+
10022
10171
# Display a list of tags and heads
10023
10172
proc showrefs {} {
10024
10173
global showrefstop bgcolor fgcolor selectbgcolor NS
0 commit comments