gitk: Cope better with getting commits that we have already seen
This fixes a bug in updating the graph after we have cherry-picked a commit in gitk and then added some new stuff externally. First, we weren't updating viewincl with the new head added by the cherry- pick. Secondly, getcommitlines was doing bad things if it saw a commit that was already in the graph (was already in an arc). This fixes both things. If getcommitlines sees a commit that is already in the graph, it ignores it unless it was not listed before and is listed now. In that case it doesn't assign it a new arc now, and doesn't re-add the commit to its arc. Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras committed
Feb 16, 2008 at 17:47 UTC
f1bf4ee6d78209a1c45cca1bf3b38252208434d2
1 file changed
+18
-7
gitk
+18
-7
@@ -1065,7 +1065,11 @@ proc getcommitlines {fd inst view} {
1065
}
1066
set id [lindex $ids 0]
1067
set vid $view,$id
1068
- if {!$listed && [info exists parents($vid)]} continue
1068
+ set a 0
1069
+ if {[info exists varcid($vid)]} {
1070
+ if {$cmitlisted($vid) || !$listed} continue
1071
+ set a $varcid($vid)
1072
+ }
1073
if {$listed} {
1074
set olds [lrange $ids 1 end]
1075
} else {
@@ -1074,10 +1078,9 @@ proc getcommitlines {fd inst view} {
1078
set commitdata($id) [string range $cmit [expr {$j + 1}] end]
1079
set cmitlisted($vid) $listed
1080
set parents($vid) $olds
1077
- set a 0
1081
if {![info exists children($vid)]} {
1082
set children($vid) {}
1080
- } elseif {[llength $children($vid)] == 1} {
1083
+ } elseif {$a == 0 && [llength $children($vid)] == 1} {
1084
set k [lindex $children($vid) 0]
1085
if {[llength $parents($view,$k)] == 1 &&
1086
(!$datemode ||
@@ -1089,11 +1092,14 @@ proc getcommitlines {fd inst view} {
1092
# new arc
1093
set a [newvarc $view $id]
1094
}
1092
- set varcid($vid) $a
1095
if {[string compare [lindex $varctok($view) $a] $vtokmod($view)] < 0} {
1096
modify_arc $view $a
1097
}
1096
- lappend varccommits($view,$a) $id
1098
+ if {![info exists varcid($vid)]} {
1099
+ set varcid($vid) $a
1100
+ lappend varccommits($view,$a) $id
1101
+ incr commitidx($view)
1102
+ }
1103
1104
set i 0
1105
foreach p $olds {
@@ -1112,7 +1118,6 @@ proc getcommitlines {fd inst view} {
1118
incr i
1119
}
1120
1115
- incr commitidx($view)
1121
if {[info exists commitinterest($id)]} {
1122
foreach script $commitinterest($id) {
1123
lappend scripts [string map [list "%I" $id] $script]
@@ -7035,7 +7040,7 @@ proc mkbrgo {top} {
7040
}
7041
7042
proc cherrypick {} {
7038
- global rowmenuid curview
7043
+ global rowmenuid curview viewincl
7044
global mainhead mainheadid
7045
7046
set oldhead [exec git rev-parse HEAD]
@@ -7069,6 +7074,12 @@ proc cherrypick {} {
7074
movedhead $newhead $mainhead
7075
set mainheadid $newhead
7076
}
7077
+ # remove oldhead from viewincl and add newhead
7078
+ set i [lsearch -exact $viewincl($curview) $oldhead]
7079
+ if {$i >= 0} {
7080
+ set viewincl($curview) [lreplace $viewincl($curview) $i $i]
7081
+ }
7082
+ lappend viewincl($curview) $newhead
7083
redrawtags $oldhead
7084
redrawtags $newhead
7085
selbyid $newhead