git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC PATCH 6/8] git gui: add "review topic" menuitem which supports feature branch workflow

From
Heiko Voigt <hvoigt@hvoigt.net>
Date
Sep 21, 2009, 13:06 UTC
Message-ID
<48c17b5cc7f2e143187a11c4e146649721bb2b0f.1253481338.git.hvoigt@hvoigt.net>
In-Reply-To
<0f2d6dac74105f84defebf23dd74c40846d304a3.1253481338.git.hvoigt@hvoigt.net>

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(-)
diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index 2a2bd38..3e3c7cd 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -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 \
diff --git a/git-gui/lib/merge.tcl b/git-gui/lib/merge.tcl
index 283e491..3716cf3 100644
--- a/git-gui/lib/merge.tcl
+++ b/git-gui/lib/merge.tcl
@@ -81,14 +81,70 @@ method _visualize {} {
 	}
 }
 
+method _update_upstream {} {
+	global repo_config index_lock_type
+
+	set upstream_branch $repo_config(gui.upstreambranch)
+	set remote $repo_config(gui.defaultremote)
+
+	if {$upstream_branch eq {} || $remote eq {}} {
+		info_popup [mc "You need to set the configuration \
+			variables gui.upstreambranch and gui.defaultremote so \
+			review topic can work"]
+		return 0
+	}
+
+	#TODO: find out why this does not return on failure
+	if {![fetch_from $remote {close_on_success}]} {
+		return 0
+	}
+
+	set co [::checkout_op::new \
+		$remote/$upstream_branch \
+		{} \
+		refs/heads/$upstream_branch]
+
+	#TODO:
+	#$co parent $w
+	$co enable_create   1
+	$co enable_merge    ff
+	$co enable_checkout 1
+
+	set spec [list refs/remotes/$remote/$upstream_branch \
+	                       $remote \
+			       refs/heads/$upstream_branch]
+
+	$co enable_fetch $spec
+	$co remote_source $spec
+
+	if {[$co run]} {
+		while {$index_lock_type ne {none}} {
+			vwait index_lock_type
+		}
+		return 1
+	} else {
+		while {$index_lock_type ne {none}} {
+			vwait index_lock_type
+		}
+		return 0
+	}
+}
+
 method _start {} {
-	global HEAD current_branch remote_url
+	global HEAD current_branch remote_url merge_type
 
 	set name [_rev $this]
 	if {$name eq {}} {
 		return
 	}
 
+	if {$merge_type eq "review"} {
+		_visualize $this
+		$w.buttons.merge configure -text [mc Merge]
+		set merge_type normal
+		return
+	}
+
 	set spec [$w_rev get_tracking_branch]
 	set cmit [$w_rev get_commit]
 
@@ -137,17 +193,34 @@ method _finish {cons ok} {
 	delete_this
 }
 
-constructor dialog {} {
+constructor dialog {{dialog_type normal}} {
 	global current_branch
 	global M1B
+	global merge_type
+
+	set merge_type $dialog_type
+	set start_button [mc Merge]
+	set action_name "Merge Into"
+	set dialog_title [mc "Merge"]
+
+	if { $merge_type eq "review" } {
+		if {![_update_upstream $this]} {
+			delete_this
+			return
+		}
+		set start_button [mc Review]
+		set action_name [mc "Review for Merge Into"]
+		set dialog_title [mc Review]
+	}
 
 	if {![_can_merge $this]} {
+		info_popup failed_can_merge
 		delete_this
 		return
 	}
 
 	make_toplevel top w
-	wm title $top [append "[appname] ([reponame]): " [mc "Merge"]]
+	wm title $top [append "[appname] ([reponame]): " $dialog_title]
 	if {$top ne {.}} {
 		wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
 	}
@@ -155,7 +228,7 @@ constructor dialog {} {
 	set _start [cb _start]
 
 	label $w.header \
-		-text [mc "Merge Into %s" $current_branch] \
+		-text [mc "$action_name %s" $current_branch] \
 		-font font_uibold
 	pack $w.header -side top -fill x
 
@@ -165,7 +238,7 @@ constructor dialog {} {
 		-command [cb _visualize]
 	pack $w.buttons.visualize -side left
 	button $w.buttons.merge \
-		-text [mc Merge] \
+		-text $start_button \
 		-command $_start
 	pack $w.buttons.merge -side right
 	button $w.buttons.cancel \
-- 
1.6.5.rc1.12.gc72fe
Previous: Heiko VoigtNext: Heiko Voigt
Message 7 of 9 in “Extend git gui for better "centralized" workflow integration”
  1. 0/8 Extend git gui for better "centralized" workflow integrationHeiko Voigt, Sep 21, 2009
  2. 1/8 git gui: add a "compose review email" checkbox to push dialogHeiko Voigt, Sep 21, 2009
  3. 2/8 git gui: teach delete dialog to open with a default remoteHeiko Voigt, Sep 21, 2009
  4. 3/8 git gui: add checkbox to launch remote branch delete after pushHeiko Voigt, Sep 21, 2009
  5. 4/8 git gui: teach fetch operation to close dialog on successful completionHeiko Voigt, Sep 21, 2009
  6. 5/8 git gui: do fetch from a default remote on startupHeiko Voigt, Sep 21, 2009
  7. 6/8 git gui: add "review topic" menuitem which supports feature branch workflowHeiko Voigt, Sep 21, 2009
  8. 7/8 Add documentation for git gui variables for email and delete after pushHeiko Voigt, Sep 21, 2009
  9. 8/8 git gui: make gc hint and fetch on startup sequentialHeiko Voigt, Sep 21, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.