ChangeSetDiffEntry.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 30 Jan 2012 17:19:14 +0000
branchjv
changeset 3012 4f40b8304d54
parent 3011 1997ff6e7e55
child 3029 c7be0be50898
permissions -rw-r--r--
Added InvalidChange

"
 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:#ChangeSetDiffEntry
	instanceVariableNames:'versionBase versionA versionB versionMerged'
	classVariableNames:''
	poolDictionaries:''
	category:'System-Changes-Diff'
!

!ChangeSetDiffEntry 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.

"
! !

!ChangeSetDiffEntry class methodsFor:'instance creation'!

versionA:versionA 

    ^self new
        versionA: versionA;
        versionB: versionA asAntiChange

    "Modified: / 24-11-2009 / 12:30:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

versionA:versionA versionB:versionB 

    ^self new
        versionA: versionA;
        versionB: versionB.
!

versionB:versionB 

    ^self new
        versionA: versionB asAntiChange;
        versionB: versionB.

    "Modified: / 24-11-2009 / 12:30:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!ChangeSetDiffEntry class methodsFor:'image specs'!

iconMinus
    ^ ToolbarIconLibrary iconMinus12x12

    "Modified: / 31-08-2011 / 10:51:21 / cg"
!

iconPlus
    ^ ToolbarIconLibrary iconPlus12x12

    "Modified: / 31-08-2011 / 10:51:34 / cg"
! !

!ChangeSetDiffEntry methodsFor:'accessing'!

changeClass

    ^(versionA ? versionB) changeClass

    "Created: / 30-11-2011 / 11:35:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

changeSelector

    | chg |

    (chg := versionA ? versionB) isMethodChange ifTrue:[
        ^chg changeSelector            
    ] ifFalse:[
        ^nil
    ]

    "Created: / 30-11-2011 / 11:40:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

className

    ^(versionA ? versionB) className

    "Created: / 01-11-2009 / 16:48:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

merged
    ^ versionMerged notNil

    "Modified: / 24-11-2009 / 12:55:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

mergedUsingVersionA

    versionMerged ifNil:[^false].
    versionA ifNil:[^false].

    ^versionA sameAs: versionMerged

    "Created: / 24-11-2009 / 08:16:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

mergedUsingVersionB

    versionMerged ifNil:[^false].
    versionB ifNil:[^false].

    ^versionB sameAs: versionMerged

    "Created: / 24-11-2009 / 08:16:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

mergedUsingVersionBase

    versionMerged ifNil:[^false].
    versionBase ifNil:[^false].

    ^versionBase sameAs: versionMerged

    "Created: / 24-11-2009 / 08:16:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

name

    ^self versionAorB displayString

    "Created: / 24-11-2009 / 09:56:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

nonMetaClassName

    ^(versionA ? versionB) nonMetaClassName

    "Created: / 21-11-2009 / 07:42:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

versionA
    ^ versionA
!

versionA:something
    versionA := something.
!

versionALabel
    ^ parent versionALabel

    "Created: / 09-11-2009 / 12:38:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

versionAText
    ^ versionA source

    "Created: / 06-07-2011 / 12:29:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

versionAorB

    ^versionA isClassRemoveChangeOrMethodRemoveChange
        ifFalse:[versionA]
        ifTrue:[versionB]

    "Created: / 02-11-2009 / 18:48:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

versionB
    ^ versionB
!

versionB:something
    versionB := something.
!

versionBLabel
    ^ parent versionBLabel

    "Created: / 09-11-2009 / 12:38:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

versionBText
    ^ versionB source

    "Created: / 06-07-2011 / 12:29:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

versionBase
    ^ versionBase
!

versionBase:something
    versionBase := something.
!

versionBaseLabel
    ^ parent versionBaseLabel

    "Created: / 23-11-2009 / 22:55:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

versionMerged
    ^ versionMerged
!

versionMerged:aChange
    versionMerged := aChange.
    self changed:#resolution with: aChange

    "Modified: / 24-11-2009 / 12:58:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

versionMergedLabel

    (versionMerged isNil)
        ifTrue:[^'<unresolved>' asText colorizeAllWith: Color red].
    (versionMerged sameAs: versionA)
        ifTrue:[^self versionALabel].
    (versionMerged sameAs: versionB)
        ifTrue:[^self versionBLabel].
    (versionMerged sameAs: versionBase)
        ifTrue:[^self versionBaseLabel].
    ^'manual merge'
! !

!ChangeSetDiffEntry methodsFor:'enumerating'!

do: aBlock

    aBlock value: self

    "Created: / 25-11-2009 / 10:22:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!ChangeSetDiffEntry methodsFor:'merging'!

automerge

    "Try to automatically merge differences. The merge is based
     on versionBase. If any of versions is same as versionBase, 
     the other is used as merge result"

    versionBase ifNil:[^self].

    (versionA sameAs: versionBase) ifTrue:[versionMerged := versionB copy].
    (versionB sameAs: versionBase) ifTrue:[versionMerged := versionA copy].

    "Created: / 02-11-2009 / 18:51:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 25-11-2009 / 08:21:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!ChangeSetDiffEntry methodsFor:'testing'!

isDiffItem
    ^ true
! !

!ChangeSetDiffEntry class methodsFor:'documentation'!

version_CVS
    ^ '§Header: /cvs/stx/stx/libbasic3/ChangeSetDiffEntry.st,v 1.3 2011/11/30 18:52:51 vrany Exp §'
!

version_SVN
    ^ '$Id: ChangeSetDiffEntry.st 1872 2012-01-30 17:19:14Z vranyj1 $'
! !