Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | 3-way diff now handles basic cases. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
674c783efab6197289174d68e05b8536 |
User & Date: | peter.spjuth@gmail.com 2011-04-25 15:58:38.000 |
Context
2011-04-27
| ||
22:20 | Restructured code to let insertMatchingBlocks handle puting changes in the change list. check-in: bd368726a8 user: peter.spjuth@gmail.com tags: trunk | |
2011-04-25
| ||
15:58 | 3-way diff now handles basic cases. check-in: 674c783efa user: peter.spjuth@gmail.com tags: trunk | |
14:28 | Added infrastructure for ancestor file check-in: cc9aa5b84c user: peter.spjuth@gmail.com tags: trunk | |
Changes
Changes to src/merge.tcl.
︙ | ︙ | |||
67 68 69 70 71 72 73 | for {set t 0} {$t < $n2} {incr t} { gets $ch2 apa append data2 $apa\n incr doingLine2 } lappend diff($top,leftMergeData) $data1 lappend diff($top,rightMergeData) $data2 | | > | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | for {set t 0} {$t < $n2} {incr t} { gets $ch2 apa append data2 $apa\n incr doingLine2 } lappend diff($top,leftMergeData) $data1 lappend diff($top,rightMergeData) $data2 set diff($top,mergeSelection,$changeNo) \ [WhichSide $top $line1 $n1 $line2 $n2] incr changeNo } set data1 {} set data2 {} while {[gets $ch1 apa] != -1} { append data1 $apa\n incr doingLine1 |
︙ | ︙ | |||
103 104 105 106 107 108 109 | set t 0 foreach {commLeft diffLeft} $diff($top,leftMergeData) \ {commRight diffRight} $diff($top,rightMergeData) { $w insert end $commRight if {![info exists diff($top,mergeSelection,$t)]} continue $w mark set merges$t insert $w mark gravity merges$t left | > > > > | > > > < | | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | set t 0 foreach {commLeft diffLeft} $diff($top,leftMergeData) \ {commRight diffRight} $diff($top,rightMergeData) { $w insert end $commRight if {![info exists diff($top,mergeSelection,$t)]} continue $w mark set merges$t insert $w mark gravity merges$t left switch $diff($top,mergeSelection,$t) { 1 { $w insert end $diffLeft merge$t } 2 { $w insert end $diffRight merge$t } 12 { $w insert end $diffLeft merge$t $w insert end $diffRight merge$t } 21 { $w insert end $diffRight merge$t $w insert end $diffLeft merge$t } } lappend marks mergee$t [$w index insert] incr t } foreach {mark index} $marks { $w mark set $mark $index } # Add fences to simplify some handling later $w mark set mergee-2 1.0 $w mark set mergee-1 1.0 $w mark set merges$t end $w mark set merges[expr {$t + 1}] end set diff($top,curMerge) 0 set diff($top,curMergeSel) $diff($top,mergeSelection,0) $w tag configure merge0 -foreground red showDiff $top 0 update # If there is any diff, show the first if {$t > 0} { seeText $w merges0 mergee0 } |
︙ | ︙ | |||
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 | collectMergeData $top fillMergeWindow $top } # Compare each file agains an ancestor file for three-way merge proc collectAncestorInfo {top dFile1 dFile2 opts} { set differrA1 [catch {DiffUtil::diffFiles {*}$opts \ $::diff($top,ancestorFile) $dFile1} diffresA1] set differrA2 [catch {DiffUtil::diffFiles {*}$opts \ $::diff($top,ancestorFile) $dFile2} diffresA2] if {$differrA1 != 0 || $differrA2 != 0} { puts $diffresA1 puts $diffresA2 return } foreach i $diffresA1 { lassign $i line1 n1 line2 n2 | > > > > > > | > > > > > > > > | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 | collectMergeData $top fillMergeWindow $top } # Compare each file agains an ancestor file for three-way merge proc collectAncestorInfo {top dFile1 dFile2 opts} { array unset ::diff $top,ancestorLeft,* array unset ::diff $top,ancestorRight,* set differrA1 [catch {DiffUtil::diffFiles {*}$opts \ $::diff($top,ancestorFile) $dFile1} diffresA1] set differrA2 [catch {DiffUtil::diffFiles {*}$opts \ $::diff($top,ancestorFile) $dFile2} diffresA2] if {$differrA1 != 0 || $differrA2 != 0} { puts $diffresA1 puts $diffresA2 return } foreach i $diffresA1 { lassign $i line1 n1 line2 n2 if {$n1 == 0} { # Added lines for {set t $line2} {$t < $line2 + $n2} {incr t} { set ::diff($top,ancestorLeft,$t) a } } elseif {$n2 == 0} { # Deleted lines # Mark the following line set ::diff($top,ancestorLeft,d$line2) d } else { # Changed lines for {set t $line2} {$t < $line2 + $n2} {incr t} { set ::diff($top,ancestorLeft,$t) c } } } foreach i $diffresA2 { lassign $i line1 n1 line2 n2 if {$n1 == 0} { # Added lines for {set t $line2} {$t < $line2 + $n2} {incr t} { set ::diff($top,ancestorRight,$t) a } } elseif {$n2 == 0} { # Deleted lines # Mark the following line set ::diff($top,ancestorRight,d$line2) d } else { # Changed lines for {set t $line2} {$t < $line2 + $n2} {incr t} { set ::diff($top,ancestorRight,$t) c } } } #parray ::diff $top,ancestor* } # Use ancestor info to select which side to use in a merge chunk proc WhichSide {top line1 n1 line2 n2} { if {$n1 == 0} { # Only to the right, this can be: set delLeft [info exists ::diff($top,ancestorLeft,d$line1)] # Inserted to right : Keep right side if {!$delLeft} { return 2 } for {set t $line2} {$t < $line2 + $n2} {incr t} { if {[info exists ::diff($top,ancestorRight,$t)]} { set right($::diff($top,ancestorRight,$t)) 1 } } # Deleted to left : Keep left side if {[array size right] == 0} { return 1 } # Deleted to left and changed to the right : ?? (right for now) # FIXA return 2 } elseif {$n2 == 0} { # Only to the left, this can be: set delRight [info exists ::diff($top,ancestorRight,d$line2)] # Inserted to left : Keep left side if {!$delRight} { return 1 } for {set t $line1} {$t < $line1 + $n1} {incr t} { if {[info exists ::diff($top,ancestorLeft,$t)]} { set left($::diff($top,ancestorLeft,$t)) 1 } } # Deleted to right : Keep right side if {[array size left] == 0} { return 2 } # Deleted to right and changed to the left : ?? (left for now) # FIXA return 1 } else { # Changed on both sides, this can be: for {set t $line1} {$t < $line1 + $n1} {incr t} { if {[info exists ::diff($top,ancestorLeft,$t)]} { set left($::diff($top,ancestorLeft,$t)) 1 } } # Changed to the right : Keep right if {[array size left] == 0} { return 2 } for {set t $line2} {$t < $line2 + $n2} {incr t} { if {[info exists ::diff($top,ancestorRight,$t)]} { set right($::diff($top,ancestorRight,$t)) 1 } } # Changed to the left : Keep left if {[array size right] == 0} { return 1 } # Changed in both, right for now # FIXA return 2 } } |