From: Rogier Goossens <goossens.rogier@gmail.com>
To: git@vger.kernel.org
Cc: Paul Mackerras <paulus@samba.org>
Subject: [PATCH 1/2] gitk: Add a 'rename' option to the branch context menu
Date: Fri, 15 Jan 2016 22:38:49 +0100 [thread overview]
Message-ID: <1859807.50qitjY8Ul@wiske> (raw)
In-Reply-To: <51900395.pKIx87RN0F@wiske>
Signed-off-by: Rogier Goossens <goossens.rogier@gmail.com>
---
gitk | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 84 insertions(+), 5 deletions(-)
diff --git a/gitk b/gitk
index 5f1255c..e9465fb 100755
--- a/gitk
+++ b/gitk
@@ -2665,6 +2665,7 @@ proc makewindow {} {
makemenu $headctxmenu {
{mc "Check out this branch" command cobranch}
{mc "Remove this branch" command rmbranch}
+ {mc "Rename this branch" command mvbranch}
{mc "Copy branch name" command {clipboard clear; clipboard append $headmenuhead}}
}
$headctxmenu configure -tearoff 0
@@ -9526,6 +9527,80 @@ proc mkbrgo {top} {
}
}
+proc mvbranch {} {
+ global mvbrtop NS
+ global headmenuid headmenuhead
+
+ set prevname $headmenuhead
+ set id $headmenuid
+
+ set top .renamebranch
+ catch {destroy $top}
+ ttk_toplevel $top
+ make_transient $top .
+ ${NS}::label $top.title -text [mc "Rename branch %s" $prevname]
+ grid $top.title - -pady 10
+ ${NS}::label $top.id -text [mc "ID:"]
+ ${NS}::entry $top.sha1 -width 40
+ $top.sha1 insert 0 $id
+ $top.sha1 conf -state readonly
+ grid $top.id $top.sha1 -sticky w
+ ${NS}::label $top.nlab -text [mc "Name:"]
+ ${NS}::entry $top.name -width 40
+ $top.name insert 0 $prevname
+ grid $top.nlab $top.name -sticky w
+ ${NS}::frame $top.buts
+ ${NS}::button $top.buts.go -text [mc "Rename"] -command [list mvbrgo $top $prevname]
+ ${NS}::button $top.buts.can -text [mc "Cancel"] -command "catch {destroy $top}"
+ bind $top <Key-Return> [list mvbrgo $top $prevname]
+ bind $top <Key-Escape> "catch {destroy $top}"
+ grid $top.buts.go $top.buts.can
+ grid columnconfigure $top.buts 0 -weight 1 -uniform a
+ grid columnconfigure $top.buts 1 -weight 1 -uniform a
+ grid $top.buts - -pady 10 -sticky ew
+ focus $top.name
+}
+
+proc mvbrgo {top prevname} {
+ global headids idheads mainhead mainheadid
+
+ set name [$top.name get]
+ set id [$top.sha1 get]
+ set cmdargs {}
+ if {$name eq $prevname} {
+ catch {destroy $top}
+ return
+ }
+ if {$name eq {}} {
+ error_popup [mc "Please specify a new name for the branch"] $top
+ return
+ }
+ catch {destroy $top}
+ lappend cmdargs -m $prevname $name
+ nowbusy renamebranch
+ update
+ if {[catch {
+ eval exec git branch $cmdargs
+ } err]} {
+ notbusy renamebranch
+ error_popup $err
+ } else {
+ notbusy renamebranch
+ removehead $id $prevname
+ removedhead $id $prevname
+ set headids($name) $id
+ lappend idheads($id) $name
+ addedhead $id $name
+ if {$prevname eq $mainhead} {
+ set mainhead $name
+ set mainheadid $id
+ }
+ redrawtags $id
+ dispneartags 0
+ run refill_reflist
+ }
+}
+
proc exec_citool {tool_args {baseid {}}} {
global commitinfo env
@@ -9756,15 +9831,19 @@ proc headmenu {x y id head} {
stopfinding
set headmenuid $id
set headmenuhead $head
- set state normal
+ array set state {0 normal 1 normal 2 normal 3 normal}
if {[string match "remotes/*" $head]} {
- set state disabled
+ set state(0) disabled
+ set state(1) disabled
+ set state(2) disabled
}
if {$head eq $mainhead} {
- set state disabled
+ set state(0) disabled
+ set state(1) disabled
+ }
+ foreach i {0 1 2 3} {
+ $headctxmenu entryconfigure $i -state $state($i)
}
- $headctxmenu entryconfigure 0 -state $state
- $headctxmenu entryconfigure 1 -state $state
tk_popup $headctxmenu $x $y
}
--
2.1.4
next prev parent reply other threads:[~2016-01-15 21:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-15 21:31 [PATCH 0/2] gitk: Two improvements to the branch context menu Rogier Goossens
2016-01-15 21:38 ` Rogier Goossens [this message]
2016-03-19 3:45 ` [PATCH 1/2] gitk: Add a 'rename' option " Paul Mackerras
2016-01-15 21:43 ` [PATCH 2/2] gitk: Allow checking out a remote branch Rogier Goossens
2016-03-19 18:31 ` [PATCH v2 0/2] gitk: Two improvements to the branch context menu Rogier Goossens
2016-03-19 18:32 ` [PATCH 1/2] gitk: Add a 'rename' option " Rogier Goossens
2016-03-19 18:33 ` [PATCH 2/2] gitk: Allow checking out a remote branch Rogier Goossens
2016-03-27 7:21 ` [PATCH v2a 3/3] gitk: Include commit title in branch dialog Rogier Goossens
2016-12-12 0:02 ` [PATCH v2 0/2] gitk: Two improvements to the branch context menu Paul Mackerras
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1859807.50qitjY8Ul@wiske \
--to=goossens.rogier@gmail.com \
--cc=git@vger.kernel.org \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.