@matheusbsbs / matheus-bagliano / commits / 8e891facbe
Fork 0

git-gui: Allow users to browse any branch, not just the current one

We now allow users to pick which commit they want to browse through our revision picking mega-widget. This opens up in a dialog first, and then opens a tree browser for that selected commit. It is a very simple approach and requires minimal code changes. I also clarified the language a bit in the Repository menu, to show that these actions will access files. Just in case a user is not quite sure what specific action they are looking for, but they know they want some sort of file thing. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Jul 18, 2007 at 01:39 UTC 8e891facbef4b0196e51fe2065602175f28508c3
2 files changed +58 -2
git-gui.sh
+5 -2
@@ -1670,9 +1670,12 @@ if {[is_enabled transport]} {
1670 menu .mbar.repository
1671
1672 .mbar.repository add command \
1673 - -label {Browse Current Branch} \
1673 + -label {Browse Current Branch's Files} \
1674 -command {browser::new $current_branch}
1675 -trace add variable current_branch write ".mbar.repository entryconf [.mbar.repository index last] -label \"Browse \$current_branch\" ;#"
1675 +trace add variable current_branch write ".mbar.repository entryconf [.mbar.repository index last] -label \"Browse \$current_branch's Files\" ;#"
1676 +.mbar.repository add command \
1677 + -label {Browse Branch Files...} \
1678 + -command browser_open::dialog
1679 .mbar.repository add separator
1680
1681 .mbar.repository add command \
lib/browser.tcl
+53
@@ -243,3 +243,56 @@ method _read {fd} {
243 }
244
245 }
246 +
247 +class browser_open {
248 +
249 +field w ; # widget path
250 +field w_rev ; # mega-widget to pick the initial revision
251 +
252 +constructor dialog {} {
253 + make_toplevel top w
254 + wm title $top "[appname] ([reponame]): Browse Branch Files"
255 + if {$top ne {.}} {
256 + wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
257 + }
258 +
259 + label $w.header \
260 + -text {Browse Branch Files} \
261 + -font font_uibold
262 + pack $w.header -side top -fill x
263 +
264 + frame $w.buttons
265 + button $w.buttons.browse -text Browse \
266 + -default active \
267 + -command [cb _open]
268 + pack $w.buttons.browse -side right
269 + button $w.buttons.cancel -text {Cancel} \
270 + -command [list destroy $w]
271 + pack $w.buttons.cancel -side right -padx 5
272 + pack $w.buttons -side bottom -fill x -pady 10 -padx 10
273 +
274 + set w_rev [::choose_rev::new $w.rev {Revision}]
275 + $w_rev bind_listbox <Double-Button-1> [cb _open]
276 + pack $w.rev -anchor nw -fill both -expand 1 -pady 5 -padx 5
277 +
278 + bind $w <Visibility> [cb _visible]
279 + bind $w <Key-Escape> [list destroy $w]
280 + bind $w <Key-Return> [cb _open]\;break
281 + tkwait window $w
282 +}
283 +
284 +method _open {} {
285 + if {[catch {$w_rev commit_or_die} err]} {
286 + return
287 + }
288 + set name [$w_rev get]
289 + destroy $w
290 + browser::new $name
291 +}
292 +
293 +method _visible {} {
294 + grab $w
295 + $w_rev focus_filter
296 +}
297 +
298 +}