@@ -1874,6 +1874,20 @@ proc removehead {id name} {
1874
1874
unset headids($name )
1875
1875
}
1876
1876
1877
+ proc removetag {id name} {
1878
+ global tagids idtags
1879
+
1880
+ if {$idtags($id) eq $name } {
1881
+ unset idtags($id )
1882
+ } else {
1883
+ set i [lsearch -exact $idtags($id) $name ]
1884
+ if {$i >= 0} {
1885
+ set idtags($id ) [lreplace $idtags($id) $i $i ]
1886
+ }
1887
+ }
1888
+ unset tagids($name )
1889
+ }
1890
+
1877
1891
proc ttk_toplevel {w args} {
1878
1892
global use_ttk
1879
1893
eval [linsert $args 0 ::toplevel $w ]
@@ -2077,6 +2091,7 @@ proc makewindow {} {
2077
2091
global filesepbgcolor filesepfgcolor
2078
2092
global mergecolors foundbgcolor currentsearchhitbgcolor
2079
2093
global headctxmenu progresscanv progressitem progresscoords statusw
2094
+ global tagctxmenu
2080
2095
global fprogitem fprogcoord lastprogupdate progupdatepending
2081
2096
global rprogitem rprogcoord rownumsel numcommits
2082
2097
global have_tk85 use_ttk NS
@@ -2679,12 +2694,20 @@ proc makewindow {} {
2679
2694
set headctxmenu .headctxmenu
2680
2695
makemenu $headctxmenu {
2681
2696
{mc " Check out this branch" command cobranch}
2682
- {mc " Rename this branch" command mvbranch}
2697
+ {mc " Rename this branch... " command mvbranch}
2683
2698
{mc " Remove this branch" command rmbranch}
2684
2699
{mc " Copy branch name" command {clipboard clear; clipboard append $headmenuhead }}
2685
2700
}
2686
2701
$headctxmenu configure -tearoff 0
2687
2702
2703
+ set tagctxmenu .tagctxmenu
2704
+ makemenu $tagctxmenu {
2705
+ {mc " Rename this tag..." command mvtag}
2706
+ {mc " Remove this tag..." command rmtag}
2707
+ {mc " Copy tag name" command {clipboard clear; clipboard append $tagmenutag }}
2708
+ }
2709
+ $tagctxmenu configure -tearoff 0
2710
+
2688
2711
global flist_menu
2689
2712
set flist_menu .flistctxmenu
2690
2713
makemenu $flist_menu {
@@ -6581,6 +6604,7 @@ proc drawtags {id x xt y1} {
6581
6604
6582
6605
set marks {}
6583
6606
set ntags 0
6607
+ set ntags_copy 0
6584
6608
set nheads 0
6585
6609
set singletag 0
6586
6610
set maxtags 3
@@ -6592,8 +6616,9 @@ proc drawtags {id x xt y1} {
6592
6616
if {[info exists idtags($id )]} {
6593
6617
set marks $idtags($id)
6594
6618
set ntags [llength $marks ]
6595
- if {$ntags > $maxtags ||
6596
- [totalwidth $marks mainfont $extra ] > $maxwidth } {
6619
+ set ntags_copy $ntags
6620
+ set out_of_bounds [expr {[totalwidth $marks mainfont $extra ] > $maxwidth }]
6621
+ if {$ntags > $maxtags || $out_of_bounds } {
6597
6622
# show just a single "n tags..." tag
6598
6623
set singletag 1
6599
6624
if {$ntags == 1} {
@@ -6678,6 +6703,9 @@ proc drawtags {id x xt y1} {
6678
6703
-font $font -tags [list tag.$id text]]
6679
6704
if {$ntags >= 0} {
6680
6705
$canv bind $t <1> $tagclick
6706
+ if {$ntags_copy <= $maxtags && !$out_of_bounds } {
6707
+ $canv bind $t $ctxbut [list tagmenu %X %Y $id $tag_quoted ]
6708
+ }
6681
6709
} elseif {$nheads >= 0} {
6682
6710
$canv bind $t $ctxbut [list headmenu %X %Y $id $tag_quoted ]
6683
6711
}
@@ -9531,6 +9559,57 @@ proc mkbranch {} {
9531
9559
branchdia $top val ui
9532
9560
}
9533
9561
9562
+ proc mvtag {} {
9563
+ global NS
9564
+ global tagmenuid tagmenutag
9565
+
9566
+ set top .tagdialog
9567
+
9568
+ set val(name) $tagmenutag
9569
+ set val(id) $tagmenuid
9570
+ set val(command) [list mvtaggo $top $tagmenutag ]
9571
+
9572
+ set ui(title) [mc " Rename tag %s" $tagmenutag ]
9573
+ set ui(accept) [mc " Rename" ]
9574
+
9575
+ tagdia $top val ui
9576
+ }
9577
+
9578
+ proc tagdia {top valvar uivar} {
9579
+ global NS commitinfo
9580
+ upvar $valvar val $uivar ui
9581
+
9582
+ catch {destroy $top }
9583
+ ttk_toplevel $top
9584
+ make_transient $top .
9585
+ ${NS} ::label $top .title -text $ui(title)
9586
+ grid $top .title - -pady 10
9587
+ ${NS} ::label $top .id -text [mc " ID:" ]
9588
+ ${NS} ::entry $top .sha1 -width 40
9589
+ $top .sha1 insert 0 $val(id)
9590
+ $top .sha1 conf -state readonly
9591
+ grid $top .id $top .sha1 -sticky w
9592
+ ${NS} ::entry $top .head -width 60
9593
+ $top .head insert 0 [lindex $commitinfo($val(id) ) 0]
9594
+ $top .head conf -state readonly
9595
+ grid x $top .head -sticky ew
9596
+ grid columnconfigure $top 1 -weight 1
9597
+ ${NS} ::label $top .nlab -text [mc " Name:" ]
9598
+ ${NS} ::entry $top .name -width 40
9599
+ $top .name insert 0 $val(name)
9600
+ grid $top .nlab $top .name -sticky w
9601
+ ${NS} ::frame $top .buts
9602
+ ${NS} ::button $top .buts.go -text $ui(accept) -command $val(command)
9603
+ ${NS} ::button $top .buts.can -text [mc " Cancel" ] -command " catch {destroy $top }"
9604
+ bind $top <Key-Return> $val(command)
9605
+ bind $top <Key-Escape> " catch {destroy $top }"
9606
+ grid $top .buts.go $top .buts.can
9607
+ grid columnconfigure $top .buts 0 -weight 1 -uniform a
9608
+ grid columnconfigure $top .buts 1 -weight 1 -uniform a
9609
+ grid $top .buts - -pady 10 -sticky ew
9610
+ focus $top .name
9611
+ }
9612
+
9534
9613
proc mvbranch {} {
9535
9614
global NS
9536
9615
global headmenuid headmenuhead
@@ -9582,6 +9661,44 @@ proc branchdia {top valvar uivar} {
9582
9661
focus $top .name
9583
9662
}
9584
9663
9664
+ proc mvtaggo {top prevname} {
9665
+ global tagids idtags idheads mainhead mainheadid
9666
+
9667
+ set name [$top .name get]
9668
+ set id [$top .sha1 get]
9669
+ if {$name eq $prevname } {
9670
+ catch {destroy $top }
9671
+ return
9672
+ }
9673
+ if {$name eq {}} {
9674
+ error_popup [mc " Please specify a new name for the tag" ] $top
9675
+ return
9676
+ }
9677
+ catch {destroy $top }
9678
+ nowbusy renametag
9679
+ update
9680
+ if {[catch {
9681
+ # NOTE: for an annotated tag, the new tag points to the old tag object
9682
+ # where the old primary tag name is still recorded inside. Acceptable.
9683
+ eval exec " git tag $name $prevname "
9684
+ eval exec " git tag -d $prevname "
9685
+ } err]} {
9686
+ notbusy renametag
9687
+ error_popup $err
9688
+ } else {
9689
+ notbusy renametag
9690
+ removetag $id $prevname
9691
+ removedtag $id $tag
9692
+ set tagids($name ) $id
9693
+ lappend idtags($id ) $name
9694
+ addedtag $id
9695
+ redrawtags $id
9696
+ dispneartags 0
9697
+ run refill_reflist
9698
+ }
9699
+
9700
+ }
9701
+
9585
9702
proc mkbrgo {top} {
9586
9703
global headids idheads
9587
9704
@@ -9915,6 +10032,17 @@ proc headmenu {x y id head} {
9915
10032
tk_popup $headctxmenu $x $y
9916
10033
}
9917
10034
10035
+ # context menu for a tag
10036
+ proc tagmenu {x y id tag} {
10037
+ global tagmenuid tagmenutag tagctxmenu mainhead
10038
+
10039
+ stopfinding
10040
+ set tagmenuid $id
10041
+ set tagmenutag $tag
10042
+
10043
+ tk_popup $tagctxmenu $x $y
10044
+ }
10045
+
9918
10046
proc cobranch {} {
9919
10047
global headmenuid headmenuhead headids
9920
10048
global showlocalchanges
@@ -10019,6 +10147,28 @@ proc rmbranch {} {
10019
10147
run refill_reflist
10020
10148
}
10021
10149
10150
+ proc rmtag {} {
10151
+ global tagmenuid tagmenutag
10152
+ global idtags
10153
+
10154
+ set tag $tagmenutag
10155
+ set id $tagmenuid
10156
+ if {![confirm_popup [mc " Really delete tag %s?" $tag ]]} return
10157
+ nowbusy rmtag
10158
+ update
10159
+ if {[catch {exec git tag -d $tag } err]} {
10160
+ notbusy rmtag
10161
+ error_popup $err
10162
+ return
10163
+ }
10164
+ removetag $id $tag
10165
+ removedtag $id $tag
10166
+ redrawtags $id
10167
+ notbusy rmtag
10168
+ dispneartags 0
10169
+ run refill_reflist
10170
+ }
10171
+
10022
10172
# Display a list of tags and heads
10023
10173
proc showrefs {} {
10024
10174
global showrefstop bgcolor fgcolor selectbgcolor NS
@@ -11228,6 +11378,14 @@ proc addedtag {id} {
11228
11378
unset -nocomplain cached_atags
11229
11379
}
11230
11380
11381
+ proc removedtag {id tag} {
11382
+ global cached_dtags cached_atags cached_tagcontent
11383
+
11384
+ unset -nocomplain cached_tagcontent
11385
+ unset -nocomplain cached_dtags
11386
+ unset -nocomplain cached_atags
11387
+ }
11388
+
11231
11389
proc addedhead {hid head} {
11232
11390
global arcnos arcout cached_dheads
11233
11391
0 commit comments