[PATCH 2/2] git-gui: add menu item to select a branch to visualize with gitk

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Previously it was only possible to either visualize the history of the
current branch or of all branches. This new menu item "Visualize Branch
History..." is similar to the existing "Browse Branch Files..." item.

The gitk_open class was straight copied from the browser_open class with
merely adjusting the UI text and the command to execute.

Signed-off-by: Markus Heidelberg <markus.heidelberg@xxxxxx>
---
 git-gui.sh   |    3 +++
 lib/gitk.tcl |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/git-gui.sh b/git-gui.sh
index 6ff04c4..9ceaf6f 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -2310,6 +2310,9 @@ set ui_browse_current [.mbar.repository index last]
 	-command {do_gitk $current_branch}
 set ui_visualize_current [.mbar.repository index last]
 .mbar.repository add command \
+	-label [mc "Visualize Branch History..."] \
+	-command gitk_open::dialog
+.mbar.repository add command \
 	-label [mc "Visualize All Branch History"] \
 	-command {do_gitk --all}
 .mbar.repository add separator
diff --git a/lib/gitk.tcl b/lib/gitk.tcl
index fcbb73d..251ab45 100644
--- a/lib/gitk.tcl
+++ b/lib/gitk.tcl
@@ -39,3 +39,56 @@ proc do_gitk {revs} {
 		}
 	}
 }
+
+class gitk_open {
+
+field w              ; # widget path
+field w_rev          ; # mega-widget to pick the initial revision
+
+constructor dialog {} {
+	make_toplevel top w
+	wm title $top [append "[appname] ([reponame]): " [mc "Visualize Branch History"]]
+	if {$top ne {.}} {
+		wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
+	}
+
+	label $w.header \
+		-text [mc "Visualize Branch History"] \
+		-font font_uibold
+	pack $w.header -side top -fill x
+
+	frame $w.buttons
+	button $w.buttons.browse -text [mc Visualize] \
+		-default active \
+		-command [cb _open]
+	pack $w.buttons.browse -side right
+	button $w.buttons.cancel -text [mc Cancel] \
+		-command [list destroy $w]
+	pack $w.buttons.cancel -side right -padx 5
+	pack $w.buttons -side bottom -fill x -pady 10 -padx 10
+
+	set w_rev [::choose_rev::new $w.rev [mc Revision]]
+	$w_rev bind_listbox <Double-Button-1> [cb _open]
+	pack $w.rev -anchor nw -fill both -expand 1 -pady 5 -padx 5
+
+	bind $w <Visibility> [cb _visible]
+	bind $w <Key-Escape> [list destroy $w]
+	bind $w <Key-Return> [cb _open]\;break
+	tkwait window $w
+}
+
+method _open {} {
+	if {[catch {$w_rev commit_or_die} err]} {
+		return
+	}
+	set name [$w_rev get]
+	destroy $w
+	do_gitk $name
+}
+
+method _visible {} {
+	grab $w
+	$w_rev focus_filter
+}
+
+}
-- 
1.6.3.rc3.79.g777c

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]