--- a/Diff3.st Mon Apr 09 12:37:13 2012 +0100
+++ b/Diff3.st Mon Apr 09 19:34:24 2012 +0100
@@ -232,6 +232,21 @@
'false conflicts', and can return two Diff3Chunks next to each other in
the result."
+ ^self mergeIndicesDiscardEmpty: true
+
+ "Modified: / 09-04-2012 / 16:26:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+mergeIndicesDiscardEmpty: discardEmpty
+ "Returns an Array of Diff3Chunks (representing clean merges) or Diff3Conflicts
+ (containing DiffChunks, representing conflicts), together representing the
+ results of a three-way merge between file1/file0/file2. Does not detect
+ 'false conflicts', and can return two Diff3Chunks next to each other in
+ the result.
+
+ If discard empty is true, empty clean merge chunks are not included
+ "
+
| result commonOffset hunks lastOverlapHunkIndex hunk firstHunkIndex |
hunks := self computeHunks.
@@ -245,7 +260,9 @@
lastOverlapHunkIndex := self findOverlapStartingAt: firstHunkIndex in: hunks.
(firstHunkIndex = lastOverlapHunkIndex) ifTrue: [
- (hunk newChunk length > 0) ifTrue: [
+ (discardEmpty and:[hunk newChunk length == 0]) ifTrue:[
+ "/Empty chunk...
+ ] ifFalse:[
result add: (Diff3::Chunk side: hunk side chunk: hunk newChunk)
].
commonOffset := (hunks at: lastOverlapHunkIndex) oldChunk lastIndex + 1.
@@ -263,8 +280,7 @@
self addCommonChunkTo: result between: commonOffset and: file0 size + 1.
^ result asArray
- "Modified: / 16-03-2012 / 19:24:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified (format): / 20-03-2012 / 18:07:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Created: / 09-04-2012 / 16:25:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!Diff3 methodsFor:'private'!
@@ -806,5 +822,5 @@
!Diff3 class methodsFor:'documentation'!
version_SVN
- ^ '$Id: Diff3.st 7974 2012-04-09 11:37:13Z vranyj1 $'
+ ^ '$Id: Diff3.st 7975 2012-04-09 18:34:24Z vranyj1 $'
! !