From: 阿德烈 via GitGitGadget <hidden> Date: 2021-02-04 08:19:11
From: ZheNing Hu <redacted>
In gitk, we can right-click on the icon of the branch,
and a directory will pop up to provide us with functions
such as "Checkout this branch", "Rename this branch"...,
but we found that the right-click tag icon does not have such
a function , So I learned how to write the branch icon, and
added the following functions "Rename this tag","Remove this tag",
"Copy tag name" to right-click the tag icon. This function is
temporarily supported work on the branch with <=3 tags.
But now I may need a little help:
after we successfully deleted or modified the tag,the content
show on gitk has not changed, and I am stuck here.
Signed-off-by: ZheNing Hu <redacted>
---
[RFC] gitk: tag add right click options
This patch want to fix: https://github.com/gitgitgadget/git/issues/855
We can provide for right-clicking the tag icon in gitk Rename this tag",
"Remove this tag", "Copy tag name" function.
For convenience, only the tags on the branch with the number of tags <=3
are processed temporarily.
Now I may need a little help: after we successfully deleted or modified
the tag name,the content show on gitk has not changed, and I am stuck
here.
In addition,I just learned part of the syntax of the tcl/tk language,
and there may be some bad uses in my patch.
Thanks!
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-866%2Fadlternative%2Fgitk_tag_new_opt-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-866/adlternative/gitk_tag_new_opt-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/866
gitk-git/gitk | 149 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 149 insertions(+)
@@ -1874,6 +1874,28 @@ proc removehead {id name} { unset headids($name) }+proc movetag {id name} {+ global tagids idtags++ removetag $tagids($name) $name+ set tagids($name) $id+ lappend idtags($id) $name+}++proc removetag {id name} {+ global tagids idtags++ if {$idtags($id) eq $name} {+ unset idtags($id)+ } else {+ set i [lsearch -exact $idtags($id) $name]+ if {$i >= 0} {+ set idtags($id) [lreplace $idtags($id) $i $i]+ }+ }+ unset tagids($name)+}+ proc ttk_toplevel {w args} { global use_ttk eval [linsert $args 0 ::toplevel $w]
@@ -2077,6 +2099,7 @@ proc makewindow {} { global filesepbgcolor filesepfgcolor global mergecolors foundbgcolor currentsearchhitbgcolor global headctxmenu progresscanv progressitem progresscoords statusw+ global tagctxmenu global fprogitem fprogcoord lastprogupdate progupdatepending global rprogitem rprogcoord rownumsel numcommits global have_tk85 use_ttk NS
@@ -2685,6 +2708,14 @@ proc makewindow {} { } $headctxmenu configure -tearoff 0+ set tagctxmenu .tagctxmenu+ makemenu $tagctxmenu {+ {mc "Rename this tag" command mvtag}+ {mc "Remove this tag" command rmtag}+ {mc "Copy tag name" command {clipboard clear; clipboard append $tagmenutag}}+ }+ $tagctxmenu configure -tearoff 0+ global flist_menu set flist_menu .flistctxmenu makemenu $flist_menu {
@@ -6581,6 +6612,7 @@ proc drawtags {id x xt y1} { set marks {} set ntags 0+ set ntags_copy 0 set nheads 0 set singletag 0 set maxtags 3
@@ -6592,6 +6624,7 @@ proc drawtags {id x xt y1} { if {[info exists idtags($id)]} { set marks $idtags($id) set ntags [llength $marks]+ set ntags_copy $ntags if {$ntags > $maxtags || [totalwidth $marks mainfont $extra] > $maxwidth} { # show just a single "n tags..." tag
@@ -9582,6 +9669,38 @@ proc branchdia {top valvar uivar} { focus $top.name }+proc mvtago {top prevname} {+ global tagids idheads mainhead mainheadid++ set name [$top.name get]+ set id [$top.sha1 get]+ if {$name eq $prevname} {+ catch {destroy $top}+ return+ }+ if {$name eq {}} {+ error_popup [mc "Please specify a new name for the tag"] $top+ return+ }+ catch {destroy $top}+ nowbusy renametag+ update+ if {[catch {+ eval exec "git tag $name $prevname"+ eval exec "git tag -d $prevname"+ } err]} {+ notbusy renametag+ error_popup $err+ } else {+ notbusy renametag+ removetag $id $prevname+ set tagids($name) $id+ lappend idtags($id) $name+ run refill_reflist+ }++}+ proc mkbrgo {top} { global headids idheads
@@ -9915,6 +10034,17 @@ proc headmenu {x y id head} { tk_popup $headctxmenu $x $y }+# context menu for a tag+proc tagmenu {x y id tag} {+ global tagmenuid tagmenutag tagctxmenu mainhead++ stopfinding+ set tagmenuid $id+ set tagmenutag $tag++ tk_popup $tagctxmenu $x $y+}+ proc cobranch {} { global headmenuid headmenuhead headids global showlocalchanges
@@ -10019,6 +10149,25 @@ proc rmbranch {} { run refill_reflist }+proc rmtag {} {+ global tagmenuid tagmenutag+ global idtags++ set tag $tagmenutag+ set id $tagmenuid++ nowbusy rmtag+ update+ if {[catch {exec git tag -d $tag} err]} {+ notbusy rmtag+ error_popup $err+ return+ }+ removetag $id $tag+ notbusy rmtag+ run refill_reflist+}+ # Display a list of tags and heads proc showrefs {} { global showrefstop bgcolor fgcolor selectbgcolor NS
From: ZheNing Hu via GitGitGadget <hidden> Date: 2021-02-16 13:54:39
From: ZheNing Hu <redacted>
In gitk, we can right-click on the icon of the branch,
and a directory will pop up to provide us with functions
such as "Checkout this branch", "Rename this branch"...,
but we found that the right-click tag icon does not have such
a function , So I learned how to write the branch icon, and
added the following functions "Rename this tag","Remove this tag",
"Copy tag name" to right-click the tag icon. This function is
temporarily supported work on the branch with <=3 tags.
Signed-off-by: ZheNing Hu <redacted>
---
gitk: tag add right click options
This patch want to fix: https://github.com/gitgitgadget/git/issues/855
We can provide for right-clicking the tag icon in gitk Rename this tag",
"Remove this tag", "Copy tag name" function.
For convenience, only the tags on the branch with the number of tags <=3
are processed temporarily.
Thanks!
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-866%2Fadlternative%2Fgitk_tag_new_opt-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-866/adlternative/gitk_tag_new_opt-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/866
Range-diff vs v1:
1: b246cdf06d6e ! 1: f3a5d7d3be9f [RFC] gitk: tag add right click options
@@ Metadata
Author: ZheNing Hu [off-list ref]
## Commit message ##
- [RFC] gitk: tag add right click options
+ gitk: tag add right click options
In gitk, we can right-click on the icon of the branch,
and a directory will pop up to provide us with functions
@@ Commit message
"Copy tag name" to right-click the tag icon. This function is
temporarily supported work on the branch with <=3 tags.
- But now I may need a little help:
- after we successfully deleted or modified the tag,the content
- show on gitk has not changed, and I am stuck here.
-
Signed-off-by: ZheNing Hu [off-list ref]
## gitk-git/gitk ##
@@ gitk-git/gitk: proc removehead {id name} {
unset headids($name)
}
-+proc movetag {id name} {
-+ global tagids idtags
-+
-+ removetag $tagids($name) $name
-+ set tagids($name) $id
-+ lappend idtags($id) $name
-+}
-+
+proc removetag {id name} {
+ global tagids idtags
+
@@ gitk-git/gitk: proc mkbranch {} {
+
+ set val(name) $tagmenutag
+ set val(id) $tagmenuid
-+ set val(command) [list mvtago $top $tagmenutag]
++ set val(command) [list mvtaggo $top $tagmenutag]
+
+ set ui(title) [mc "Rename tag %s" $tagmenutag]
+ set ui(accept) [mc "Rename"]
@@ gitk-git/gitk: proc branchdia {top valvar uivar} {
focus $top.name
}
-+proc mvtago {top prevname} {
-+ global tagids idheads mainhead mainheadid
++proc mvtaggo {top prevname} {
++ global tagids idtags idheads mainhead mainheadid
+
+ set name [$top.name get]
+ set id [$top.sha1 get]
@@ gitk-git/gitk: proc branchdia {top valvar uivar} {
+ nowbusy renametag
+ update
+ if {[catch {
++ # NOTE: for an annotated tag, the new tag points to the old tag object
++ # where the old primary tag name is still recorded inside. Acceptable.
+ eval exec "git tag $name $prevname"
+ eval exec "git tag -d $prevname"
-+ } err]} {
++ } err]} {
+ notbusy renametag
+ error_popup $err
+ } else {
@@ gitk-git/gitk: proc branchdia {top valvar uivar} {
+ removetag $id $prevname
+ set tagids($name) $id
+ lappend idtags($id) $name
++ redrawtags $id
++ addedtag $id
++ dispneartags 0
+ run refill_reflist
+ }
+
@@ gitk-git/gitk: proc rmbranch {} {
+ return
+ }
+ removetag $id $tag
++ redrawtags $id
+ notbusy rmtag
+ run refill_reflist
+}
gitk-git/gitk | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 147 insertions(+)
@@ -1874,6 +1874,20 @@ proc removehead {id name} { unset headids($name) }+proc removetag {id name} {+ global tagids idtags++ if {$idtags($id) eq $name} {+ unset idtags($id)+ } else {+ set i [lsearch -exact $idtags($id) $name]+ if {$i >= 0} {+ set idtags($id) [lreplace $idtags($id) $i $i]+ }+ }+ unset tagids($name)+}+ proc ttk_toplevel {w args} { global use_ttk eval [linsert $args 0 ::toplevel $w]
@@ -2077,6 +2091,7 @@ proc makewindow {} { global filesepbgcolor filesepfgcolor global mergecolors foundbgcolor currentsearchhitbgcolor global headctxmenu progresscanv progressitem progresscoords statusw+ global tagctxmenu global fprogitem fprogcoord lastprogupdate progupdatepending global rprogitem rprogcoord rownumsel numcommits global have_tk85 use_ttk NS
@@ -2685,6 +2700,14 @@ proc makewindow {} { } $headctxmenu configure -tearoff 0+ set tagctxmenu .tagctxmenu+ makemenu $tagctxmenu {+ {mc "Rename this tag" command mvtag}+ {mc "Remove this tag" command rmtag}+ {mc "Copy tag name" command {clipboard clear; clipboard append $tagmenutag}}+ }+ $tagctxmenu configure -tearoff 0+ global flist_menu set flist_menu .flistctxmenu makemenu $flist_menu {
@@ -6581,6 +6604,7 @@ proc drawtags {id x xt y1} { set marks {} set ntags 0+ set ntags_copy 0 set nheads 0 set singletag 0 set maxtags 3
@@ -6592,6 +6616,7 @@ proc drawtags {id x xt y1} { if {[info exists idtags($id)]} { set marks $idtags($id) set ntags [llength $marks]+ set ntags_copy $ntags if {$ntags > $maxtags || [totalwidth $marks mainfont $extra] > $maxwidth} { # show just a single "n tags..." tag
@@ -9582,6 +9661,43 @@ proc branchdia {top valvar uivar} { focus $top.name }+proc mvtaggo {top prevname} {+ global tagids idtags idheads mainhead mainheadid++ set name [$top.name get]+ set id [$top.sha1 get]+ if {$name eq $prevname} {+ catch {destroy $top}+ return+ }+ if {$name eq {}} {+ error_popup [mc "Please specify a new name for the tag"] $top+ return+ }+ catch {destroy $top}+ nowbusy renametag+ update+ if {[catch {+ # NOTE: for an annotated tag, the new tag points to the old tag object+ # where the old primary tag name is still recorded inside. Acceptable.+ eval exec "git tag $name $prevname"+ eval exec "git tag -d $prevname"+ } err]} {+ notbusy renametag+ error_popup $err+ } else {+ notbusy renametag+ removetag $id $prevname+ set tagids($name) $id+ lappend idtags($id) $name+ redrawtags $id+ addedtag $id+ dispneartags 0+ run refill_reflist+ }++}+ proc mkbrgo {top} { global headids idheads
@@ -9915,6 +10031,17 @@ proc headmenu {x y id head} { tk_popup $headctxmenu $x $y }+# context menu for a tag+proc tagmenu {x y id tag} {+ global tagmenuid tagmenutag tagctxmenu mainhead++ stopfinding+ set tagmenuid $id+ set tagmenutag $tag++ tk_popup $tagctxmenu $x $y+}+ proc cobranch {} { global headmenuid headmenuhead headids global showlocalchanges
@@ -10019,6 +10146,26 @@ proc rmbranch {} { run refill_reflist }+proc rmtag {} {+ global tagmenuid tagmenutag+ global idtags++ set tag $tagmenutag+ set id $tagmenuid++ nowbusy rmtag+ update+ if {[catch {exec git tag -d $tag} err]} {+ notbusy rmtag+ error_popup $err+ return+ }+ removetag $id $tag+ redrawtags $id+ notbusy rmtag+ run refill_reflist+}+ # Display a list of tags and heads proc showrefs {} { global showrefstop bgcolor fgcolor selectbgcolor NS
From: ZheNing Hu via GitGitGadget <hidden> Date: 2021-02-18 16:57:00
From: ZheNing Hu <redacted>
In gitk, we can right-click on the icon of the branch,
and a directory will pop up to provide us with functions
such as "Checkout this branch", "Rename this branch"...,
but we found that the right-click tag icon does not have such
a function , So I learned how to write the branch icon, and
added the following functions "Rename this tag","Remove this tag",
"Copy tag name" to right-click the tag icon. This function is
temporarily supported work on the branch with <=3 tags.
Signed-off-by: ZheNing Hu <redacted>
---
gitk: tag add right click options
This patch want to fix: https://github.com/gitgitgadget/git/issues/855
We can provide for right-clicking the tag icon in gitk Rename this tag",
"Remove this tag", "Copy tag name" function.
For convenience, only the tags on the branch with the number of tags <=3
are processed temporarily.
Thanks!
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-866%2Fadlternative%2Fgitk_tag_new_opt-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-866/adlternative/gitk_tag_new_opt-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/866
Range-diff vs v2:
1: f3a5d7d3be9f ! 1: 52ca9bcfa52f gitk: tag add right click options
@@ gitk-git/gitk: proc makewindow {} {
global rprogitem rprogcoord rownumsel numcommits
global have_tk85 use_ttk NS
@@ gitk-git/gitk: proc makewindow {} {
+ set headctxmenu .headctxmenu
+ makemenu $headctxmenu {
+ {mc "Check out this branch" command cobranch}
+- {mc "Rename this branch" command mvbranch}
++ {mc "Rename this branch..." command mvbranch}
+ {mc "Remove this branch" command rmbranch}
+ {mc "Copy branch name" command {clipboard clear; clipboard append $headmenuhead}}
}
$headctxmenu configure -tearoff 0
+ set tagctxmenu .tagctxmenu
+ makemenu $tagctxmenu {
-+ {mc "Rename this tag" command mvtag}
-+ {mc "Remove this tag" command rmtag}
++ {mc "Rename this tag..." command mvtag}
++ {mc "Remove this tag..." command rmtag}
+ {mc "Copy tag name" command {clipboard clear; clipboard append $tagmenutag}}
+ }
+ $tagctxmenu configure -tearoff 0
@@ gitk-git/gitk: proc branchdia {top valvar uivar} {
+ } else {
+ notbusy renametag
+ removetag $id $prevname
++ removedtag $id $tag
+ set tagids($name) $id
+ lappend idtags($id) $name
-+ redrawtags $id
+ addedtag $id
++ redrawtags $id
+ dispneartags 0
+ run refill_reflist
+ }
@@ gitk-git/gitk: proc rmbranch {} {
+
+ set tag $tagmenutag
+ set id $tagmenuid
-+
++ if {![confirm_popup [mc "Really delete tag %s?" $tag]]} return
+ nowbusy rmtag
+ update
+ if {[catch {exec git tag -d $tag} err]} {
@@ gitk-git/gitk: proc rmbranch {} {
+ return
+ }
+ removetag $id $tag
++ removedtag $id $tag
+ redrawtags $id
+ notbusy rmtag
++ dispneartags 0
+ run refill_reflist
+}
+
# Display a list of tags and heads
proc showrefs {} {
global showrefstop bgcolor fgcolor selectbgcolor NS
+@@ gitk-git/gitk: proc addedtag {id} {
+ unset -nocomplain cached_atags
+ }
+
++proc removedtag {id tag} {
++ global cached_dtags cached_atags cached_tagcontent
++
++ unset -nocomplain cached_tagcontent
++ unset -nocomplain cached_dtags
++ unset -nocomplain cached_atags
++}
++
+ proc addedhead {hid head} {
+ global arcnos arcout cached_dheads
+
gitk-git/gitk | 160 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 159 insertions(+), 1 deletion(-)
@@ -1874,6 +1874,20 @@ proc removehead {id name} { unset headids($name) }+proc removetag {id name} {+ global tagids idtags++ if {$idtags($id) eq $name} {+ unset idtags($id)+ } else {+ set i [lsearch -exact $idtags($id) $name]+ if {$i >= 0} {+ set idtags($id) [lreplace $idtags($id) $i $i]+ }+ }+ unset tagids($name)+}+ proc ttk_toplevel {w args} { global use_ttk eval [linsert $args 0 ::toplevel $w]
@@ -2077,6 +2091,7 @@ proc makewindow {} { global filesepbgcolor filesepfgcolor global mergecolors foundbgcolor currentsearchhitbgcolor global headctxmenu progresscanv progressitem progresscoords statusw+ global tagctxmenu global fprogitem fprogcoord lastprogupdate progupdatepending global rprogitem rprogcoord rownumsel numcommits global have_tk85 use_ttk NS
@@ -2679,12 +2694,20 @@ proc makewindow {} { set headctxmenu .headctxmenu makemenu $headctxmenu { {mc "Check out this branch" command cobranch}- {mc "Rename this branch" command mvbranch}+ {mc "Rename this branch..." command mvbranch} {mc "Remove this branch" command rmbranch} {mc "Copy branch name" command {clipboard clear; clipboard append $headmenuhead}} } $headctxmenu configure -tearoff 0+ set tagctxmenu .tagctxmenu+ makemenu $tagctxmenu {+ {mc "Rename this tag..." command mvtag}+ {mc "Remove this tag..." command rmtag}+ {mc "Copy tag name" command {clipboard clear; clipboard append $tagmenutag}}+ }+ $tagctxmenu configure -tearoff 0+ global flist_menu set flist_menu .flistctxmenu makemenu $flist_menu {
@@ -6581,6 +6604,7 @@ proc drawtags {id x xt y1} { set marks {} set ntags 0+ set ntags_copy 0 set nheads 0 set singletag 0 set maxtags 3
@@ -6592,6 +6616,7 @@ proc drawtags {id x xt y1} { if {[info exists idtags($id)]} { set marks $idtags($id) set ntags [llength $marks]+ set ntags_copy $ntags if {$ntags > $maxtags || [totalwidth $marks mainfont $extra] > $maxwidth} { # show just a single "n tags..." tag
@@ -9582,6 +9661,44 @@ proc branchdia {top valvar uivar} { focus $top.name }+proc mvtaggo {top prevname} {+ global tagids idtags idheads mainhead mainheadid++ set name [$top.name get]+ set id [$top.sha1 get]+ if {$name eq $prevname} {+ catch {destroy $top}+ return+ }+ if {$name eq {}} {+ error_popup [mc "Please specify a new name for the tag"] $top+ return+ }+ catch {destroy $top}+ nowbusy renametag+ update+ if {[catch {+ # NOTE: for an annotated tag, the new tag points to the old tag object+ # where the old primary tag name is still recorded inside. Acceptable.+ eval exec "git tag $name $prevname"+ eval exec "git tag -d $prevname"+ } err]} {+ notbusy renametag+ error_popup $err+ } else {+ notbusy renametag+ removetag $id $prevname+ removedtag $id $tag+ set tagids($name) $id+ lappend idtags($id) $name+ addedtag $id+ redrawtags $id+ dispneartags 0+ run refill_reflist+ }++}+ proc mkbrgo {top} { global headids idheads
@@ -9915,6 +10032,17 @@ proc headmenu {x y id head} { tk_popup $headctxmenu $x $y }+# context menu for a tag+proc tagmenu {x y id tag} {+ global tagmenuid tagmenutag tagctxmenu mainhead++ stopfinding+ set tagmenuid $id+ set tagmenutag $tag++ tk_popup $tagctxmenu $x $y+}+ proc cobranch {} { global headmenuid headmenuhead headids global showlocalchanges
@@ -10019,6 +10147,28 @@ proc rmbranch {} { run refill_reflist }+proc rmtag {} {+ global tagmenuid tagmenutag+ global idtags++ set tag $tagmenutag+ set id $tagmenuid+ if {![confirm_popup [mc "Really delete tag %s?" $tag]]} return+ nowbusy rmtag+ update+ if {[catch {exec git tag -d $tag} err]} {+ notbusy rmtag+ error_popup $err+ return+ }+ removetag $id $tag+ removedtag $id $tag+ redrawtags $id+ notbusy rmtag+ dispneartags 0+ run refill_reflist+}+ # Display a list of tags and heads proc showrefs {} { global showrefstop bgcolor fgcolor selectbgcolor NS
From: ZheNing Hu via GitGitGadget <hidden> Date: 2021-02-24 10:59:33
From: ZheNing Hu <redacted>
In gitk, we can right-click on the icon of the branch,
and a directory will pop up to provide us with functions
such as "Checkout this branch", "Rename this branch"...,
but we found that the right-click tag icon does not have
such a function , So I learned how to write the branch icon,
and added the following functions "Rename this tag",
"Remove this tag", "Copy tag name" to right-click the tag icon.
This function temporarily only supports those labels independently
displayed tag(s), and cannot work on label aggregated display
"tag..." or "n tags...".
Signed-off-by: ZheNing Hu <redacted>
---
gitk: tag add right click options
This patch want to fix: https://github.com/gitgitgadget/git/issues/855
We can provide for right-clicking the tag icon in gitk Rename this tag",
"Remove this tag", "Copy tag name" function.
For convenience, only the tags on the branch with the number of tags <=3
are processed temporarily.
Thanks!
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-866%2Fadlternative%2Fgitk_tag_new_opt-v4
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-866/adlternative/gitk_tag_new_opt-v4
Pull-Request: https://github.com/gitgitgadget/git/pull/866
Range-diff vs v3:
1: 52ca9bcfa52f ! 1: c8b0dfa6628e gitk: tag add right click options
@@ Commit message
In gitk, we can right-click on the icon of the branch,
and a directory will pop up to provide us with functions
such as "Checkout this branch", "Rename this branch"...,
- but we found that the right-click tag icon does not have such
- a function , So I learned how to write the branch icon, and
- added the following functions "Rename this tag","Remove this tag",
- "Copy tag name" to right-click the tag icon. This function is
- temporarily supported work on the branch with <=3 tags.
+ but we found that the right-click tag icon does not have
+ such a function , So I learned how to write the branch icon,
+ and added the following functions "Rename this tag",
+ "Remove this tag", "Copy tag name" to right-click the tag icon.
+
+ This function temporarily only supports those labels independently
+ displayed tag(s), and cannot work on label aggregated display
+ "tag..." or "n tags...".
Signed-off-by: ZheNing Hu [off-list ref]
@@ gitk-git/gitk: proc drawtags {id x xt y1} {
if {[info exists idtags($id)]} {
set marks $idtags($id)
set ntags [llength $marks]
+- if {$ntags > $maxtags ||
+- [totalwidth $marks mainfont $extra] > $maxwidth} {
+ set ntags_copy $ntags
- if {$ntags > $maxtags ||
- [totalwidth $marks mainfont $extra] > $maxwidth} {
++ set out_of_bounds [expr {[totalwidth $marks mainfont $extra] > $maxwidth}]
++ if {$ntags > $maxtags || $out_of_bounds} {
# show just a single "n tags..." tag
+ set singletag 1
+ if {$ntags == 1} {
@@ gitk-git/gitk: proc drawtags {id x xt y1} {
-font $font -tags [list tag.$id text]]
if {$ntags >= 0} {
$canv bind $t <1> $tagclick
-+ if {$ntags_copy < $maxtags} {
++ if {$ntags_copy <= $maxtags && !$out_of_bounds} {
+ $canv bind $t $ctxbut [list tagmenu %X %Y $id $tag_quoted]
+ }
} elseif {$nheads >= 0} {
gitk-git/gitk | 164 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 161 insertions(+), 3 deletions(-)
@@ -1874,6 +1874,20 @@ proc removehead {id name} { unset headids($name) }+proc removetag {id name} {+ global tagids idtags++ if {$idtags($id) eq $name} {+ unset idtags($id)+ } else {+ set i [lsearch -exact $idtags($id) $name]+ if {$i >= 0} {+ set idtags($id) [lreplace $idtags($id) $i $i]+ }+ }+ unset tagids($name)+}+ proc ttk_toplevel {w args} { global use_ttk eval [linsert $args 0 ::toplevel $w]
@@ -2077,6 +2091,7 @@ proc makewindow {} { global filesepbgcolor filesepfgcolor global mergecolors foundbgcolor currentsearchhitbgcolor global headctxmenu progresscanv progressitem progresscoords statusw+ global tagctxmenu global fprogitem fprogcoord lastprogupdate progupdatepending global rprogitem rprogcoord rownumsel numcommits global have_tk85 use_ttk NS
@@ -2679,12 +2694,20 @@ proc makewindow {} { set headctxmenu .headctxmenu makemenu $headctxmenu { {mc "Check out this branch" command cobranch}- {mc "Rename this branch" command mvbranch}+ {mc "Rename this branch..." command mvbranch} {mc "Remove this branch" command rmbranch} {mc "Copy branch name" command {clipboard clear; clipboard append $headmenuhead}} } $headctxmenu configure -tearoff 0+ set tagctxmenu .tagctxmenu+ makemenu $tagctxmenu {+ {mc "Rename this tag..." command mvtag}+ {mc "Remove this tag..." command rmtag}+ {mc "Copy tag name" command {clipboard clear; clipboard append $tagmenutag}}+ }+ $tagctxmenu configure -tearoff 0+ global flist_menu set flist_menu .flistctxmenu makemenu $flist_menu {
@@ -6581,6 +6604,7 @@ proc drawtags {id x xt y1} { set marks {} set ntags 0+ set ntags_copy 0 set nheads 0 set singletag 0 set maxtags 3
@@ -6592,8 +6616,9 @@ proc drawtags {id x xt y1} { if {[info exists idtags($id)]} { set marks $idtags($id) set ntags [llength $marks]- if {$ntags > $maxtags ||- [totalwidth $marks mainfont $extra] > $maxwidth} {+ set ntags_copy $ntags+ set out_of_bounds [expr {[totalwidth $marks mainfont $extra] > $maxwidth}]+ if {$ntags > $maxtags || $out_of_bounds} { # show just a single "n tags..." tag set singletag 1 if {$ntags == 1} {
@@ -9582,6 +9661,44 @@ proc branchdia {top valvar uivar} { focus $top.name }+proc mvtaggo {top prevname} {+ global tagids idtags idheads mainhead mainheadid++ set name [$top.name get]+ set id [$top.sha1 get]+ if {$name eq $prevname} {+ catch {destroy $top}+ return+ }+ if {$name eq {}} {+ error_popup [mc "Please specify a new name for the tag"] $top+ return+ }+ catch {destroy $top}+ nowbusy renametag+ update+ if {[catch {+ # NOTE: for an annotated tag, the new tag points to the old tag object+ # where the old primary tag name is still recorded inside. Acceptable.+ eval exec "git tag $name $prevname"+ eval exec "git tag -d $prevname"+ } err]} {+ notbusy renametag+ error_popup $err+ } else {+ notbusy renametag+ removetag $id $prevname+ removedtag $id $tag+ set tagids($name) $id+ lappend idtags($id) $name+ addedtag $id+ redrawtags $id+ dispneartags 0+ run refill_reflist+ }++}+ proc mkbrgo {top} { global headids idheads
@@ -9915,6 +10032,17 @@ proc headmenu {x y id head} { tk_popup $headctxmenu $x $y }+# context menu for a tag+proc tagmenu {x y id tag} {+ global tagmenuid tagmenutag tagctxmenu mainhead++ stopfinding+ set tagmenuid $id+ set tagmenutag $tag++ tk_popup $tagctxmenu $x $y+}+ proc cobranch {} { global headmenuid headmenuhead headids global showlocalchanges
@@ -10019,6 +10147,28 @@ proc rmbranch {} { run refill_reflist }+proc rmtag {} {+ global tagmenuid tagmenutag+ global idtags++ set tag $tagmenutag+ set id $tagmenuid+ if {![confirm_popup [mc "Really delete tag %s?" $tag]]} return+ nowbusy rmtag+ update+ if {[catch {exec git tag -d $tag} err]} {+ notbusy rmtag+ error_popup $err+ return+ }+ removetag $id $tag+ removedtag $id $tag+ redrawtags $id+ notbusy rmtag+ dispneartags 0+ run refill_reflist+}+ # Display a list of tags and heads proc showrefs {} { global showrefstop bgcolor fgcolor selectbgcolor NS
From: ZheNing Hu via GitGitGadget <hidden> Date: 2021-02-25 04:39:47
From: ZheNing Hu <redacted>
Adds a context menu for tag icons with commands similar to what
exits for branches: "Rename this tag", "Remove this tag",
"Copy tag name".
Signed-off-by: ZheNing Hu <redacted>
---
gitk: add right-click context menu for tags
This patch want to fix: https://github.com/gitgitgadget/git/issues/855
We can provide for right-clicking the tag icon in gitk Rename this tag",
"Remove this tag", "Copy tag name" function.
For convenience, only the tags on the branch with the number of tags <=3
are processed temporarily.
Thanks!
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-866%2Fadlternative%2Fgitk_tag_new_opt-v5
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-866/adlternative/gitk_tag_new_opt-v5
Pull-Request: https://github.com/gitgitgadget/git/pull/866
Range-diff vs v4:
1: c8b0dfa6628e ! 1: e7cdb01c1b0f gitk: tag add right click options
@@ Metadata
Author: ZheNing Hu [off-list ref]
## Commit message ##
- gitk: tag add right click options
+ gitk: add right-click context menu for tags
- In gitk, we can right-click on the icon of the branch,
- and a directory will pop up to provide us with functions
- such as "Checkout this branch", "Rename this branch"...,
- but we found that the right-click tag icon does not have
- such a function , So I learned how to write the branch icon,
- and added the following functions "Rename this tag",
- "Remove this tag", "Copy tag name" to right-click the tag icon.
-
- This function temporarily only supports those labels independently
- displayed tag(s), and cannot work on label aggregated display
- "tag..." or "n tags...".
+ Adds a context menu for tag icons with commands similar to what
+ exits for branches: "Rename this tag", "Remove this tag",
+ "Copy tag name".
Signed-off-by: ZheNing Hu [off-list ref]
@@ gitk-git/gitk: proc branchdia {top valvar uivar} {
+ } else {
+ notbusy renametag
+ removetag $id $prevname
-+ removedtag $id $tag
++ removedtag $id $prevname
+ set tagids($name) $id
+ lappend idtags($id) $name
+ addedtag $id
gitk-git/gitk | 164 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 161 insertions(+), 3 deletions(-)
@@ -1874,6 +1874,20 @@ proc removehead {id name} { unset headids($name) }+proc removetag {id name} {+ global tagids idtags++ if {$idtags($id) eq $name} {+ unset idtags($id)+ } else {+ set i [lsearch -exact $idtags($id) $name]+ if {$i >= 0} {+ set idtags($id) [lreplace $idtags($id) $i $i]+ }+ }+ unset tagids($name)+}+ proc ttk_toplevel {w args} { global use_ttk eval [linsert $args 0 ::toplevel $w]
@@ -2077,6 +2091,7 @@ proc makewindow {} { global filesepbgcolor filesepfgcolor global mergecolors foundbgcolor currentsearchhitbgcolor global headctxmenu progresscanv progressitem progresscoords statusw+ global tagctxmenu global fprogitem fprogcoord lastprogupdate progupdatepending global rprogitem rprogcoord rownumsel numcommits global have_tk85 use_ttk NS
@@ -2679,12 +2694,20 @@ proc makewindow {} { set headctxmenu .headctxmenu makemenu $headctxmenu { {mc "Check out this branch" command cobranch}- {mc "Rename this branch" command mvbranch}+ {mc "Rename this branch..." command mvbranch} {mc "Remove this branch" command rmbranch} {mc "Copy branch name" command {clipboard clear; clipboard append $headmenuhead}} } $headctxmenu configure -tearoff 0+ set tagctxmenu .tagctxmenu+ makemenu $tagctxmenu {+ {mc "Rename this tag..." command mvtag}+ {mc "Remove this tag..." command rmtag}+ {mc "Copy tag name" command {clipboard clear; clipboard append $tagmenutag}}+ }+ $tagctxmenu configure -tearoff 0+ global flist_menu set flist_menu .flistctxmenu makemenu $flist_menu {
@@ -6581,6 +6604,7 @@ proc drawtags {id x xt y1} { set marks {} set ntags 0+ set ntags_copy 0 set nheads 0 set singletag 0 set maxtags 3
@@ -6592,8 +6616,9 @@ proc drawtags {id x xt y1} { if {[info exists idtags($id)]} { set marks $idtags($id) set ntags [llength $marks]- if {$ntags > $maxtags ||- [totalwidth $marks mainfont $extra] > $maxwidth} {+ set ntags_copy $ntags+ set out_of_bounds [expr {[totalwidth $marks mainfont $extra] > $maxwidth}]+ if {$ntags > $maxtags || $out_of_bounds} { # show just a single "n tags..." tag set singletag 1 if {$ntags == 1} {
@@ -9582,6 +9661,44 @@ proc branchdia {top valvar uivar} { focus $top.name }+proc mvtaggo {top prevname} {+ global tagids idtags idheads mainhead mainheadid++ set name [$top.name get]+ set id [$top.sha1 get]+ if {$name eq $prevname} {+ catch {destroy $top}+ return+ }+ if {$name eq {}} {+ error_popup [mc "Please specify a new name for the tag"] $top+ return+ }+ catch {destroy $top}+ nowbusy renametag+ update+ if {[catch {+ # NOTE: for an annotated tag, the new tag points to the old tag object+ # where the old primary tag name is still recorded inside. Acceptable.+ eval exec "git tag $name $prevname"+ eval exec "git tag -d $prevname"+ } err]} {+ notbusy renametag+ error_popup $err+ } else {+ notbusy renametag+ removetag $id $prevname+ removedtag $id $prevname+ set tagids($name) $id+ lappend idtags($id) $name+ addedtag $id+ redrawtags $id+ dispneartags 0+ run refill_reflist+ }++}+ proc mkbrgo {top} { global headids idheads
@@ -9915,6 +10032,17 @@ proc headmenu {x y id head} { tk_popup $headctxmenu $x $y }+# context menu for a tag+proc tagmenu {x y id tag} {+ global tagmenuid tagmenutag tagctxmenu mainhead++ stopfinding+ set tagmenuid $id+ set tagmenutag $tag++ tk_popup $tagctxmenu $x $y+}+ proc cobranch {} { global headmenuid headmenuhead headids global showlocalchanges
@@ -10019,6 +10147,28 @@ proc rmbranch {} { run refill_reflist }+proc rmtag {} {+ global tagmenuid tagmenutag+ global idtags++ set tag $tagmenutag+ set id $tagmenuid+ if {![confirm_popup [mc "Really delete tag %s?" $tag]]} return+ nowbusy rmtag+ update+ if {[catch {exec git tag -d $tag} err]} {+ notbusy rmtag+ error_popup $err+ return+ }+ removetag $id $tag+ removedtag $id $tag+ redrawtags $id+ notbusy rmtag+ dispneartags 0+ run refill_reflist+}+ # Display a list of tags and heads proc showrefs {} { global showrefstop bgcolor fgcolor selectbgcolor NS