SVN__Repository.st
author fm
Wed, 23 Sep 2009 18:45:55 +0200
changeset 33 cb4a953f1b9c
child 183 3e8f4e07a809
permissions -rw-r--r--
initial checkin

"{ Package: 'cvut:stx/goodies/libsvn' }"

"{ NameSpace: SVN }"

Object subclass:#Repository
	instanceVariableNames:'manager package url credentials workingCopy'
	classVariableNames:''
	poolDictionaries:''
	category:'SVN-Core'
!

!Repository class methodsFor:'documentation'!

version_SVN
    ^'$Id$'
! !

!Repository class methodsFor:'instance creation'!

package: package url: url

    ^self new 
        package: package;
        url: url; 
        yourself

    "Created: / 19-08-2009 / 12:24:29 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!Repository class methodsFor:'accessing - containers'!

containerNameForClass: cls

    ^(self containerNameWithoutSuffixForClass: cls) , '.' , cls sourceFileSuffix

    "Created: / 19-04-2008 / 17:24:38 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 13-08-2009 / 15:26:22 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

containerNameForExtensions

    ^'extensions.st'

    "Created: / 19-04-2008 / 17:25:24 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

containerNameWithoutSuffixForClass: cls

    ^self containerNameWithoutSuffixForClassNamed: 
        cls theNonMetaclass fullName

    "Created: / 13-08-2009 / 15:25:36 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

containerNameWithoutSuffixForClassNamed: clsName

    | containerName |
    containerName := clsName copyReplaceAll:$: with:$_.
    "/Transcript showCR:'Container for ',clsName,  ' is ' , containerName.
    ^containerName.

    "Created: / 13-08-2009 / 15:24:51 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!Repository methodsFor:'accessing'!

branch

    ^self workingCopy branch

    "Created: / 19-04-2008 / 18:25:39 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

branches

    ^self branchesAndTags reject:[:branch|branch isTag]

    "Modified: / 14-04-2008 / 11:02:07 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

branchesAndTags
    | topLevelDirs  branches |

    branches := OrderedCollection new.
    topLevelDirs := ListCommand list: url.
     "Try trunk branch"
    (topLevelDirs anySatisfy: [:entry | entry path = 'trunk' ]) 
        ifTrue: 
            [ branches add: ((Branch new)
                        repository: self;
                        path: '/trunk/') ]
        ifFalse: 
            [ branches add: ((Branch new)
                        repository: self;
                        path: '').
            ^ branches ].
     "Try  branches"
    (topLevelDirs anySatisfy: [:entry | entry path = 'branches' ]) 
        ifTrue: 
            [ (ListCommand list: url , '/branches/') do: 
                    [:branchEntry | 
                    branches add: ((Branch new)
                                repository: self;
                                path: '/branches/' , branchEntry path) ] ].
     "Try tags"
    (topLevelDirs anySatisfy: [:entry | entry path = 'tags' ]) 
        ifTrue: 
            [ (ListCommand list: url , '/tags/') do: 
                    [:branchEntry | 
                    branches add: ((Branch new)
                                repository: self;
                                path: '/tags/' , branchEntry path) ] ].
    ^ branches.

    "Created: / 14-04-2008 / 11:01:15 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 19-08-2009 / 13:27:48 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

manager
    ^ manager

    "Created: / 03-10-2008 / 15:41:49 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

manager:aRepositoryManager
    manager := aRepositoryManager.

    "Created: / 03-10-2008 / 15:41:49 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

package
    ^ package

    "Created: / 15-03-2008 / 20:22:51 / janfrog"
!

package:something
    package := something.

    "Created: / 15-03-2008 / 20:22:51 / janfrog"
!

packageClasses

    ^self workingCopy packageClasses

    "Created: / 19-04-2008 / 19:07:41 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

packageExtensions

    ^self workingCopy packageExtensions

    "Created: / 19-04-2008 / 19:07:52 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

url
    ^ url

    "Created: / 15-03-2008 / 20:21:30 / janfrog"
!

url:aString
    url := aString.

    "Created: / 15-03-2008 / 20:21:30 / janfrog"
!

workingCopy
    ^ workingCopy

    "Created: / 15-03-2008 / 20:30:13 / janfrog"
!

workingCopy:aWorkingCopy 
    workingCopy := aWorkingCopy.
    workingCopy repository: self.

    "Created: / 15-03-2008 / 20:30:13 / janfrog"
    "Modified: / 31-03-2008 / 12:47:43 / janfrog"
! !

!Repository methodsFor:'accessing - containers'!

containerNameForClass:arg
    ^ self class containerNameForClass:arg
!

containerNameForExtensions
    ^ self class containerNameForExtensions
! !

!Repository methodsFor:'accessing - tasks'!

commitTask

    ^self workingCopy commitTask

    "Created: / 24-03-2009 / 15:14:31 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

updateTask

    ^self workingCopy updateTask

    "Created: / 24-03-2009 / 15:14:40 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!Repository methodsFor:'comparing'!

= anotherRepo

    ^self class = anotherRepo class
        and:[self url = anotherRepo url
            and:[self package = anotherRepo package]]

    "Created: / 31-03-2008 / 14:39:29 / janfrog"
!

hash

    ^url hash bitXor: package hash

    "Created: / 31-03-2008 / 14:39:57 / janfrog"
! !

!Repository methodsFor:'error reporting'!

svnError: aMessage

    self error: aMessage

    "Created: / 19-03-2008 / 10:00:55 / janfrog"
! !

!Repository methodsFor:'queries'!

exists

    ^[
        ListCommand new
            branch: self;
            execute.
        true
    ] on: SVN::Error do:[ false ]

    "Created: / 16-03-2008 / 12:12:17 / janfrog"
    "Modified: / 19-08-2009 / 13:08:25 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!Repository class methodsFor:'documentation'!

version
    ^ '$Header$'
! !