MCSnapshot.st
author Claus Gittinger <cg@exept.de>
Tue, 08 May 2018 19:54:33 +0200
changeset 1042 3b8c88c55251
parent 1039 88f5b1106042
child 1096 4e37cbca898d
permissions -rw-r--r--
#FEATURE by cg class: MCRepositoryGroup changed: #initializeRepositoriesFromUserSettings

"{ Encoding: utf8 }"

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

"{ NameSpace: Smalltalk }"

Object subclass:#MCSnapshot
	instanceVariableNames:'definitions'
	classVariableNames:''
	poolDictionaries:''
	category:'SCM-Monticello-Base'
!


!MCSnapshot class methodsFor:'as yet unclassified'!

empty
	^ self fromDefinitions: #()
!

fromDefinitions: aCollection
	^ self new initializeWithDefinitions: aCollection
! !

!MCSnapshot methodsFor:'accessing'!

= other
	^ definitions asArray = other definitions asArray
!

definitions
	^ definitions
!

hash
	^ definitions asArray hash
!

includeExtrasForSTX
    "/ do not default to true here, as the version is snapshotted twice in order to
    "/ update the version-strings, and we don not need this stuff in the first round!!
    | includeExtrasForSTX |
    includeExtrasForSTX := self objectAttributeAt: #includeExtrasForSTX.
    ^ includeExtrasForSTX ? false

    "Modified: / 12-08-2013 / 01:57:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

includeExtrasForSTX:something
    self objectAttributeAt: #includeExtrasForSTX put: something.

    "Modified: / 12-08-2013 / 01:57:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!MCSnapshot methodsFor:'converting'!

asChangeSet
    |changes|

    changes := ChangeSet new.
    self definitions do:[:def|def addChangesTo:changes].
    ^ changes

    "Created: / 13-10-2010 / 17:18:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 26-10-2010 / 23:05:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!MCSnapshot methodsFor:'copying'!

postCopy
    "Do half-shallow copy of definitions to allow for their transformation"
    definitions := definitions copy.
    1 to: definitions size do:[:i|
        definitions at: i put: (definitions at:i) copy
    ]

    "Created: / 29-05-2013 / 01:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 31-05-2013 / 00:54:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!MCSnapshot methodsFor:'initializing'!

initializeWithDefinitions: aCollection
	definitions := aCollection.
! !

!MCSnapshot methodsFor:'loading'!

install
	MCPackageLoader installSnapshot: self
!

updatePackage: aPackage
	MCPackageLoader updatePackage: aPackage withSnapshot: self
! !

!MCSnapshot methodsFor:'patching'!

patchRelativeToBase: aSnapshot
	^ MCPatch fromBase: aSnapshot target: self
! !

!MCSnapshot methodsFor:'queries'!

includesClassNamed: className
    definitions reverseDo:[:definition|
        (definition isClassDefinition and:[definition className = className])
            ifTrue:[ ^ true ].
    ].
    ^false

    "Created: / 31-05-2013 / 00:04:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!MCSnapshot class methodsFor:'documentation'!

version
    ^ '$Header$'
!

version_CVS
    ^ '$Header$'
!

version_SVN
    ^ '$Id$'
! !