The Trunk: System-mt.1192.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: System-mt.1192.mcz

commits-2
Marcel Taeumel uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-mt.1192.mcz

==================== Summary ====================

Name: System-mt.1192
Author: mt
Time: 10 November 2020, 8:57:39.098594 am
UUID: 287a932b-bf27-334a-b0b3-2db1fc95027d
Ancestors: System-mt.1191

Makes the order of inserted/removed lines in text diffs configurable. Set the default to the unix-y way, which is remove-before-insert.

=============== Diff against System-mt.1191 ===============

Item was changed:
  Object subclass: #TextDiffBuilder
  instanceVariableNames: 'xLines yLines ignoreLineEndings'
+ classVariableNames: 'IgnoreLineEndings InsertTextAttributes NormalTextAttributes RemoveTextAttributes ShowInsertBeforeRemove'
- classVariableNames: 'IgnoreLineEndings InsertTextAttributes NormalTextAttributes RemoveTextAttributes'
  poolDictionaries: ''
  category: 'System-FilePackage'!
 
  !TextDiffBuilder commentStamp: 'fbs 9/23/2013 08:58' prior: 0!
  I implement the diff algorithm. I can show the differences between two texts. See my method comments for further information.
 
  Instance Variables
  xLines: <Array>
  yLines: <Array>
  ignoreLineEndings: <Boolean>
 
  xLines
  - an Array of DiffElements which is created from the first input text
 
  yLines
  - an Array of DiffElements which is created from the second input text
 
  ignoreLineEndings
  - a Boolean describing whether lines only differing in the line endings should be reported as a difference, or not!

Item was added:
+ ----- Method: TextDiffBuilder class>>showInsertBeforeRemove (in category 'preferences') -----
+ showInsertBeforeRemove
+ "Answer a boolean telling if line endings differences should be ignored or emphasized"
+
+ <preference: 'Show inserted before removed lines'
+ category: 'TextDiff'
+ description: 'When enabled, the diff builder will print added lines before the removed ones to show replacement.'
+ type: #Boolean>
+
+ ^ ShowInsertBeforeRemove ifNil: [ false ]!

Item was added:
+ ----- Method: TextDiffBuilder class>>showInsertBeforeRemove: (in category 'preferences') -----
+ showInsertBeforeRemove: aBoolean
+
+ ShowInsertBeforeRemove := aBoolean.!

Item was changed:
  ----- Method: TextDiffBuilder>>patchSequenceDoIfMatch:ifInsert:ifRemove: (in category 'creating patches') -----
  patchSequenceDoIfMatch: matchBlock ifInsert: insertBlock ifRemove: removeBlock
  "I'm the general purpose method to iterate through the patch sequence. See my senders to learn how to use me."
 
+ | aLines bLines aBlock bBlock aLine aLineStream |
+ self class showInsertBeforeRemove
+ ifTrue: [ aLines := xLines. bLines := yLines. aBlock := insertBlock. bBlock := removeBlock ]
+ ifFalse: [ aLines := yLines. bLines := xLines. aBlock := removeBlock. bBlock := insertBlock ].
+ aLineStream := aLines readStream.
+ bLines do: [ :bLine |
+ bLine hasMatch
+ ifFalse: [
+ aBlock value: bLine string  ]
- | xLine xLineStream |
- xLineStream := xLines readStream.
- yLines do: [ :yLine |
- yLine hasMatch
- ifFalse: [ insertBlock value: yLine string  ]
  ifTrue: [
+ [ (aLine := aLineStream next) == nil or: [ aLine == bLine match  ] ]
+ whileFalse: [ bBlock value: aLine string ].
+ matchBlock value: bLine string ] ].
+ [ (aLine := aLineStream next) == nil ] whileFalse: [
+ bBlock value: aLine string ]!
- [ (xLine := xLineStream next) == nil or: [ xLine == yLine match  ] ]
- whileFalse: [ removeBlock value: xLine string ].
- matchBlock value: yLine string ] ].
- [ (xLine := xLineStream next) == nil ] whileFalse: [
- removeBlock value: xLine string ]!