MCFileRepositoryInspector sort bug

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

MCFileRepositoryInspector sort bug

Eliot Miranda-2
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

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.
| 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 ]

'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

MCsortmethods.st (2K) Download Attachment