[squeak-dev] MCFileRepositoryInspector sort bug

Eliot Miranda eliot.miranda at gmail.com
Tue Mar 14 02:12:37 UTC 2017


Hi All,

    if one has a set of packages with some versions with identical version
numbers but different timestamps then the default sort-by-version-number
list can be displayed in the wrong order.  For example take a look at the
VMMaker.oscog package in

MCHttpRepository
location: 'http://source.squeak.org/VMMaker'
user: 'squeak'
password: 'squeak'

Versions such as VMMaker.oscog-eem.2151 & VMMaker.oscog-cb.2151 may be
displayed in the wrong order because the sort-by-version-number block
in MCRepositoryInspector>>#orderSpecs doesn't look at time stamps when the
version numbers are the same.

In fact it does this for good reason.  It takes an *age* to obtain he
timestamp from a version number because the scanner
in MCMczReader>>#loadVersionInfo reads the entire version info.  There
isn't a path to scan just enough tokens to retrieve the time stamp.

I don't have the time or the Monticello chops to fix this but if anyone
does I'd be grateful.  I got as far as the following before I realised I
needed to write a timestamp-specific path through the MCVersionName ->
MCVersionInfo path that avoids parsing the entire version literal.

(See attached)
Added a sortCache inst var to MCRepositoryInspector.
Changed
MCRepositoryInspector>>versionList
| result |
result := selectedPackage
ifNil: [ self versionNamesForNoPackageSelection ]
ifNotNil: [ self versionNamesForSelectedPackage ].
(self orderSpecs at: order) value ifNotNil:
[ : sortBlock |
sortCache := Dictionary new.
result sort: sortBlock ].
sortCache := nil.
^result collect:
[ : each | self versionHighlight: each ]

MCRepositoryInspector>>orderSpecs
^{
'unchanged' -> nil.
'order by package' -> [ :x :y | x packageName < y packageName ].
'order by author' -> [ :x :y | x author caseInsensitiveLessOrEqual: y
author ].
'order by version-string' -> [ :x :y | x versionNumber asString < y
versionNumber asString ].
'order by version-number' -> [ :x :y | | vx vy |
x versionNumber > y versionNumber
or: [x versionNumber = y versionNumber
and: [vx := sortCache at: x ifAbsentPut: [repository
versionInfoForFileNamed: x].
vy := sortCache at: y ifAbsentPut: [repository versionInfoForFileNamed: y].
vx timeStamp > vy timeStamp]]].
'order by filename' -> [ :x :y | x < y ].
}

Fixed what looks like a bug in
MCCacheRepository>>versionInfoForFileNamed: aString
^ cache at: aString ifAbsentPut: [self versionReaderForFileNamed: aString
do: [:r | r info]]

_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20170313/1d1bf82d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MCsortmethods.st
Type: application/octet-stream
Size: 1840 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20170313/1d1bf82d/attachment.obj>


More information about the Squeak-dev mailing list