Skip to content

Commit

Permalink
Move log trimming from postscript to class method
Browse files Browse the repository at this point in the history
...to avoid accessing the class variables through the classPool dictionary.
  • Loading branch information
j4yk committed Mar 19, 2024
1 parent 7534ab5 commit cc4a992
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/FileSystem-Git.package/.squot-contents
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SquotTrackedObjectMetadata {
#objectClassName : #PackageInfo,
#id : UUID [ '9d2378120e641f4fad4dd02310c91f53' ],
#slotOverrides : { },
#objectsReplacedByNames : true,
#slotOverrides : { },
#serializer : #SquotCypressCodeSerializer
}
12 changes: 12 additions & 0 deletions src/FileSystem-Git.package/GitStore.class/class/trimLog.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
internal
trimLog
"Fix too large log list due to a bug in the tally optimization from November 28, 2021.
Original code was added by Christoph Thiede (ct) in the package postscript."
"GitStore trimLog"
| maxLogSize count |
LogMessages ifNil: [^ self].
maxLogSize := 5000.
(LogMutex ifNil: [LogMutex := Mutex new]) critical:
[count := LogMessages size.
LogMessages := (LogMessages asArray last: (count := count clampHigh: maxLogSize)) as: LinkedList. "forth and back conversion to avoid inefficient LinkedList(...)>>#last: (quadratic in older versions of Squeak)"
LogMessageCount := count].
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"cleanUp:" : "ct 1/10/2024 18:18",
"logMessage:" : "ct 1/10/2024 18:17",
"memory" : "CamilloBruni 8/30/2012 14:04",
"openLog" : "jr 6/29/2017 10:42" },
"openLog" : "jr 6/29/2017 10:42",
"trimLog" : "jr 3/19/2024 14:13" },
"instance" : {
"addParent:" : "jr 2/26/2017 00:10",
"basenameFromEntry:" : "jr 3/6/2017 23:35",
Expand Down
8 changes: 2 additions & 6 deletions src/FileSystem-Git.package/monticello.meta/postscript.st
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,5 @@ FileSystemGitCompatibility hadInadequateFromUnixTimeImplementation ifFalse:
FileSystemGitCompatibility ensureValidFromUnixTimeImplementation.
"2024-01-10: fix git log rotation and truncate older logs, see https://github.com/hpi-swa/Squot/pull/410"
(GitStore classPool at: #LogMessages) ifNotNil: [:logMessages |
| count |
count := logMessages size.
GitStore classPool
at: #LogMessages put: ((logMessages asArray last: (count := 5000 clampHigh: count)) as: LinkedList) "forth and back conversion to avoid inefficient LinkedList(...)>>#last: (quadratic in older versions of Squeak)";
at: #LogMessageCount put: count].'!
GitStore trimLog.
'!

0 comments on commit cc4a992

Please sign in to comment.