Skip to content

Commit

Permalink
improved lineSequence algorithm (still not complete) feenkcom/gtoolki…
Browse files Browse the repository at this point in the history
  • Loading branch information
girba committed Nov 4, 2024
1 parent f5f57fc commit 8589f80
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/Iceberg-Git-CLI/PureGitTrackedFile.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,15 @@ PureGitTrackedFile >> file: aGitFile [
PureGitTrackedFile >> lineSequences [
| sequences lines |
sequences := OrderedCollection new.
lines := self uniqueTrackedLines asOrderedCollection.
lines := self uniqueTrackedLines
sorted: [ :a :b |
a startVersion < b startVersion
or: [ a startVersion = b startVersion
and: [ a positionInStartVersion < b positionInStartVersion ] ] ].
sequences add: (PureGitTrackedLineSequence new addLine: lines first).
lines allButFirst
do: [ :each |
(sequences last lines first startVersion = each startVersion
and: [ sequences last lines first endVersion = each endVersion ])
sequences last endVersion = each endVersion
ifTrue: [ sequences last addLine: each ]
ifFalse: [ sequences add: (PureGitTrackedLineSequence new addLine: each) ] ].
^ sequences
Expand Down
22 changes: 21 additions & 1 deletion src/Iceberg-Git-CLI/PureGitTrackedLine.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,19 @@ PureGitTrackedLine >> endVersion [
self positionsInVersions reverse
doWithIndex: [ :each :index |
(end isZero and: each isZero not)
ifTrue: [ end := self positionsInVersions size - index ] ].
ifTrue: [ end := self positionsInVersions size - index + 1 ] ].
^ end
]

{ #category : #'as yet unclassified' }
PureGitTrackedLine >> gtPositionsInVersionsFor: aView [
<gtView>
^ aView list
title: 'Positions';
priority: 50;
items: [ self positionsInVersions ]
]

{ #category : #initialization }
PureGitTrackedLine >> initializeForNumberOfVersions: count [
positionInVersions := Array new: count withAll: 0
Expand All @@ -52,6 +61,16 @@ PureGitTrackedLine >> line: aString [
line := aString
]

{ #category : #'as yet unclassified' }
PureGitTrackedLine >> positionInEndVersion [
^ self positionInVersionAt: self endVersion
]

{ #category : #'as yet unclassified' }
PureGitTrackedLine >> positionInStartVersion [
^ self positionInVersionAt: self startVersion
]

{ #category : #accessing }
PureGitTrackedLine >> positionInVersionAt: index [
^ positionInVersions at: index
Expand All @@ -75,6 +94,7 @@ PureGitTrackedLine >> printOn: stream [
nextPutAll: line;
nextPut: $);
space;
nextPutAll: 'ver. ';
nextPutAll: self startVersion asString;
nextPutAll: '-';
nextPutAll: self endVersion asString
Expand Down
2 changes: 1 addition & 1 deletion src/Iceberg-Git-CLI/PureGitTrackedLineSequence.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ PureGitTrackedLineSequence >> endVersion [
PureGitTrackedLineSequence >> gtDisplayOn: stream [
stream
nextPutAll: self lines size asString;
nextPutAll: ' lines ';
nextPutAll: ' lines in ver. ';
nextPutAll: self startVersion asString;
nextPutAll: '-';
nextPutAll: self endVersion asString
Expand Down

0 comments on commit 8589f80

Please sign in to comment.