Skip to content

Commit

Permalink
Fix stringOrNilMerge not calling unchangedBlock or mergedBlock after …
Browse files Browse the repository at this point in the history
…successful string merge
  • Loading branch information
MariusDoe committed Oct 4, 2024
1 parent 446b54c commit 6a01724
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
merging
stringMergeLeft: leftString right: rightString base: baseString ifConflict: aBlock
| diffResult |
diffResult := Diff3 new
file0: baseString lines;
file1: leftString lines;
file2: rightString lines;
diffClass: HuntMcilroyDiff;
merge: true.
^ (diffResult size = 1 and: [diffResult first key = #ok])
ifTrue: [diffResult first value joinSeparatedBy: Character cr]
ifFalse: [aBlock value: (SquotMergeConflict left: leftString right: rightString base: baseString)]
stringMergeLeft: leftString right: rightString base: baseString ifConflict: conflictBlock
^ self
stringMergeLeft: leftString
right: rightString
base: baseString
ifUnchanged: [leftString]
ifMerged: [:merged | merged]
ifConflict: conflictBlock
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
merging
stringMergeLeft: leftString right: rightString base: baseString ifUnchanged: unchangedBlock ifMerged: mergedBlock ifConflict: conflictBlock
| leftLines diffResult |
leftLines := leftString lines.
diffResult := Diff3 new
file0: baseString lines;
file1: leftLines;
file2: rightString lines;
diffClass: HuntMcilroyDiff;
merge: true.
^ (diffResult size = 1 and: [diffResult first key = #ok])
ifFalse: [conflictBlock value: (SquotMergeConflict left: leftString right: rightString base: baseString)]
ifTrue: [ | mergedLines |
mergedLines := diffResult first value.
mergedLines = leftLines
ifTrue: [unchangedBlock value]
ifFalse: [mergedBlock value: (mergedLines joinSeparatedBy: Character cr)]]
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ ifConflict: conflictBlock
stringMergeLeft: leftStringOrNil
right: rightStringOrNil
base: baseStringOrNil
ifUnchanged: unchangedBlock
ifMerged: mergedBlock
ifConflict: conflictBlock]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"class" : {
"atomicMergeLeft:right:base:ifUnchanged:ifMerged:ifConflict:" : "mad 9/29/2024 16:04",
"hexHashMerge:left:right:base:ifUnchanged:" : "mad 10/2/2024 20:28",
"stringMergeLeft:right:base:ifConflict:" : "mad 8/24/2024 17:41",
"stringOrNilMergeLeft:right:base:ifUnchanged:ifMerged:ifConflict:" : "mad 8/24/2024 17:34" },
"stringMergeLeft:right:base:ifConflict:" : "mad 10/2/2024 20:57",
"stringMergeLeft:right:base:ifUnchanged:ifMerged:ifConflict:" : "mad 10/2/2024 20:56",
"stringOrNilMergeLeft:right:base:ifUnchanged:ifMerged:ifConflict:" : "mad 10/2/2024 20:56" },
"instance" : {
} }

0 comments on commit 6a01724

Please sign in to comment.