{"thread":{"id":"19230","subject":"[RFC PATCH] gitk: showing onging merge as such","startedAt":"2009-05-07T12:37:49Z","lastAt":"2009-05-07T12:37:49Z","messageCount":1,"participants":["Yann Dirson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"113212","messageId":"33880.10.0.0.1.1241699869.squirrel@intranet.linagora.com","threadId":"19230","inReplyTo":null,"subject":"[RFC PATCH] gitk: showing onging merge as such","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2009-05-07T12:37:49Z","receivedAt":"2009-05-07T12:37:49Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":">While resolving a conflicted merge, I wondered if there was any reason why\n>gitk does not show that we are indeed doing a merge, by showing the staged\n>contents as a merge commit if MERGE_HEAD is found.\n>\n>Is there any reason why we would not do this ?\n>\n>I had a quick try at how this could be done, here it is.  The diff is not\n>yet displayed as combined.\n\nI'm lucky I did not advertise the patch yet as being right below :)\n\n>From e3f3d8e04a05dfc5961671ab36bbd0541a03433b Mon Sep 17 00:00:00 2001\nFrom: Yann Dirson <ydirson@altern.org>\nDate: Thu, 7 May 2009 13:44:54 +0200\nSubject: [PATCH] gitk: crude addition of ongoing merge.\n\n---\n gitk-git/gitk |   50 ++++++++++++++++++++++++++++++--------------------\n 1 files changed, 30 insertions(+), 20 deletions(-)\n\ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nindex 1a7887b..863dde2 100644\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -918,29 +918,31 @@ proc insertrow {id p v} {\n     }\n }\n\n-proc insertfakerow {id p} {\n+proc insertfakerow {id pl} {\n     global varcid varccommits parents children cmitlisted\n     global commitidx varctok vtokmod targetid targetrow curview numcommits\n\n     set v $curview\n-    set a $varcid($v,$p)\n-    set i [lsearch -exact $varccommits($v,$a) $p]\n-    if {$i < 0} {\n-\tputs \"oops: insertfakerow can't find [shortids $p] on arc $a\"\n-\treturn\n-    }\n     set children($v,$id) {}\n-    set parents($v,$id) [list $p]\n-    set varcid($v,$id) $a\n-    lappend children($v,$p) $id\n+    set parents($v,$id) $pl\n     set cmitlisted($v,$id) 1\n     set numcommits [incr commitidx($v)]\n-    # note we deliberately don't update varcstart($v) even if $i == 0\n-    set varccommits($v,$a) [linsert $varccommits($v,$a) $i $id]\n-    modify_arc $v $a $i\n-    if {[info exists targetid]} {\n-\tif {![comes_before $targetid $p]} {\n-\t    incr targetrow\n+    foreach p $pl {\n+\tset a $varcid($v,$p)\n+\tset i [lsearch -exact $varccommits($v,$a) $p]\n+\tif {$i < 0} {\n+\t    puts \"oops: insertfakerow can't find [shortids $p] on arc $a\"\n+\t    return\n+\t}\n+\tset varcid($v,$id) $a\n+\tlappend children($v,$p) $id\n+\t# note we deliberately don't update varcstart($v) even if $i == 0\n+\tset varccommits($v,$a) [linsert $varccommits($v,$a) $i $id]\n+\tmodify_arc $v $a $i\n+\tif {[info exists targetid]} {\n+\t    if {![comes_before $targetid $p]} {\n+\t\tincr targetrow\n+\t    }\n \t}\n     }\n     setcanvscroll\n@@ -4595,7 +4597,6 @@ proc ntimes {n o} {\n\n proc ordertoken {id} {\n     global ordertok curview varcid varcstart varctok curview parents\nchildren\n-    global nullid nullid2\n\n     if {[info exists ordertok($id)]} {\n \treturn $ordertok($id)\n@@ -4811,7 +4812,7 @@ proc dodiffindex {} {\n\n proc readdiffindex {fd serial inst} {\n     global viewmainheadid nullid nullid2 curview commitinfo commitdata\nlserial\n-    global vfilelimit\n+    global vfilelimit gitdir\n\n     set isdiff 1\n     if {[gets $fd line] < 0} {\n@@ -4838,14 +4839,23 @@ proc readdiffindex {fd serial inst} {\n     filerun $fd [list readdifffiles $fd $serial $i]\n\n     if {$isdiff && ![commitinview $nullid2 $curview]} {\n+\tset heads [list]\n \t# add the line for the changes in the index to the graph\n \tset hl [mc \"Local changes checked in to index but not committed\"]\n+\tif {[catch {\n+\t    # get the last line from .git/MERGE_HEAD\n+\t    set f [open [file join $gitdir MERGE_HEAD] r]\n+\t    set heads [lrange [split [read $f] \"\\n\"] 0 end-1]\n+\t    close $f\n+\t} err]} {\n+\t    #error_popup \"This is NO merge\"\n+\t}\n \tset commitinfo($nullid2) [list  $hl {} {} {} {} \"    $hl\\n\"]\n \tset commitdata($nullid2) \"\\n    $hl\\n\"\n \tif {[commitinview $nullid $curview]} {\n \t    removefakerow $nullid\n \t}\n-\tinsertfakerow $nullid2 $viewmainheadid($curview)\n+\tinsertfakerow $nullid2 [concat $viewmainheadid($curview) $heads]\n     } elseif {!$isdiff && [commitinview $nullid2 $curview]} {\n \tif {[commitinview $nullid $curview]} {\n \t    removefakerow $nullid\n@@ -4883,7 +4893,7 @@ proc readdifffiles {fd serial inst} {\n \t} else {\n \t    set p $viewmainheadid($curview)\n \t}\n-\tinsertfakerow $nullid $p\n+\tinsertfakerow $nullid [list $p]\n     } elseif {!$isdiff && [commitinview $nullid $curview]} {\n \tremovefakerow $nullid\n     }\n-- \n1.6.3.rc3\n"}]}