-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #45.
- Loading branch information
Showing
7 changed files
with
46 additions
and
10 deletions.
There are no files selected for viewing
10 changes: 5 additions & 5 deletions
10
...MergeUtilities.class/class/stringMergeLeft.right.base.ifUnchanged.ifMerged.ifConflict..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
merging | ||
stringMergeLeft: leftString right: rightString base: baseString ifUnchanged: unchangedBlock ifMerged: mergedBlock ifConflict: conflictBlock | ||
| leftLines diffResult | | ||
| leftLines chunks | | ||
leftLines := leftString lines. | ||
diffResult := Diff3 new | ||
chunks := (Diff3 new | ||
file0: baseString lines; | ||
file1: leftLines; | ||
file2: rightString lines; | ||
diffClass: GSTextUtilities diffClass; | ||
merge: true. | ||
^ (diffResult size = 1 and: [diffResult first key = #ok]) | ||
yourself) merge: true. | ||
^ (chunks allSatisfy: [:each | each key = #ok]) | ||
ifFalse: [conflictBlock value: (GSMergeConflict left: leftString right: rightString base: baseString)] | ||
ifTrue: [ | mergedLines | | ||
mergedLines := diffResult first value. | ||
mergedLines := chunks gather: #value. | ||
mergedLines = leftLines | ||
ifTrue: [unchangedBlock value] | ||
ifFalse: [mergedBlock value: (mergedLines joinSeparatedBy: Character cr)]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
src/GitS-Core.package/GSTextUtilities.class/class/diffChunksFrom.to..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/GitS-Core.package/MyersUkkonenDiff.extension/instance/calculateLcs.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
*GitS-Core-private-override | ||
calculateLcs | ||
"I find one of the longest common subsequences of my the arguments. I assume that none of my arguments are empty. I return nil or an Array which represents a list. The first two elements are the matching line numbers, the last is the next node in the list or nil if there are no more elements. The list containts the longest common subsequence. I'm a modified version of the greedy lcs algorithm from the 6th page of 'An O(ND) Difference Algorithm and Its Variations (1986)' by Eugene W. Myers" | ||
|
||
| n m v lcss max | | ||
n := file1 size. | ||
m := file2 size. | ||
max := m + n. | ||
max = 0 ifTrue: [^ nil]. | ||
v := Array new: 2 * max + 1. | ||
v at: max + 2 put: 0. | ||
lcss := Array new: 2 * max + 1. | ||
0 to: max do: [ :d | | ||
d negated to: d by: 2 do: [ :k | | ||
| index chain x y | | ||
(k + d = 0 or: [ k ~= d and: [ (v at: max + k ) < (v at: max + k + 2) ] ]) | ||
ifTrue: [ | ||
index := max + k + 2. | ||
x := v at: index ] | ||
ifFalse: [ | ||
index := max + k. | ||
x := (v at: index) + 1 ]. | ||
chain := lcss at: index. | ||
y := x - k. | ||
[ x < n and: [ y < m and: [ (file1 at: x + 1) = (file2 at: y + 1) ] ] ] | ||
whileTrue: [ | ||
chain := { x := x + 1. y := y + 1. chain } ]. | ||
(x >= n and: [ y >= m ]) ifTrue: [ | ||
^chain ]. | ||
v at: max + k + 1 put: x. | ||
lcss at: max + k + 1 put: chain ] ]. | ||
self error |
5 changes: 5 additions & 0 deletions
5
src/GitS-Core.package/MyersUkkonenDiff.extension/methodProperties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"class" : { | ||
}, | ||
"instance" : { | ||
"calculateLcs" : "mad 11/16/2024 13:52" } } |
2 changes: 2 additions & 0 deletions
2
src/GitS-Core.package/MyersUkkonenDiff.extension/properties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
"name" : "MyersUkkonenDiff" } |