ChangeSetDiffSet.st
changeset 2408 c5c99ce9ab0d
child 2427 8a55734614cb
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ChangeSetDiffSet.st	Wed Jul 06 13:47:51 2011 +0200
@@ -0,0 +1,239 @@
+"
+ Copyright (c) 2007-2010 Jan Vrany, SWING Research Group,
+                           Czech Technical University in Prague
+ Copyright (c) 2009-2010 eXept Software AG
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the 'Software'), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+"
+"{ Package: 'stx:libbasic3' }"
+
+ChangeSetDiffComponent subclass:#ChangeSetDiffSet
+	instanceVariableNames:'name versionALabel versionBLabel versionBaseLabel diffs'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'System-Changes-Diff'
+!
+
+!ChangeSetDiffSet class methodsFor:'documentation'!
+
+copyright
+"
+ Copyright (c) 2007-2010 Jan Vrany, SWING Research Group,
+                           Czech Technical University in Prague
+ Copyright (c) 2009-2010 eXept Software AG
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the 'Software'), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+
+"
+! !
+
+!ChangeSetDiffSet class methodsFor:'instance creation'!
+
+new
+    ^ self basicNew initialize.
+! !
+
+!ChangeSetDiffSet methodsFor:'accessing'!
+
+diffs
+    ^ diffs
+!
+
+flattened
+
+    | flattened s |
+    flattened := self copy.
+    s := (OrderedCollection new: diffs size) writeStream.
+    self flattenOn: s.
+    flattened setDiffs: s contents.
+    ^flattened
+
+    "Created: / 05-12-2009 / 11:09:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+merged
+
+    ^diffs allSatisfy:[:e|e merged]
+
+    "Created: / 24-11-2009 / 10:04:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+name
+    ^ name ? '<unnamed>'
+
+    "Modified: / 26-11-2009 / 16:26:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+name:aString
+    name := aString.
+!
+
+resolution
+
+    | changeset |
+    changeset := ChangeSet new.
+    self do:
+        [:diff|
+        diff versionMerged ifNotNil:
+            [changeset add: diff versionMerged]].
+    ^changeset
+
+    "Created: / 26-11-2009 / 08:44:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+versionALabel
+    ^ versionALabel ifNil:[parent ifNotNil:[parent versionALabel]]
+
+    "Modified: / 21-11-2009 / 07:50:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+versionALabel:aString
+    versionALabel := aString.
+!
+
+versionBLabel
+    ^ versionBLabel ifNil:[parent ifNotNil:[parent versionBLabel]]
+
+    "Modified: / 21-11-2009 / 07:51:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+versionBLabel:aString
+    versionBLabel := aString.
+!
+
+versionBaseLabel
+
+    ^ versionBaseLabel ifNil:[parent ifNotNil:[parent versionBaseLabel]]
+
+    "Created: / 23-11-2009 / 22:54:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 24-11-2009 / 09:21:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+versionBaseLabel:aString
+    versionBaseLabel := aString.
+! !
+
+!ChangeSetDiffSet methodsFor:'adding & removing'!
+
+add: anObject
+
+    anObject parent: self.
+    ^diffs add: anObject
+
+    "Created: / 09-11-2009 / 12:36:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 10-11-2009 / 11:26:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+addAll: aCollection
+
+    aCollection do:[:e|self add:e]
+
+    "Created: / 10-11-2009 / 11:27:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!ChangeSetDiffSet methodsFor:'enumerating'!
+
+collect: aBlock
+
+    ^diffs collect: aBlock
+
+    "Created: / 10-11-2009 / 11:26:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+do: aBlock
+
+    ^diffs do: [:each|each do:aBlock]
+
+    "Created: / 10-11-2009 / 11:26:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 25-11-2009 / 10:30:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!ChangeSetDiffSet methodsFor:'initialization'!
+
+initialize
+    "Invoked when a new instance is created."
+
+    "/ please change as required (and remove this comment)
+    "/ name := nil.
+    "/ versionALabel := nil.
+    "/ versionBLabel := nil.
+    diffs := OrderedCollection new:4.
+
+    "/ super initialize.   -- commented since inherited method does nothing
+
+    "Modified: / 10-11-2009 / 11:25:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+setDiffs: aCollection
+
+    diffs := aCollection
+
+    "Created: / 05-12-2009 / 11:09:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!ChangeSetDiffSet methodsFor:'private'!
+
+flattenOn: stream
+
+    diffs do:[:diff|diff flattenOn: stream]
+
+    "Created: / 05-12-2009 / 11:07:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!ChangeSetDiffSet methodsFor:'testing'!
+
+isDiffSet
+    ^ true
+!
+
+isEmpty
+
+    ^diffs isEmpty or:[diffs allSatisfy: [:diff|diff isEmpty]]
+
+    "Created: / 25-11-2009 / 20:37:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 09-12-2009 / 17:43:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!ChangeSetDiffSet class methodsFor:'documentation'!
+
+version_CVS
+    ^ '$Header: /cvs/stx/stx/libbasic3/ChangeSetDiffSet.st,v 1.1 2011-07-06 11:47:51 vrany Exp $'
+! !