Monticello
Ramon Leon
ramon.leon at allresnet.com
Tue Dec 12 16:04:18 UTC 2006
> The following is the "Monticello Code" I use. I does not
> really load the latest version. It loads the version with the
> biggest version number. This has the advantage that it does
> not download all the versions in order to find out their
> timestamp. This works better for large repositories like Seaside.
>
> loadLatestPackage: aString from: aPath
> | repository versionsBlock versions tries version |
> repository := MCHttpRepository
> location: aPath
> user: username
> password: password.
>
> versionsBlock := [ (repository allVersionNames select: [ :each |
> each beginsWith: aString ])
> asSortedCollection: [ :a :b |
> (a copyAfterLast: $.) asNumber <= (b
> copyAfterLast: $.) asNumber ] ] fixTemps.
> versions := versionsBlock value.
>
> tries := 0.
> [ versions isEmpty and: [ tries < 3 ] ] whileTrue: [
> versions := versionsBlock value.
> tries := tries + 1 ].
> versions isEmpty ifTrue: [ self error: 'problems when
> accessing squeaksource' ].
>
> version := (repository versionReaderForFileNamed:
> versions last ,
> '.mcz') version.
> version load.
> version workingCopy repositoryGroup addRepository: repository.
>
> Philippe
Thanks, I ended up using this, derived from your code, but abstracting out
the repository and loading, this just finds the newest package in a
repository and returns it's version info. Works like a charm...
findNewestVersionOf: aPackageName from: aRepository
| versionsBlock versions tries |
versionsBlock :=
[(aRepository allVersionNames
select: [:each | each beginsWith: aPackageName])
asSortedCollection:
[:a :b |
(a copyAfterLast: $.) asNumber <= (b copyAfterLast:
$.) asNumber]]
fixTemps.
versions := versionsBlock value.
tries := 0.
[versions isEmpty and: [tries < 3]] whileTrue:
[versions := versionsBlock value.
tries := tries + 1].
versions isEmpty
ifTrue: [self error: 'problems when accessing repository'].
^aRepository versionInfoFromFileNamed: versions last , '.mcz'
Ramon Leon
http://onsmalltalk.com
More information about the Squeak-dev
mailing list
|