MCCacheRepository.st
author Claus Gittinger <cg@exept.de>
Mon, 03 Jun 2013 12:32:31 +0200
changeset 878 57dcb488ff87
parent 576 eb260bad5999
child 906 a12f9e7f5421
permissions -rw-r--r--
class: ProjectDefinition changed: #monticelloName

"{ Package: 'stx:goodies/monticello' }"

MCDirectoryRepository subclass:#MCCacheRepository
	instanceVariableNames:'packageCaches seenFiles'
	classVariableNames:''
	poolDictionaries:''
	category:'SCM-Monticello-Repositories'
!

MCCacheRepository class instanceVariableNames:'default'

"
 No other class instance variables are inherited by this class.
"
!


!MCCacheRepository class methodsFor:'as yet unclassified'!

cacheDirectory
	^ (FileDirectory default directoryNamed: 'package-cache')
		assureExistence;
		yourself
!

checkCacheDirectory
	default notNil and: [default directory exists ifFalse: [default _ nil]]
!

default
	self checkCacheDirectory.
	^ default ifNil: [default _ self new directory: self cacheDirectory]
!

description
	^ nil
!

initialize
	self checkCacheDirectory
! !

!MCCacheRepository methodsFor:'as yet unclassified'!

basicStoreVersion: aVersion
	(aVersion isCacheable and: [self allFileNames includes: aVersion fileName])
		ifFalse: [super basicStoreVersion: aVersion]
!

cacheForPackage: aPackage
	packageCaches ifNil: [packageCaches _ Dictionary new].
	^ packageCaches at: aPackage ifAbsentPut: [MCPackageCache new]
!

newFileNames 
	^ self allFileNames difference: self seenFileNames
!

packageForFileNamed: aString
	^ self packageCache at: aString ifAbsentPut: [self versionReaderForFileNamed: aString do: [:r | r package]]
!

rescan
	self newFileNames do:
		[:ea |
		self versionReaderForFileNamed: ea do:
			[:reader |
			(self cacheForPackage: reader package)
				recordVersionInfo: reader info
				forFileNamed: ea.
			self seenFileNames add: ea]]
		displayingProgress: 'Scanning cache...'
!

seenFileNames
	^ seenFiles ifNil: [seenFiles _ OrderedCollection new]
!

versionInfoForFileNamed: aString
	^ self infoCache at: aString ifAbsentPut: [self versionReaderForFileNamed: aString do: [:r | r info]]
! !

!MCCacheRepository class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/goodies/monticello/MCCacheRepository.st,v 1.2 2012-09-11 20:54:09 cg Exp $'
! !

MCCacheRepository initialize!