@matheusbsbs / matheus-bagliano / commits / 6bdf5e5f20
Fork 0

git-gui: Consolidate the Fetch and Push menus into a Remote menu

Sometimes the Fetch menu looks really odd, such as if you are in a repository that has no remotes configured when you start git-gui. Here we didn't have any items to add to the Fetch menu so it was a tad confusing for the end-user to see an empty menu on the menu bar. We now place all of the commands related to fetching and pushing of changes into a single "Remote" menu. This way we have a better class of bucket that we can drop additional remote related items into such as doing a remote merge or editing the remote configuration specs. The shortcuts to execute fetch/remote prune/push on existing remote specifications are now actually submenus listing the remotes by name. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Oct 7, 2007 at 22:23 UTC 6bdf5e5f20c792ad0c5d5ba941d7e637aca86d32
2 files changed +45 -28
git-gui.sh
+13 -7
@@ -1792,8 +1792,7 @@ if {[is_enabled multicommit] || [is_enabled singlecommit]} {
1792 }
1793 if {[is_enabled transport]} {
1794 .mbar add cascade -label [mc Merge] -menu .mbar.merge
1795 - .mbar add cascade -label [mc Fetch] -menu .mbar.fetch
1796 - .mbar add cascade -label [mc Push] -menu .mbar.push
1795 + .mbar add cascade -label [mc Remote] -menu .mbar.remote
1796 }
1797 . configure -menu .mbar
1798
@@ -2000,13 +1999,14 @@ if {[is_enabled branch]} {
1999 # -- Transport Menu
2000 #
2001 if {[is_enabled transport]} {
2003 - menu .mbar.fetch
2002 + menu .mbar.remote
2003
2005 - menu .mbar.push
2006 - .mbar.push add command -label [mc "Push..."] \
2004 + .mbar.remote add command \
2005 + -label [mc "Push..."] \
2006 -command do_push_anywhere \
2007 -accelerator $M1T-P
2009 - .mbar.push add command -label [mc "Delete..."] \
2008 + .mbar.remote add command \
2009 + -label [mc "Delete..."] \
2010 -command remote_branch_delete::dialog
2011 }
2012
@@ -2720,8 +2720,14 @@ user.email settings into your personal
2720 if {[is_enabled transport]} {
2721 load_all_remotes
2722
2723 - populate_fetch_menu
2723 + set n [.mbar.remote index end]
2724 populate_push_menu
2725 + populate_fetch_menu
2726 + set n [expr {[.mbar.remote index end] - $n}]
2727 + if {$n > 0} {
2728 + .mbar.remote insert $n separator
2729 + }
2730 + unset n
2731 }
2732
2733 if {[winfo exists $ui_comm]} {
lib/remote.tcl
+32 -21
@@ -135,8 +135,10 @@ proc load_all_remotes {} {
135 proc populate_fetch_menu {} {
136 global all_remotes repo_config
137
138 - set m .mbar.fetch
139 - set prune_list [list]
138 + set remote_m .mbar.remote
139 + set fetch_m $remote_m.fetch
140 + set prune_m $remote_m.prune
141 +
142 foreach r $all_remotes {
143 set enable 0
144 if {![catch {set a $repo_config(remote.$r.url)}]} {
@@ -157,28 +159,34 @@ proc populate_fetch_menu {} {
159 }
160
161 if {$enable} {
160 - lappend prune_list $r
161 - $m add command \
162 - -label [mc "Fetch from %s" $r] \
162 + if {![winfo exists $fetch_m]} {
163 + menu $prune_m
164 + $remote_m insert 0 cascade \
165 + -label [mc "Prune from"] \
166 + -menu $prune_m
167 +
168 + menu $fetch_m
169 + $remote_m insert 0 cascade \
170 + -label [mc "Fetch from"] \
171 + -menu $fetch_m
172 + }
173 +
174 + $fetch_m add command \
175 + -label $r \
176 -command [list fetch_from $r]
177 + $prune_m add command \
178 + -label $r \
179 + -command [list prune_from $r]
180 }
181 }
166 -
167 - if {$prune_list ne {}} {
168 - $m add separator
169 - }
170 - foreach r $prune_list {
171 - $m add command \
172 - -label [mc "Prune from %s" $r] \
173 - -command [list prune_from $r]
174 - }
182 }
183
184 proc populate_push_menu {} {
185 global all_remotes repo_config
186
180 - set m .mbar.push
181 - set fast_count 0
187 + set remote_m .mbar.remote
188 + set push_m $remote_m.push
189 +
190 foreach r $all_remotes {
191 set enable 0
192 if {![catch {set a $repo_config(remote.$r.url)}]} {
@@ -199,13 +207,16 @@ proc populate_push_menu {} {
207 }
208
209 if {$enable} {
202 - if {!$fast_count} {
203 - $m add separator
210 + if {![winfo exists $push_m]} {
211 + menu $push_m
212 + $remote_m insert 0 cascade \
213 + -label [mc "Push to"] \
214 + -menu $push_m
215 }
205 - $m add command \
206 - -label [mc "Push to %s" $r] \
216 +
217 + $push_m add command \
218 + -label $r \
219 -command [list push_to $r]
208 - incr fast_count
220 }
221 }
222 }