2362
{mc "Mark this commit" command markhere}
2363
{mc "Return to mark" command gotomark}
2364
{mc "Find descendant of this and mark" command find_common_desc}
2365
+ {mc "Compare with marked commit" command compare_commits}
2366
}
2367
$rowctxmenu configure -tearoff 0
2368
8038
if {[info exists markedid] && $markedid ne $id} {
8039
$menu entryconfigure 9 -state normal
8040
$menu entryconfigure 10 -state normal
8041
+ $menu entryconfigure 11 -state normal
8042
} else {
8043
$menu entryconfigure 9 -state disabled
8044
$menu entryconfigure 10 -state disabled
8045
+ $menu entryconfigure 11 -state disabled
8046
}
8047
} else {
8048
set menu $fakerowmenu
8106
#puts "took [expr {$t2-$t1}]ms"
8107
}
8108
8109
+proc compare_commits {} {
8110
+ global markedid rowmenuid curview children
8111
+
8112
+ if {![info exists markedid]} return
8113
+ if {![commitinview $markedid $curview]} return
8114
+ addtohistory [list do_cmp_commits $markedid $rowmenuid]
8115
+ do_cmp_commits $markedid $rowmenuid
8116
+}
8117
+
8118
+proc getpatchid {id} {
8119
+ global patchids
8120
+
8121
+ if {![info exists patchids($id)]} {
8122
+ set x [exec git diff-tree -p --root $id | git patch-id]
8123
+ set patchids($id) [lindex $x 0]
8124
+ }
8125
+ return $patchids($id)
8126
+}
8127
+
8128
+proc do_cmp_commits {a b} {
8129
+ global ctext curview parents children patchids commitinfo
8130
+
8131
+ $ctext conf -state normal
8132
+ clear_ctext
8133
+ init_flist {}
8134
+ for {set i 0} {$i < 100} {incr i} {
8135
+ set shorta [string range $a 0 7]
8136
+ set shortb [string range $b 0 7]
8137
+ set skipa 0
8138
+ set skipb 0
8139
+ if {[llength $parents($curview,$a)] > 1} {
8140
+ appendwithlinks [mc "Skipping merge commit %s\n" $shorta] {}
8141
+ set skipa 1
8142
+ } else {
8143
+ set patcha [getpatchid $a]
8144
+ }
8145
+ if {[llength $parents($curview,$b)] > 1} {
8146
+ appendwithlinks [mc "Skipping merge commit %s\n" $shortb] {}
8147
+ set skipb 1
8148
+ } else {
8149
+ set patchb [getpatchid $b]
8150
+ }
8151
+ if {!$skipa && !$skipb} {
8152
+ set heada [lindex $commitinfo($a) 0]
8153
+ set headb [lindex $commitinfo($b) 0]
8154
+ if {$patcha eq $patchb} {
8155
+ if {$heada eq $headb} {
8156
+ appendwithlinks [mc "Commit %s == %s %s\n" \
8157
+ $shorta $shortb $heada] {}
8158
+ } else {
8159
+ appendwithlinks [mc "Commit %s %s\n" $shorta $heada] {}
8160
+ appendwithlinks [mc " is the same patch as\n"] {}
8161
+ appendwithlinks [mc " %s %s\n" $shortb $headb] {}
8162
+ }
8163
+ set skipa 1
8164
+ set skipb 1
8165
+ } else {
8166
+ $ctext insert end "\n"
8167
+ appendwithlinks [mc "Commit %s %s\n" $shorta $heada] {}
8168
+ appendwithlinks [mc " differs from\n"] {}
8169
+ appendwithlinks [mc " %s %s\n" $shortb $headb] {}
8170
+ appendwithlinks [mc "- stopping\n"]
8171
+ break
8172
+ }
8173
+ }
8174
+ if {$skipa} {
8175
+ if {[llength $children($curview,$a)] != 1} {
8176
+ $ctext insert end "\n"
8177
+ appendwithlinks [mc "Commit %s has %s children - stopping\n" \
8178
+ $shorta [llength $children($curview,$a)]] {}
8179
+ break
8180
+ }
8181
+ set a [lindex $children($curview,$a) 0]
8182
+ }
8183
+ if {$skipb} {
8184
+ if {[llength $children($curview,$b)] != 1} {
8185
+ appendwithlinks [mc "Commit %s has %s children - stopping\n" \
8186
+ $shortb [llength $children($curview,$b)]] {}
8187
+ break
8188
+ }
8189
+ set b [lindex $children($curview,$b) 0]
8190
+ }
8191
+ }
8192
+ $ctext conf -state disabled
8193
+}
8194
+
8195
proc diffvssel {dirn} {
8196
global rowmenuid selectedline
8197