initial checkin
authorfm
Wed, 23 Sep 2009 18:43:00 +0200
changeset 7 00a4de6327c3
parent 6 a85577d2ccce
child 8 31b33be27220
initial checkin
SVN__Branch.st
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SVN__Branch.st	Wed Sep 23 18:43:00 2009 +0200
@@ -0,0 +1,394 @@
+"{ Package: 'cvut:stx/goodies/libsvn' }"
+
+"{ NameSpace: SVN }"
+
+Object subclass:#Branch
+	instanceVariableNames:'repository path'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'SVN-Core'
+!
+
+!Branch class methodsFor:'documentation'!
+
+version_SVN
+    ^'$Id$'
+! !
+
+!Branch class methodsFor:'instance creation'!
+
+repository: aRepository path: aString
+
+    ^self new
+        repository: aRepository;
+        path: aString;
+        yourself
+
+    "Created: / 19-08-2009 / 11:19:44 / Jan Vrany <vranyj1@fel.cvut.cz>"
+! !
+
+!Branch methodsFor:'accessing'!
+
+icon
+
+
+    self isBranch ifTrue:[^IconLibrary branch].
+    self isTag ifTrue:[^IconLibrary tag].
+    ^IconLibrary empty
+
+    "Created: / 11-04-2008 / 13:45:32 / Jan Vrany <vranyj1@fel.cvut.cz>"
+    "Modified: / 14-04-2008 / 11:15:01 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+name
+
+    ^path isNilOrEmptyCollection 
+        ifTrue:['<no branch>']
+        ifFalse:[path]
+
+    "Created: / 19-03-2008 / 08:27:54 / janfrog"
+    "Modified: / 31-03-2008 / 15:20:04 / janfrog"
+!
+
+package
+
+    ^repository package
+
+    "Created: / 20-05-2008 / 17:56:45 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+path
+    ^ path
+
+    "Created: / 19-03-2008 / 08:27:47 / janfrog"
+!
+
+path:aString
+    path := aString.
+    (path endsWith: $/) ifFalse:
+        [path := path , $/]
+
+    "Created: / 19-03-2008 / 08:27:47 / janfrog"
+    "Modified: / 22-10-2008 / 13:18:24 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+repository
+    ^ repository
+
+    "Created: / 19-03-2008 / 08:28:39 / janfrog"
+!
+
+repository:something
+    repository := something.
+
+    "Created: / 19-03-2008 / 08:28:39 / janfrog"
+!
+
+url
+
+    ^repository url , path
+
+    "Created: / 19-03-2008 / 09:40:41 / janfrog"
+! !
+
+!Branch methodsFor:'accessing - change sets'!
+
+changeSet
+
+    ^self changeSet: Revision head
+
+    "Created: / 19-04-2008 / 14:09:08 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+changeSet: revision
+
+    | entries changeSet |
+    SVN::ActivityNotification notify:'Listing repository'.
+    entries := (self list: revision) select:[:entry|entry kind isSourceContainer].
+    changeSet := ChangeSet new.
+    SVN::ActivityNotification notify:'Creating change set for revision ' , revision printString.
+    entries withIndexDo:
+        [:entry :index|
+        changeSet addAll:
+            (self changeSetForContainer: entry path revision: revision).
+        SVN::ProgressNotification 
+            notify:'Creating change set for revision ' , revision printString
+            progress: ((100 / entries size) * index) rounded].
+    ^changeSet
+
+    "Created: / 19-04-2008 / 14:09:30 / Jan Vrany <vranyj1@fel.cvut.cz>"
+    "Modified: / 28-10-2008 / 13:00:05 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+changeSetForClass: cls
+
+    ^self changeSetForClass: cls revision: Revision head
+
+    "Created: / 19-04-2008 / 17:24:04 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+changeSetForClass: cls revision: revision
+
+    ^self 
+        changeSetForContainer:(repository containerNameForClass: cls)
+        revision: revision.
+
+    "Created: / 19-04-2008 / 17:23:46 / Jan Vrany <vranyj1@fel.cvut.cz>"
+    "Modified: / 19-04-2008 / 20:20:17 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+changeSetForContainer: container revision: revision
+
+    | containerStream |
+    containerStream := (self 
+                            cat:container
+                            revision: revision) readStream.
+    ^ChangeSet fromStream: containerStream.
+
+    "Created: / 19-04-2008 / 20:18:51 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+changeSetForExtensions
+
+    ^self changeSetForExtensionsRevision: Revision head
+
+    "Created: / 19-04-2008 / 20:21:29 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+changeSetForExtensionsRevision: revision
+
+    ^self 
+        changeSetForContainer:(repository containerNameForExtensions)
+        revision: revision.
+
+    "Created: / 19-04-2008 / 19:08:52 / Jan Vrany <vranyj1@fel.cvut.cz>"
+    "Modified: / 19-04-2008 / 20:20:58 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+changeSetForLoad:revision 
+    |diffSet classesToRemove|
+
+    diffSet := self diffSetBetweenImageAndRevision:revision.
+    classesToRemove := Set new.
+    SVN::ActivityNotification notify:'Computing load set'.
+    "self = image, arg = revision"
+    ^(diffSet onlyInArg) ,
+        (diffSet changed collect:[:changePair | changePair second ])
+            , (diffSet onlyInReceiver 
+                select:[:change | change isClassDefinitionChange ]
+                thenCollect:
+                    [:change |
+                    classesToRemove add:change className.
+                    ClassRemoveChange className:change className])
+                , (diffSet onlyInReceiver 
+                        select:
+                            [:change | 
+                            change isMethodDefinitionChange 
+                                and:[ (classesToRemove includes:change className) not ]]
+                            thenCollect:
+                                [:change | 
+                                MethodRemoveChange className:change className selector:change selector])
+
+    "Created: / 22-10-2008 / 11:08:06 / Jan Vrany <vranyj1@fel.cvut.cz>"
+    "Modified: / 07-11-2008 / 08:09:48 / Jan Vrany <vranyj1@fel.cvut.cz>"
+! !
+
+!Branch methodsFor:'accessing - diff sets'!
+
+diffSetBetweenImageAndRevision: revision
+
+    | imageChangeSet revisionChangeSet |
+    imageChangeSet := ChangeSet forPackage: self package.
+    revisionChangeSet := self changeSet: revision.
+    ^imageChangeSet diffSetsAgainst: revisionChangeSet
+
+    "Created: / 20-05-2008 / 17:56:02 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+diffSetBetweenRevision: revisionA andRevision: revisionB
+
+    | revisionAChangeSet revisionBChangeSet |
+    revisionAChangeSet := self changeSet: revisionA.
+    revisionBChangeSet := self changeSet: revisionB.
+    ^revisionAChangeSet diffSetsAgainst: revisionBChangeSet
+
+    "Created: / 20-05-2008 / 17:58:20 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+diffSetForClass: cls betweenImageAndRevision: revision
+
+    | imageChangeSet revisionChangeSet |
+    imageChangeSet := ChangeSet forExistingClass:cls withExtensions: false extensionsOnly:false.
+    revisionChangeSet := self changeSetForClass: cls revision: revision.
+    ^imageChangeSet diffSetsAgainst: revisionChangeSet
+
+    "Created: / 19-04-2008 / 18:34:06 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+diffSetForExtensionsBetweenImageAndRevision: revision
+
+    | imageChangeSet revisionChangeSet |
+    imageChangeSet := ChangeSet forExistingMethods: repository packageExtensions.
+    revisionChangeSet := self changeSetForExtensionsRevision: revision.
+    ^imageChangeSet diffSetsAgainst: revisionChangeSet
+
+    "Created: / 19-04-2008 / 19:08:33 / Jan Vrany <vranyj1@fel.cvut.cz>"
+! !
+
+!Branch methodsFor:'commands'!
+
+cat: file
+
+    ^self cat: file revision: Revision head
+
+    "Created: / 19-04-2008 / 10:51:54 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+cat: file revision: revision
+
+    ^CatCommand new
+        branch: self;
+        path: file;
+        revision: revision;
+        execute.
+
+    "Created: / 19-04-2008 / 10:51:54 / Jan Vrany <vranyj1@fel.cvut.cz>"
+    "Modified: / 19-08-2009 / 10:00:59 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+list
+
+
+    ^self list: Revision head.
+
+    "Created: / 19-04-2008 / 13:42:23 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+list: revision
+
+    ^ListCommand new
+        branch: self;
+        recursive: true;
+        revision: revision;
+        execute
+
+    "Created: / 19-04-2008 / 13:42:50 / Jan Vrany <vranyj1@fel.cvut.cz>"
+    "Modified: / 19-08-2009 / 10:01:08 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+log
+
+    ^self log: ''
+
+    "Created: / 19-04-2008 / 10:52:45 / Jan Vrany <vranyj1@fel.cvut.cz>"
+    "Modified: / 19-04-2008 / 12:16:01 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+log: stringOrClass
+
+    | container |
+    container := stringOrClass isBehavior 
+                    ifFalse:[stringOrClass]
+                    ifTrue:[repository containerNameForClass: stringOrClass].
+
+    ^LogCommand new
+        branch: self;
+        path: container;
+        execute
+
+    "Created: / 19-04-2008 / 10:52:45 / Jan Vrany <vranyj1@fel.cvut.cz>"
+    "Modified: / 19-08-2009 / 10:03:11 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+revert
+
+    self repository workingCopy revert
+
+    "Created: / 22-10-2008 / 16:46:30 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+revert: paths
+
+    self repository workingCopy revert: paths
+
+    "Created: / 03-11-2008 / 21:21:44 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+update
+
+    self repository workingCopy update
+
+    "Created: / 22-10-2008 / 16:41:22 / Jan Vrany <vranyj1@fel.cvut.cz>"
+! !
+
+!Branch methodsFor:'comparing'!
+
+= anotherBranch
+
+    ^self class = anotherBranch class
+        and:[self repository = anotherBranch repository
+            and:[self path = anotherBranch path]]
+
+    "Created: / 31-03-2008 / 14:38:38 / janfrog"
+!
+
+hash
+
+    ^path hash bitXor: repository hash
+
+    "Created: / 31-03-2008 / 14:37:45 / janfrog"
+! !
+
+!Branch methodsFor:'displaying'!
+
+displayOn:aGC x:x y:y
+
+    ^(LabelAndIcon 
+        label: self name
+        icon: self icon) displayOn: aGC x:x y:y
+
+    "Created: / 14-04-2008 / 11:11:01 / Jan Vrany <vranyj1@fel.cvut.cz>"
+! !
+
+!Branch methodsFor:'printing & storing'!
+
+printOn:aStream
+    "append a printed representation if the receiver to the argument, aStream"
+
+    super printOn:aStream.
+    aStream nextPut:$(.
+    path printOn:aStream.
+    aStream nextPut:$).
+
+    "Created: / 19-03-2008 / 08:34:04 / janfrog"
+! !
+
+!Branch methodsFor:'testing'!
+
+isBranch
+
+    ^path startsWith:'/branches'
+
+    "Created: / 19-03-2008 / 08:42:46 / janfrog"
+!
+
+isTag
+
+    ^path startsWith:'/tags'
+
+    "Created: / 19-03-2008 / 08:42:53 / janfrog"
+!
+
+isTrunk
+
+    ^path = '/trunk/' or:[path = '']
+
+    "Created: / 19-03-2008 / 08:42:58 / janfrog"
+    "Modified: / 14-04-2008 / 12:48:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
+! !
+
+!Branch class methodsFor:'documentation'!
+
+version
+    ^ '$Header$'
+! !