Added copyright notice.
"
COPYRIGHT (c) 2012-2013 by Jan Vrany
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
"{ Package: 'stx:libscm/mercurial' }"
SCMAbstractPackageModel subclass:#HGPackageModel
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'SCM-Mercurial-StX'
!
!HGPackageModel class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 2012-2013 by Jan Vrany
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
! !
!HGPackageModel class methodsFor:'instance creation'!
named:package
^HGPackageModelRegistry packageNamed: package
"Modified: / 16-11-2012 / 19:53:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGPackageModel methodsFor:'accessing'!
manager
^ HGSourceCodeManager
"Created: / 14-11-2012 / 01:02:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
repository
"Returns original package repository (not the temporary repository)"
^repository
"Created: / 15-11-2012 / 09:47:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 01-12-2012 / 00:33:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
revision
"Return a logical revision of the package, i.e., a revision
on which the next commit will be based on"
^self definition hgLogicalRevision
"Created: / 28-11-2012 / 09:41:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
temporaryRepository
self ensureTemporaryWorkingCopy.
^wc repository
"Created: / 01-12-2012 / 00:31:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGPackageModel methodsFor:'accessing-classes'!
commitDialogClass
"raise an error: must be redefined in concrete subclass(es)"
^ HGCommitDialog
"Created: / 14-11-2012 / 22:30:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
commitTaskClass
^ HGCommitTask
"Created: / 14-11-2012 / 00:36:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGPackageModel methodsFor:'initialization'!
setName:aSymbolOrPackageId repository:aRepository
| wcopy wcopyroot components |
name := aSymbolOrPackageId asSymbol.
repository := aRepository.
wcopy := repository workingCopy.
components := (name copyReplaceAll:$: with:$/) tokensBasedOn:$/.
wcopyroot := wcopy root.
"This is rubbish but I have to move on..."
1 to:components size do:[:i |
| f |
f := wcopy root asFilename.
i to:components size do:[:j |
f := f / (components at:j).
].
f exists ifTrue:[
wcopyroot := wcopy root.
i to:components size do:[:j |
wcopyroot := wcopyroot / (components at:j).
].
repositoryRoot := wcopyroot pathNameRelative.
^ self.
]
].
repositoryRoot := '.'.
"Created: / 01-12-2012 / 17:52:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified (format): / 03-12-2012 / 14:45:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGPackageModel methodsFor:'private'!
commited
"Sent by commit task once commited"
| versionMethod |
super commited.
versionMethod := self definition class compiledMethodAt: HGSourceCodeManager nameOfVersionMethodInClasses.
versionMethod isNil ifTrue:[
self error:'Should not happen!!'.
].
versionMethod annotateWith:
(HGRevisionAnnotation revision: wc changeset id)
"Created: / 23-11-2012 / 22:52:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGPackageModel methodsFor:'utils'!
ensureTemporaryWorkingCopy
"raise an error: must be redefined in concrete subclass(es)"
| rev tmpPath tmpRepo tmpWc |
rev := self definition hgLogicalRevision.
(wc notNil and:[ wc path exists ]) ifTrue:[
^ self
].
tmpPath := self manager temporaryWorkingCopyDirectory
/ repository uuid printString.
tmpPath exists ifTrue:[
tmpRepo := HGRepository on:tmpPath.
tmpRepo pull.
] ifFalse:[
tmpRepo := repository cloneTo:tmpPath update:false.
].
tmpWc := tmpRepo workingCopy.
"If it is fresh repository, it has no changeset yet..."
(rev ~~ HGChangesetId null) ifTrue:[
tmpWc update:rev.
].
"Update branch to match branch of master working copy"
tmpWc branch: repository workingCopy branch name.
self setWorkingCopy:tmpWc
"Created: / 14-11-2012 / 00:16:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 14-01-2013 / 14:27:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
ensureTemporaryWorkingCopyAtRevision:rev
"Make sure temporary working exists and is at
given revision"
| cs r |
r := rev.
r revno isNil ifTrue:[
cs := self repository changesetWithId: rev.
r := cs id.
].
self ensureTemporaryWorkingCopy.
(r revno ~~ -1) ifTrue:[
r revno notNil ifTrue:[
wc update:r revno printString.
] ifFalse:[
wc update:r printString.
].
"Update branch to match branch of master working copy"
wc branch: repository workingCopy branch name.
].
"Created: / 28-11-2012 / 09:38:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 22-01-2013 / 20:49:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGPackageModel class methodsFor:'documentation'!
version_GIT
"Never, ever change this method. Ask JV or CG why"
^thisContext method mclass theNonMetaclass instVarNamed: #revision
!
version_HG
^ '$Changeset: <not expanded> $'
!
version_SVN
^ '§Id:: §'
! !