git-gui: Completely remove support for creating octopus merges
authorShawn O. Pearce <spearce@spearce.org>
Thu, 19 Jul 2007 06:24:25 +0000 (02:24 -0400)
committerShawn O. Pearce <spearce@spearce.org>
Thu, 19 Jul 2007 06:24:25 +0000 (02:24 -0400)
I'm working on refactoring the UI of the merge dialog, because as it
currently stands the dialog is absolutely horrible, especially when
you have 200+ branches available from a single remote system.

In that refactoring I plan on using the choose_rev widget to allow
the user to select exactly which branch/commit they want to merge.
However since that only selects a single commit I'm first removing
the code that supports octopus merges.

A brief consultation on #git tonight seemed to indicate that the
octopus merge strategy is not as useful as originally thought when
it was invented, and that most people don't commonly use them. So
making users fall back to the command line to create an octopus is
actually maybe a good idea here, as they might think twice before
they use it.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
lib/merge.tcl
index 6caf25f2bea19efbad2190587ea5c414604871f0..e5a752507b55269daad163ae525e373dde44773c 100644 (file)
@@ -67,95 +67,44 @@ You should complete the current commit before starting a merge.  Doing so will h
        return 1
 }
 
-method _refs {} {
-       set r {}
-       foreach i [$w_list curselection] {
-               lappend r [lindex [lindex $list $i] 0]
+method _rev {} {
+       set i [$w_list curselection]
+       if {$i >= 0} {
+               return [lindex [lindex $list $i] 0]
        }
-       return $r
+       return {}
 }
 
 method _visualize {} {
-       set revs [_refs $this]
-       if {$revs eq {}} return
-       lappend revs --not HEAD
-       do_gitk $revs
+       set rev [_rev $this]
+       if {$rev ne {}} {
+               do_gitk [list $rev --not HEAD]
+       }
 }
 
 method _start {} {
        global HEAD current_branch
 
-       set cmd [list git merge]
-       set names [_refs $this]
-       set revcnt [llength $names]
-       append cmd { } $names
-
-       if {$revcnt == 0} {
-               return
-       } elseif {$revcnt == 1} {
-               set unit branch
-       } elseif {$revcnt <= 15} {
-               set unit branches
-
-               if {[tk_dialog \
-               $w.confirm_octopus \
-               [wm title $w] \
-               "Use octopus merge strategy?
-
-You are merging $revcnt branches at once.  This requires using the octopus merge driver, which may not succeed if there are file-level conflicts.
-" \
-               question \
-               0 \
-               {Cancel} \
-               {Use octopus} \
-               ] != 1} return
-       } else {
-               tk_messageBox \
-                       -icon error \
-                       -type ok \
-                       -title [wm title $w] \
-                       -parent $w \
-                       -message "Too many branches selected.
-
-You have requested to merge $revcnt branches in an octopus merge.  This exceeds Git's internal limit of 15 branches per merge.
-
-Please select fewer branches.  To merge more than 15 branches, merge the branches in batches.
-"
+       set name [_rev $this]
+       if {$name eq {}} {
                return
        }
 
-       set msg "Merging $current_branch, [join $names {, }]"
+       set cmd [list git merge $name]
+       set msg "Merging $current_branch and $name"
        ui_status "$msg..."
-       set cons [console::new "Merge" $msg]
-       console::exec $cons $cmd [cb _finish $revcnt $cons]
+       set cons [console::new "Merge" $cmd]
+       console::exec $cons $cmd [cb _finish $cons]
 
        wm protocol $w WM_DELETE_WINDOW {}
        destroy $w
 }
 
-method _finish {revcnt cons ok} {
+method _finish {cons ok} {
        console::done $cons $ok
        if {$ok} {
                set msg {Merge completed successfully.}
        } else {
-               if {$revcnt != 1} {
-                       info_popup "Octopus merge failed.
-
-Your merge of $revcnt branches has failed.
-
-There are file-level conflicts between the branches which must be resolved manually.
-
-The working directory will now be reset.
-
-You can attempt this merge again by merging only one branch at a time." $w
-
-                       set fd [git_read read-tree --reset -u HEAD]
-                       fconfigure $fd -blocking 0 -translation binary
-                       fileevent $fd readable [cb _reset_wait $fd]
-                       ui_status {Aborting... please wait...}
-                       return
-               }
-
                set msg {Merge failed.  Conflict resolution is required.}
        }
        unlock_index
@@ -235,7 +184,7 @@ constructor dialog {} {
                -height 10 \
                -width 70 \
                -font font_diff \
-               -selectmode extended \
+               -selectmode browse \
                -yscrollcommand [list $w.source.sby set]
        scrollbar $w.source.sby -command [list $w_list yview]
        pack $w.source.sby -side right -fill y