Extend git gui for better "centralized" workflow integration
cover Extend git gui for better "centralized" workflow integration
This series is adding some more support for a centralized workflow with code review based on feature branches. Most of it is plugging existing functionality together so the most typical steps can be done at once.
In our team at $dayjob we use a workflow were each developer creates feature branches and once he is satified with his change he sends out a review request to another developer (the reviewer) which is most familiar with the code parts involved in the change. If the reviewer likes the change he merges it into the upstream branch (master). He then publishes the new master and deletes the feature branch. Thats a quick description of the workflow I am trying to add more support for with this series.
There are still some TODO markers in there and if someone can help me with those I would be very glad. This is the first time I am doing some more extensive programming in tcl/tk and git gui so I hope you do not tear everything apart ;)
The last patch is not really about the same topic but since it currently relies on the changes of this series I included it nevertheless.
cheers Heiko
Heiko Voigt (8):
git gui: add a "compose review email" checkbox to push dialog git gui: teach delete dialog to open with a default remote git gui: add checkbox to launch remote branch delete after push git gui: teach fetch operation to close dialog on successful
completion
git gui: do fetch from a default remote on startup
git gui: add "review topic" menuitem which supports feature branch
workflow
Add documentation for git gui variables for email and delete after
push
git gui: make gc hint and fetch on startup sequential
Documentation/config.txt | 30 ++++++++++ git-gui/git-gui.sh | 29 ++++++++- git-gui/lib/console.tcl | 6 ++ git-gui/lib/merge.tcl | 83 ++++++++++++++++++++++++-- git-gui/lib/option.tcl | 5 ++ git-gui/lib/remote_branch_delete.tcl | 6 +- git-gui/lib/transport.tcl | 107 ++++++++++++++++++++++++++++++++- 7 files changed, 250 insertions(+), 16 deletions(-)
RFC PATCH 1/8 git gui: add a "compose review email" checkbox to push dialog
This is useful when working with a central server. If a developer wants to send his changes to a reviewer we can help him fill out the necessary information about the branch he has pushed and launch his default email composer.
Composition of such an email is currently only allowed for pushing one branch because the subject line size is limited.
--- git-gui/git-gui.sh | 2 + git-gui/lib/option.tcl | 2 + git-gui/lib/transport.tcl | 75 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 77 insertions(+), 2 deletions(-)
git-gui/git-gui.sh +2 -0
@@ -737,6 +737,8 @@ set default_config(gui.matchtrackingbranch) false set default_config(gui.pruneduringfetch) false set default_config(gui.trustmtime) false set default_config(gui.fastcopyblame) false +set default_config(gui.emailafterpush) false +set default_config(gui.upstreambranch) {master} set default_config(gui.copyblamethreshold) 40 set default_config(gui.blamehistoryctx) 7 set default_config(gui.diffcontext) 5
git-gui/lib/option.tcl +2 -0
@@ -147,6 +147,8 @@ proc do_options {} { {b gui.pruneduringfetch {mc "Prune Tracking Branches During Fetch"}} {b gui.matchtrackingbranch {mc "Match Tracking Branches"}} {b gui.fastcopyblame {mc "Blame Copy Only On Changed Files"}} + {b gui.emailafterpush {mc "Open Email Composer after Push of Feature Branch"}} + {t gui.upstreambranch {mc "Upstream branch"}} {i-20..200 gui.copyblamethreshold {mc "Minimum Letters To Blame Copy On"}} {i-0..300 gui.blamehistoryctx {mc "Blame History Context Radius (days)"}} {i-1..99 gui.diffcontext {mc "Number of Diff Context Lines"}}
git-gui/lib/transport.tcl +73 -2
124 lines not on this page · raw message
Signature · 1 line
1.6.5.rc1.12.gc72fe
RFC PATCH 2/8 git gui: teach delete dialog to open with a default remote
This is useful if you want to open the delete dialog with a preselected remote. We use this in the next patch from this series.
--- git-gui/lib/remote_branch_delete.tcl | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
git-gui/lib/remote_branch_delete.tcl +3 -3
@@ -22,7 +22,7 @@ field head_cache field full_cache field cached -constructor dialog {} { +constructor dialog {{initial_remote origin}} { global all_remotes M1B make_toplevel top w
@@ -52,8 +52,8 @@ constructor dialog {} { -variable @urltype eval tk_optionMenu $w.dest.remote_m @remote $all_remotes grid $w.dest.remote_r $w.dest.remote_m -sticky w - if {[lsearch -sorted -exact $all_remotes origin] != -1} { - set remote origin + if {[lsearch -sorted -exact $all_remotes $initial_remote] != -1} { + set remote $initial_remote } else { set remote [lindex $all_remotes 0] }
Signature · 1 line
1.6.5.rc1.12.gc72fe
RFC PATCH 3/8 git gui: add checkbox to launch remote branch delete after push
This is useful when working with a central server and feature branches. After a reviewer merged a feature branch into the upstream branch he usually wants to delete this branch on the server after pushing the upstream branch.
Save some clicks and open the delete dialog after pushing the upstream branch.
--- git-gui/git-gui.sh | 1 + git-gui/lib/option.tcl | 1 + git-gui/lib/transport.tcl | 28 ++++++++++++++++++++++++---- 3 files changed, 26 insertions(+), 4 deletions(-)
git-gui/git-gui.sh +1 -0
@@ -738,6 +738,7 @@ set default_config(gui.pruneduringfetch) false set default_config(gui.trustmtime) false set default_config(gui.fastcopyblame) false set default_config(gui.emailafterpush) false +set default_config(gui.deleteafterpush) false set default_config(gui.upstreambranch) {master} set default_config(gui.copyblamethreshold) 40 set default_config(gui.blamehistoryctx) 7
git-gui/lib/option.tcl +1 -0
@@ -148,6 +148,7 @@ proc do_options {} { {b gui.matchtrackingbranch {mc "Match Tracking Branches"}} {b gui.fastcopyblame {mc "Blame Copy Only On Changed Files"}} {b gui.emailafterpush {mc "Open Email Composer after Push of Feature Branch"}} + {b gui.deleteafterpush {mc "Open Remote Delete Dialog On Push of Upstream Branch"}} {t gui.upstreambranch {mc "Upstream branch"}} {i-20..200 gui.copyblamethreshold {mc "Minimum Letters To Blame Copy On"}} {i-0..300 gui.blamehistoryctx {mc "Blame History Context Radius (days)"}}
git-gui/lib/transport.tcl +24 -4
@@ -37,7 +37,7 @@ proc compose_email {to subject} { } proc after_push_anywhere_action {cons ok} { - global push_email r_url branches + global push_email delete_after_push r_url branches console::done $cons $ok
@@ -52,13 +52,21 @@ proc after_push_anywhere_action {cons ok} { set email_subject "Review%20request:%20$remote_short_name:$branches" compose_email {} $email_subject } + if {$delete_after_push} { + remote_branch_delete::dialog $r_url + } } } proc do_push_on_change_branch {w} { global upstream_branch - $w.options.email select + if {[is_config_true gui.emailafterpush]} { + $w.options.email select + } + if {[is_config_true gui.deleteafterpush]} { + $w.options.delete_after_push deselect + } set cnt 0 set b {}
@@ -70,6 +78,7 @@ proc do_push_on_change_branch {w} { if {$cnt != 1} { $w.options.email deselect $w.options.email configure -state disabled + $w.options.delete_after_push deselect return }
@@ -79,6 +88,9 @@ proc do_push_on_change_branch {w} { if {[is_config_true gui.emailafterpush]} { $w.options.email deselect } + if {[is_config_true gui.deleteafterpush]} { + $w.options.delete_after_push select + } } }
@@ -173,7 +185,8 @@ proc do_push_anywhere {} { -width 70 \ -selectmode extended \ -yscrollcommand [list $w.source.sby set] - if {[is_config_true gui.emailafterpush]} { + if {[is_config_true gui.emailafterpush] \ + || [is_config_true gui.deleteafterpush]} { bind $w.source.l <ButtonRelease-1> [list do_push_on_change_branch $w] } foreach h [load_all_heads] {
@@ -243,6 +256,11 @@ proc do_push_anywhere {} { -variable push_email grid $w.options.email -columnspan 2 -sticky w $w.options.email deselect + checkbutton $w.options.delete_after_push \ + -text [mc "Launch delete dialog after push"] \ + -variable delete_after_push + grid $w.options.delete_after_push -columnspan 2 -sticky w + $w.options.delete_after_push deselect grid columnconfigure $w.options 1 -weight 1 pack $w.options -anchor nw -fill x -pady 5 -padx 5
@@ -251,10 +269,12 @@ proc do_push_anywhere {} { set push_thin 0 set push_tags 0 set push_email 0 + set delete_after_push 0 set upstream_branch $repo_config(gui.upstreambranch) - if {[is_config_true gui.emailafterpush]} { + if {[is_config_true gui.emailafterpush] \ + || [is_config_true gui.deleteafterpush]} { do_push_on_change_branch $w }
Signature · 1 line
1.6.5.rc1.12.gc72fe
RFC PATCH 4/8 git gui: teach fetch operation to close dialog on successful completion
--- git-gui/lib/console.tcl | 6 ++++++ git-gui/lib/transport.tcl | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-)
git-gui/lib/console.tcl +6 -0
@@ -168,6 +168,7 @@ method chain {cmdlist {ok 1}} { } else { done $this $ok } + return $ok } method insert {txt} {
@@ -178,6 +179,11 @@ method insert {txt} { $w_t conf -state disabled } +method close_window {} { + wm protocol $w WM_DELETE_WINDOW {} + destroy $w +} + method done {ok} { if {$ok} { if {[winfo exists $w.m.s]} {
git-gui/lib/transport.tcl +10 -2
@@ -1,7 +1,7 @@ # git-gui transport (fetch/push) support # Copyright (C) 2006, 2007 Shawn Pearce -proc fetch_from {remote} { +proc fetch_from {remote {close_after {}}} { set w [console::new \ [mc "fetch %s" $remote] \ [mc "Fetching new changes from %s" $remote]]
@@ -10,7 +10,15 @@ proc fetch_from {remote} { if {[is_config_true gui.pruneduringfetch]} { lappend cmds [list exec git remote prune $remote] } - console::chain $w $cmds + set ok [console::chain $w $cmds] + + if {$ok} { + if {$close_after ne {}} { + console::close_window $w + } + return 1 + } + return 0 } proc prune_from {remote} {
Signature · 1 line
1.6.5.rc1.12.gc72fe
RFC PATCH 5/8 git gui: do fetch from a default remote on startup
In many situations the very first thing you do after starting git gui is to fetch the newest changes from your main remote. Lets have git gui do the work automatically and save us some clicking.
We add two configuration variables (one to enable the feature and one specifying the default remote) so the remote can be reused in another patch which adds a "Review Topic" merge item later in this series.
--- git-gui/git-gui.sh | 8 ++++++++ git-gui/lib/option.tcl | 2 ++ 2 files changed, 10 insertions(+), 0 deletions(-)
git-gui/git-gui.sh +8 -0
@@ -740,6 +740,8 @@ set default_config(gui.fastcopyblame) false set default_config(gui.emailafterpush) false set default_config(gui.deleteafterpush) false set default_config(gui.upstreambranch) {master} +set default_config(gui.defaultremote) {origin} +set default_config(gui.fetchonstartup) false set default_config(gui.copyblamethreshold) 40 set default_config(gui.blamehistoryctx) 7 set default_config(gui.diffcontext) 5
@@ -3495,6 +3497,12 @@ after 1 { $ui_comm configure -state disabled -background gray } } + +set defaultremote $repo_config(gui.defaultremote) +if {[is_config_true gui.fetchonstartup] && $defaultremote ne {}} { + after 500 {fetch_from $defaultremote {close_on_success}} +} + if {[is_enabled multicommit]} { after 1000 hint_gc }
git-gui/lib/option.tcl +2 -0
@@ -149,7 +149,9 @@ proc do_options {} { {b gui.fastcopyblame {mc "Blame Copy Only On Changed Files"}} {b gui.emailafterpush {mc "Open Email Composer after Push of Feature Branch"}} {b gui.deleteafterpush {mc "Open Remote Delete Dialog On Push of Upstream Branch"}} + {b gui.fetchonstartup {mc "Fetch default remote on startup"}} {t gui.upstreambranch {mc "Upstream branch"}} + {t gui.defaultremote {mc "Default remote repository"}} {i-20..200 gui.copyblamethreshold {mc "Minimum Letters To Blame Copy On"}} {i-0..300 gui.blamehistoryctx {mc "Blame History Context Radius (days)"}} {i-1..99 gui.diffcontext {mc "Number of Diff Context Lines"}}
Signature · 1 line
1.6.5.rc1.12.gc72fe
RFC PATCH 6/8 git gui: add "review topic" menuitem which supports feature branch workflow
We have a setup where each developer publishes feature branches on a central server. These branches then become merged into the upstream branch (master in most times) by another developer designated as the reviewer.
The review process usually involves several steps (fetch remote branches, update local upstream branch to server branch, review in gitk, merge). To combine this operation into one step we add a new menu item "Review Topic" under the merge menu which guides the user through all the steps.
After "Review Topic" has finished the only thing left to do is to push the current branch (which is the upstream branch) and delete the feature branch. Support for which has been implemented in an ealier patch in this series.
--- git-gui/git-gui.sh | 4 ++ git-gui/lib/merge.tcl | 83 ++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 82 insertions(+), 5 deletions(-)
git-gui/git-gui.sh +4 -0
@@ -2557,6 +2557,10 @@ if {[is_enabled branch]} { -accelerator $M1T-M lappend disable_on_lock \ [list .mbar.merge entryconf [.mbar.merge index last] -state] + .mbar.merge add command -label [mc "Review Topic..."] \ + -command {merge::dialog review} + lappend disable_on_lock \ + [list .mbar.merge entryconf [.mbar.merge index last] -state] .mbar.merge add command -label [mc "Abort Merge..."] \ -command merge::reset_hard lappend disable_on_lock \
git-gui/lib/merge.tcl +78 -5
123 lines not on this page · raw message
Signature · 1 line
1.6.5.rc1.12.gc72fe
RFC PATCH 7/8 Add documentation for git gui variables for email and delete after push
--- Documentation/config.txt | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-)
Documentation/config.txt +30 -0
@@ -957,6 +957,36 @@ gui.blamehistoryctx:: Context` menu item is invoked from 'git gui blame'. If this variable is set to zero, the whole history is shown. +gui.emailafterpush:: + The push dialog can compose a review email if you push a feature + branch. If this option is set to true the checkbox will be + automatically enabled when you select a feature branch. The + upstream (main) branch is determined from the + `gui.upstreambranch` option. + +gui.deleteafterpush:: + If you push a branch in git gui you can enable a checkbox which + will open the remote delete branch dialog after a push. Setting + this variable to true will automatically check that checkbox + when you select to push the upstream (main) branch. The upstream + branch can be configured using the `gui.upstreambranch` configuration + variable. + +gui.upstreambranch:: + This configures which branchname will be referred to as the + upstream (main) branch on remote repositories. Currently this + option is used in combination with the options + `gui.emailafterpush` and `gui.deleteafterpush`. + +gui.fetchonstartup:: + Boolean, if set all branches from remote determined by + `gui.defaulremote` will be fetched on startup of git gui. + +gui.defaultremote:: + String variable which determines from which remote git gui will + automatically start a fetch on startup. If this variable is not + set the automatic fetch is disabled. + guitool.<name>.cmd:: Specifies the shell command line to execute when the corresponding item of the linkgit:git-gui[1] `Tools` menu is invoked. This option is
Signature · 1 line
1.6.5.rc1.12.gc72fe
RFC PATCH 8/8 git gui: make gc hint and fetch on startup sequential
On large repositories (especially on Windows) doing any harddrive usage during the initial status scan slows the whole process down. So this postpones the question for compressing loose objects and fetching of the default remote until after that.
--- git-gui/git-gui.sh | 24 +++++++++++++++--------- 1 files changed, 15 insertions(+), 9 deletions(-)
git-gui/git-gui.sh +15 -9
@@ -2031,8 +2031,22 @@ proc do_quit {{rc {1}}} { destroy . } +proc ui_finalize_startup {} { + global repo_config + + set defaultremote $repo_config(gui.defaultremote) + if {[is_config_true gui.fetchonstartup] && $defaultremote ne {}} { + fetch_from $defaultremote {close_on_success} + } + + if {[is_enabled multicommit]} { + hint_gc + } + ui_ready +} + proc do_rescan {} { - rescan ui_ready + rescan ui_finalize_startup } proc ui_do_rescan {} {
@@ -3502,14 +3516,6 @@ after 1 { } } -set defaultremote $repo_config(gui.defaultremote) -if {[is_config_true gui.fetchonstartup] && $defaultremote ne {}} { - after 500 {fetch_from $defaultremote {close_on_success}} -} - -if {[is_enabled multicommit]} { - after 1000 hint_gc -} if {[is_enabled retcode]} { bind . <Destroy> {+terminate_me %W} }
Signature · 1 line
1.6.5.rc1.12.gc72fe