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' }"
SCMAbstractPackageModelRegistry subclass:#HGPackageModelRegistry
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'SCM-Mercurial-StX'
!
!HGPackageModelRegistry 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.
"
! !
!HGPackageModelRegistry methodsFor:'accessing'!
packageNamed:package
"Returns a HGPackageModel for given package or nil
if given package is not backed by Mercurial repository."
| dir components names directories root rootI rootD pkg|
packages at: package ifPresent: [ :p | ^ p ].
dir := Smalltalk getPackageDirectoryForPackage: package.
dir isNil ifTrue:[ ^ nil ].
components := OrderedCollection new.
names := OrderedCollection new.
(package includes: $:) ifFalse:[
components := package.
names := package.
] ifTrue:[
| i1 i2 |
i1 := 1.
i2 := package indexOf: $:.
components add: (package copyFrom: i1 to: i2 - 1).
names add: (package copyFrom: 1 to: i2 - 1).
i1 := i2 + 1.
[ (i2 := package indexOf: $/ startingAt: i1) ~~ 0 ] whileTrue:[
components add: (package copyFrom: i1 to: i2 - 1).
names add: (package copyFrom: 1 to: i2 - 1).
i1 := i2 + 1.
].
components add: (package copyFrom: i1 ).
names add: package
].
directories := Array new: components size.
directories at: components size put: dir.
directories size - 1 downTo: 1 do:[:i|
directories at: i put: (directories at: i + 1) directory.
].
"/ search cached packages...
1 to: names size do:[:i|
packages at: (names at:i) ifPresent:[:p|root := p. rootI := i].
].
root isNil ifTrue:[
directories withIndexDo:[:each :eachI|
( each / '.hg' ) exists ifTrue:[
rootD := each.
rootI := eachI.
].
].
rootD isNil ifTrue:[ ^ nil ].
root := HGPackageModel new
setName: (names at: rootI)
repository: (HGRepository on: rootD).
packages at: root name put: root.
].
pkg := root.
rootI + 1 to: components size do:[:each|
pkg := pkg construct: (components at:each).
packages at: pkg name put: pkg.
].
^pkg
"Created: / 14-11-2012 / 00:15:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 03-12-2012 / 14:27:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGPackageModelRegistry methodsFor:'initialization'!
flush: pattern
"Flushes all cached data packages matching given name."
| toFlush |
toFlush := OrderedCollection new.
packages valuesDo:[:package|
(package name matches: pattern) ifTrue:[toFlush add: package]].
toFlush do:[:package|
| wcdir |
repositories removeKey: package repository path ifAbsent:[nil].
wcdir := package temporaryWorkingCopy path.
[ wcdir recursiveRemove ] on: Error do:[
OperatingSystem isMSWINDOWSlike ifTrue:[
Delay waitForSeconds: 1.
wcdir recursiveRemove.
].
].
packages removeKey: package name
].
"Created: / 16-11-2012 / 19:40:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 22-11-2012 / 16:03:07 / jv"
"Modified: / 01-12-2012 / 00:32:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGPackageModelRegistry class methodsFor:'documentation'!
version_HG
^ '$Changeset: <not expanded> $'
!
version_SVN
^ '§Id:: §'
! !