VersionDiffBrowser.st
author penk
Fri, 25 Oct 2002 13:11:24 +0200
changeset 4057 73bc66a13c39
parent 3853 f3ce00da9b68
child 4128 540bf0752f89
permissions -rw-r--r--
checkin from browser

"
 COPYRIGHT (c) 2000 by eXept Software AG
              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:libtool' }"

ApplicationModel subclass:#VersionDiffBrowser
	instanceVariableNames:'classChangeSet diffTextView boxAVisible boxBVisible boxMVisible
		classIfSingleClassDiff versionAIfSingleClassDiff
		versionBIfSingleClassDiff changedLabelHolder diffTextLabelA
		diffTextLabelB methodText methodsChanged methodsChangedSelection
		methodsOnlyInA methodsOnlyInASelection methodsOnlyInB
		methodsOnlyInBSelection onlyInALabelHolder onlyInBLabelHolder'
	classVariableNames:''
	poolDictionaries:''
	category:'Interface-Browsers'
!

HierarchicalItem subclass:#ClassChangeSet
	instanceVariableNames:'classBeingCompared labelA labelB diffSet onlyInA onlyInB
		changedMethods versionA versionB'
	classVariableNames:''
	poolDictionaries:''
	privateIn:VersionDiffBrowser
!

!VersionDiffBrowser class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2000 by eXept Software AG
              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.
"

!

documentation
"
    This is not yet finished (work in progress).

    A browser to show differences between class versions,
    allowing easy comparison; will also eventually add capabilities
    to checkIn / load classes into / from the repository.

    [see also:]

    [instance variables:]

    [class variables:]
"


! !

!VersionDiffBrowser class methodsFor:'interface specs'!

windowSpec
    "This resource specification was automatically generated
     by the UIPainter of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the UIPainter may not be able to read the specification."

    "
     UIPainter new openOnClass:VersionDiffBrowser andSelector:#windowSpec
     VersionDiffBrowser new openInterface:#windowSpec
     VersionDiffBrowser open
    "

    <resource: #canvas>

    ^ 
     #(#FullSpec
        #name: #windowSpec
        #window: 
       #(#WindowSpec
          #label: 'Version DiffBrowser'
          #name: 'Version DiffBrowser'
          #min: #(#Point 10 10)
          #max: #(#Point nil nil)
          #bounds: #(#Rectangle 157 154 1022 658)
          #menu: #mainMenu
        )
        #component: 
       #(#SpecCollection
          #collection: #(
           #(#VariableVerticalPanelSpec
              #name: 'VariableVerticalPanel1'
              #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
              #component: 
             #(#SpecCollection
                #collection: #(
                 #(#HorizontalPanelViewSpec
                    #name: 'TopHorizontalPanel'
                    #horizontalLayout: #fit
                    #verticalLayout: #fit
                    #horizontalSpace: 3
                    #verticalSpace: 3
                    #component: 
                   #(#SpecCollection
                      #collection: #(
                       #(#ViewSpec
                          #name: 'BoxA'
                          #level: 0
                          #visibilityChannel: #boxAVisible
                          #component: 
                         #(#SpecCollection
                            #collection: #(
                             #(#LabelSpec
                                #label: 'Only in A'
                                #name: 'OnlyInALabel'
                                #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 20 0)
                                #translateLabel: true
                                #labelChannel: #onlyInALabelHolder
                              )
                             #(#SequenceViewSpec
                                #name: 'ListA'
                                #layout: #(#LayoutFrame 0 0.0 20 0.0 0 1.0 -3 1.0)
                                #model: #methodsOnlyInASelection
                                #menu: #menuA
                                #hasHorizontalScrollBar: true
                                #hasVerticalScrollBar: true
                                #miniScrollerHorizontal: true
                                #valueChangeSelector: #methodsOnlyInASelectionChanged
                                #useIndex: true
                                #sequenceList: #methodsOnlyInA
                              )
                             )
                           
                          )
                          #extent: #(#Point 286 252)
                        )
                       #(#ViewSpec
                          #name: 'BoxM'
                          #visibilityChannel: #boxMVisible
                          #component: 
                         #(#SpecCollection
                            #collection: #(
                             #(#LabelSpec
                                #label: 'Changed'
                                #name: 'Label2'
                                #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 20 0)
                                #translateLabel: true
                                #labelChannel: #changedLabelHolder
                              )
                             #(#SequenceViewSpec
                                #name: 'ListM'
                                #layout: #(#LayoutFrame 0 0.0 20 0.0 0 1.0 -3 1.0)
                                #model: #methodsChangedSelection
                                #menu: #menuM
                                #hasHorizontalScrollBar: true
                                #hasVerticalScrollBar: true
                                #miniScrollerHorizontal: true
                                #valueChangeSelector: #methodsChangedSelectionChanged
                                #useIndex: true
                                #sequenceList: #methodsChanged
                              )
                             )
                           
                          )
                          #extent: #(#Point 286 252)
                        )
                       #(#ViewSpec
                          #name: 'BoxB'
                          #visibilityChannel: #boxBVisible
                          #component: 
                         #(#SpecCollection
                            #collection: #(
                             #(#LabelSpec
                                #label: 'Only in B'
                                #name: 'OnlyInBLabel'
                                #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 20 0)
                                #translateLabel: true
                                #labelChannel: #onlyInBLabelHolder
                              )
                             #(#SequenceViewSpec
                                #name: 'ListB'
                                #layout: #(#LayoutFrame 0 0.0 20 0.0 0 1.0 -3 1.0)
                                #model: #methodsOnlyInBSelection
                                #menu: #menuB
                                #hasHorizontalScrollBar: true
                                #hasVerticalScrollBar: true
                                #miniScrollerHorizontal: true
                                #valueChangeSelector: #methodsOnlyInBSelectionChanged
                                #useIndex: true
                                #sequenceList: #methodsOnlyInB
                              )
                             )
                           
                          )
                          #extent: #(#Point 287 252)
                        )
                       )
                     
                    )
                  )
                 #(#ViewSpec
                    #name: 'Box4'
                    #component: 
                   #(#SpecCollection
                      #collection: #(
                       #(#ViewSpec
                          #name: 'diffTextViewBox'
                          #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
                          #initiallyInvisible: true
                          #component: 
                         #(#SpecCollection
                            #collection: #(
                             #(#LabelSpec
                                #label: 'A'
                                #name: 'DiffTextLabelA'
                                #layout: #(#LayoutFrame 0 0 0 0 0 0.5 20 0)
                                #translateLabel: true
                                #labelChannel: #diffTextLabelA
                              )
                             #(#LabelSpec
                                #label: 'B'
                                #name: 'DiffTextLabelB'
                                #layout: #(#LayoutFrame 0 0.5 0 0 0 1 20 0)
                                #translateLabel: true
                                #labelChannel: #diffTextLabelB
                              )
                             #(#ArbitraryComponentSpec
                                #name: 'diffTextView'
                                #layout: #(#LayoutFrame 0 0.0 20 0.0 0 1.0 0 1.0)
                                #hasBorder: false
                                #component: #diffTextView
                              )
                             )
                           
                          )
                        )
                       #(#TextEditorSpec
                          #name: 'singleTextView'
                          #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
                          #model: #methodText
                          #hasHorizontalScrollBar: true
                          #hasVerticalScrollBar: true
                          #miniScrollerHorizontal: true
                          #isReadOnly: true
                        )
                       )
                     
                    )
                  )
                 )
               
              )
              #handles: #(#Any 0.5 1.0)
            )
           )
         
        )
      )
! !

!VersionDiffBrowser class methodsFor:'menu specs'!

mainMenu
    "This resource specification was automatically generated
     by the MenuEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the MenuEditor may not be able to read the specification."

    "
     MenuEditor new openOnClass:VersionDiffBrowser andSelector:#mainMenu
     (Menu new fromLiteralArrayEncoding:(VersionDiffBrowser mainMenu)) startUp
    "

    <resource: #menu>

    ^ 
     #(#Menu
        #(
         #(#MenuItem
            #label: 'File'
            #translateLabel: true
            #submenu: 
           #(#Menu
              #(
               #(#MenuItem
                  #label: 'Create PatchFile...'
                  #translateLabel: true
                  #value: #createPatchFile
                )
               #(#MenuItem
                  #label: '-'
                )
               #(#MenuItem
                  #label: 'Exit'
                  #translateLabel: true
                  #value: #closeRequest
                )
               )
              nil
              nil
            )
          )
         #(#MenuItem
            #label: 'Help'
            #translateLabel: true
            #startGroup: #right
            #submenu: 
           #(#Menu
              #(
               #(#MenuItem
                  #label: 'Documentation'
                  #translateLabel: true
                  #value: #openDocumentation
                )
               #(#MenuItem
                  #label: '-'
                )
               #(#MenuItem
                  #label: 'About this Application'
                  #translateLabel: true
                  #value: #openAboutThisApplication
                )
               )
              nil
              nil
            )
          )
         )
        nil
        nil
      )
!

menuA
    "This resource specification was automatically generated
     by the MenuEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the MenuEditor may not be able to read the specification."

    "
     MenuEditor new openOnClass:VersionDiffBrowser andSelector:#menu1
     (Menu new fromLiteralArrayEncoding:(VersionDiffBrowser menu1)) startUp
    "

    <resource: #menu>

    ^ 
     #(#Menu
        #(
         #(#MenuItem
            #label: 'Apply'
            #translateLabel: true
            #value: #applySelectedChangeInA
            #enabled: #hasChangeSelectedInA
          )
         #(#MenuItem
            #label: 'Browse'
            #translateLabel: true
            #value: #browseClassInA
            #enabled: #hasChangeSelectedInA
          )
         #(#MenuItem
            #label: '-'
          )
         #(#MenuItem
            #label: 'Inspect'
            #translateLabel: true
            #value: #inspectSelectedChangeInA
            #choiceValue: 'nil "UndefinedObject" '
            #enabled: #hasChangeSelectedInA
          )
         )
        nil
        nil
      )
!

menuB
    "This resource specification was automatically generated
     by the MenuEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the MenuEditor may not be able to read the specification."

    "
     MenuEditor new openOnClass:VersionDiffBrowser andSelector:#menuB
     (Menu new fromLiteralArrayEncoding:(VersionDiffBrowser menuB)) startUp
    "

    <resource: #menu>

    ^ 
     #(#Menu
        #(
         #(#MenuItem
            #label: 'Apply'
            #translateLabel: true
            #value: #applySelectedChangeInB
            #enabled: #hasChangeSelectedInB
          )
         #(#MenuItem
            #label: 'Browse'
            #translateLabel: true
            #value: #browseClassInB
            #enabled: #hasChangeSelectedInB
          )
         #(#MenuItem
            #label: '-'
          )
         #(#MenuItem
            #label: 'Inspect'
            #translateLabel: true
            #value: #inspectSelectedChangeInB
            #choiceValue: 'nil "UndefinedObject" '
            #enabled: #hasChangeSelectedInA
          )
         )
        nil
        nil
      )
!

menuM
    "This resource specification was automatically generated
     by the MenuEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the MenuEditor may not be able to read the specification."

    "
     MenuEditor new openOnClass:VersionDiffBrowser andSelector:#menu1
     (Menu new fromLiteralArrayEncoding:(VersionDiffBrowser menu1)) startUp
    "

    <resource: #menu>

    ^ 
     #(#Menu
        #(
         #(#MenuItem
            #label: 'Browse'
            #translateLabel: true
            #value: #browseClassInM
            #enabled: #hasChangeSelectedInM
          )
         #(#MenuItem
            #label: '-'
          )
         #(#MenuItem
            #label: 'Inspect both'
            #translateLabel: true
            #value: #inspectSelectedChangeInM
            #choiceValue: 'nil "UndefinedObject" '
            #enabled: #hasChangeSelectedInM
          )
         )
        nil
        nil
      )
! !

!VersionDiffBrowser class methodsFor:'plugIn spec'!

aspectSelectors
    "This resource specification was automatically generated
     by the UIPainter of ST/X."

    "Do not manually edit this. If it is corrupted,
     the UIPainter may not be able to read the specification."

    "Return a description of exported aspects;
     these can be connected to aspects of an embedding application
     (if this app is embedded in a subCanvas)."

    ^ #(
        #changedLabelHolder
        #onlyInALabelHolder
        #onlyInBLabelHolder
      ).

! !

!VersionDiffBrowser class methodsFor:'startup'!

openOnClass:aClass againstVersion:aVersionA 
    "
    create an VersionDiffBrowser instance and set the class change set of the
    browser. The class diff set is generated from classes current against some version
    via the source code manager .

    <return: VersionDiffBrowser>
    "
    |theBrowser|

    theBrowser := self new.
    theBrowser allButOpen.
    theBrowser setupForClass:aClass againstVersion:aVersionA.
    theBrowser openWindow.
    ^ theBrowser.

    "
     self openOnClass:Array againstVersion:'1.116'
     self openOnClass:Array againstVersion:nil            - against the version on which Array is based upon
     self openOnClass:Array againstVersion:#newest        - against the newest repository version

     self openOnClass:VersionDiffBrowser againstVersion:nil
     self openOnClass:VersionDiffBrowser againstVersion:#newest
    "
!

openOnClass:classA labelA:aLabelA andClass:classB labelB:aLabelB title:ignoredTitle 
    "
    create an VersionDiffBrowser instance and set the class change set of the
    browser. The class diff set is generated from two classes.

    <return: VersionDiffBrowser>
    "
    ^ self
        openOnClass:classA labelA:aLabelA andClass:classB labelB:aLabelB title:ignoredTitle ifSame:nil
!

openOnClass:classA labelA:aLabelA andClass:classB labelB:aLabelB title:ignoredTitle ifSame:sameAction
    "
    create an VersionDiffBrowser instance and set the class change set of the
    browser. The class diff set is generated from two classes.

    <return: VersionDiffBrowser>
    "
    |theBrowser|

    theBrowser := self new.
    theBrowser allButOpen.
    theBrowser setupForClass:classA labelA:aLabelA andClass:classB labelB:aLabelB.

    sameAction notNil ifTrue:[
        "/ check if same ...
        (theBrowser classChangeSet methodsOnlyInA isEmpty
        and:[theBrowser classChangeSet methodsOnlyInB isEmpty
        and:[theBrowser classChangeSet diffSet isEmpty]]) ifTrue:[
            sameAction value.
            ^ self "/ do not open
        ]
    ].
    theBrowser openWindow.
    ^ theBrowser.
!

openOnClass:aClass labelA:aLabelA sourceA:aSourceA labelB:aLabelB sourceB:aSourceB 
    "
    create an VersionDiffBrowser instance and set the class change set of the
    browser. The class diff set is generated from two source files.

    <return: VersionDiffBrowser>
    "
    ^ self
        openOnClass:aClass labelA:aLabelA sourceA:aSourceA labelB:aLabelB sourceB:aSourceB 
        title:nil
!

openOnClass:aClass labelA:aLabelA sourceA:aSourceA labelB:aLabelB sourceB:aSourceB title:ignoredTitle
    "
    create an VersionDiffBrowser instance and set the class change set of the
    browser. The class diff set is generated from two source files.

    <return: VersionDiffBrowser>
    "
    ^ self openOnClass:aClass labelA:aLabelA sourceA:aSourceA labelB:aLabelB sourceB:aSourceB title:ignoredTitle ifSame:nil
!

openOnClass:aClass labelA:aLabelA sourceA:aSourceA labelB:aLabelB sourceB:aSourceB title:ignoredTitle ifSame:sameAction
    "
    create an VersionDiffBrowser instance and set the class change set of the
    browser. The class diff set is generated from two source files.

    <return: VersionDiffBrowser>
    "
    |theBrowser diffs theOnlyDifference theOnlyChange noChangedMethods|

    theBrowser := self new.
    theBrowser allButOpen.
    theBrowser setupForClass:aClass labelA:aLabelA sourceA:aSourceA labelB:aLabelB sourceB:aSourceB.
    sameAction notNil ifTrue:[
        "/ check if same ...
        (theBrowser classChangeSet methodsOnlyInA isEmpty
        and:[theBrowser classChangeSet methodsOnlyInB isEmpty]) ifTrue:[
            diffs := theBrowser classChangeSet diffSet.

            noChangedMethods := diffs changed isEmpty.
            noChangedMethods ifFalse:[
                diffs changed size == 1 ifTrue:[
                    theOnlyDifference := diffs changed first.
                    theOnlyChange := theOnlyDifference first.
                    (theOnlyChange isMethodChange 
                    and:[ (theOnlyChange selector == #version) 
                    and:[ theOnlyChange changeClass isMeta ]]) ifTrue:[
                        noChangedMethods := true
                    ]
                ]
            ].

            (noChangedMethods
            and:[diffs onlyInArg isEmpty
            and:[diffs onlyInReceiver isEmpty]]) ifTrue:[
                sameAction value.
                ^ self "/ do not open
            ].
        ]
    ].
    theBrowser openWindow.
    ^ theBrowser.
!

openOnClass:aClass versionA:aVersionA versionB:aVersionB
    "
    create an VersionDiffBrowser instance and set the class change set of the
    browser. The class diff set is generated from two class versions via
    the source code manager .

    <return: VersionDiffBrowser>
    "
    |theBrowser|

    theBrowser := self new.
    theBrowser allButOpen.
    theBrowser setupForClass:aClass versionA:aVersionA versionB:aVersionB.
    theBrowser openWindow.
    ^ theBrowser.

    "
     self openOnClass:Array versionA:'1.116' versionB:'1.113'
    "
!

openOnDiffSet:diffSet labelA:aLabelA labelB:aLabelB title:ignoredTitle
    |theBrowser|

    theBrowser := self new.
    theBrowser allButOpen.
    theBrowser setupForDiffSet:diffSet labelA:aLabelA labelB:aLabelB.
    theBrowser window label:ignoredTitle.
    theBrowser openWindow.
    ^ theBrowser.
! !

!VersionDiffBrowser methodsFor:'accessing'!

changeSetA
    "
    gets the change set which contains only the new methods
    in versionA of the class

    <return: ChangeSet>
    "

    ^ self classChangeSet methodsOnlyInA
!

changeSetB
    "
    gets the change set which contains only the new methods
    in versionB of the class

    <return: ChangeSet>
    "

    ^ self classChangeSet methodsOnlyInB
!

class:aClass versionA:revA versionB:revB
    classIfSingleClassDiff := aClass.
    versionAIfSingleClassDiff := revA.
    versionBIfSingleClassDiff := revB.
!

classBeingCompared
    "
    gets the class from the change set which is compared.

    <return: Class>
    " 
    ^ self classChangeSet classBeingCompared
!

classChangeSet
    "
    returns the class change set which is the model of the version diff browser.

    <return: ClassChangeSet> 
    " 
    ^ classChangeSet
!

classChangeSet:aClassChangeSet
    "
    sets the class change set which is the model of the version diff browser.
    The labels, the lists, the visibility and the selection of the lists must be reseted
    when a new change set is given.

    <return: self>
    " 
    classChangeSet := aClassChangeSet.
    self updateLabels.
    self updateLists.
    self resetSelectionHolders.
!

selectedChangeInA
    "
    gets the selected method change for the 'method only in version A'.

    <return: MethodChange | nil>
    "
    |sel change|

    sel := self methodsOnlyInASelection value.
    sel notNil ifTrue:[
        change := self changeSetA at:sel.
    ].
    ^ change
!

selectedChangeInB
    "
    gets the selected method change for the 'method only in version B'.

    <return: MethodChange | nil>
    "
    |sel change|

    sel := self methodsOnlyInBSelection value.
    sel notNil ifTrue:[
        change := (self changeSetB at:sel).
    ].
    ^ change
!

selectedChangesInM
    "
    get the two method changes for the selected 'changed method'.

    <return: <Array with:MethodChange with:MethodChange | nil>>
    "
    |sel changeA changeB theTwoChanges|

    sel := self methodsChangedSelection value.
    sel notNil ifTrue:[
        theTwoChanges := self classChangeSet methodsChanged at:sel.
"/        changeA := theTwoChanges first.
"/        changeB := theTwoChanges second.
"/        ^ Array with:changeA with:changeB.
        ^ theTwoChanges.
    ].
    ^ #(nil nil)
!

versionA
    "
    gets the first class version to be compared

    <return: String>
    "
    classChangeSet isNil ifTrue:[^ 'A'].
    ^ classChangeSet labelA
!

versionB
    "
    gets the second class version to be compared

    <return: String>
    "
    classChangeSet isNil ifTrue:[^ 'B'].
    ^ classChangeSet labelB
! !

!VersionDiffBrowser methodsFor:'actions'!

methodsChangedSelectionChanged
    "
    the selection in the list of the 'changed methods' changed.
    Reset the selection of the two other lists and calc the method change.

    <return: self>
    "
    |sel idxA idxB changeA changeB methodsChanged|

    sel := self methodsChangedSelection value.
    sel notNil ifTrue:[
        self methodsOnlyInASelection value:nil.
        self methodsOnlyInBSelection value:nil.
        methodsChanged := self classChangeSet methodsChanged.
        changeA := (methodsChanged at:sel) first.
        changeB := (methodsChanged at:sel) second.
        self withReadCursorDo:[
            self diffTextView text1:changeA prettyPrintedSource text2:changeB prettyPrintedSource.
            self diffTextView moveToNextChanged
        ].
        self showDiffTextView.
    ]

    "Modified: / 3.9.1999 / 15:01:30 / ps"
!

methodsOnlyInASelectionChanged
    "
    the selection in the list of the 'method only in version A' changed.
    Reset the selection of the two other lists and show the method in
    the text view.

    <return: self>
    "
    |change sel|

    sel := self methodsOnlyInASelection value.
    sel notNil ifTrue:[
        self methodsOnlyInBSelection value:nil.
        self methodsChangedSelection value:nil.
        change := self changeSetA at:sel.
        self methodText value:(change prettyPrintedSource).    
        self showSingleTextView.
    ]
!

methodsOnlyInBSelectionChanged
    "
    the selection in the list of the 'method only in version B' changed.
    Reset the selection of the two other lists and show the method in
    the text view.

    <return: self>
    "
    |change sel|

    sel := self methodsOnlyInBSelection value.
    sel notNil ifTrue:[
        self methodsOnlyInASelection value:nil.
        self methodsChangedSelection value:nil.
        change := self changeSetB at:sel.
        self methodText value:(change prettyPrintedSource).    
        self showSingleTextView.
    ]
! !

!VersionDiffBrowser methodsFor:'aspects'!

boxAVisible
    boxAVisible isNil ifTrue:[
        boxAVisible := true asValue.
    ].
    ^ boxAVisible.
!

boxBVisible
    boxBVisible isNil ifTrue:[
        boxBVisible := true asValue.
    ].
    ^ boxBVisible.
!

boxMVisible
    boxMVisible isNil ifTrue:[
        boxMVisible := true asValue.
    ].
    ^ boxMVisible.
!

changedLabelHolder
    "
    aspect for the label of the changed method box.

    <return: ValueHolder on: nil>
    "

    changedLabelHolder isNil ifTrue:[
        changedLabelHolder := ValueHolder new.
    ].
    ^ changedLabelHolder.
!

diffTextLabelA
    "
    aspect for the label for version A.

    <return: ValueHolder on: nil>
    "

    diffTextLabelA isNil ifTrue:[
        diffTextLabelA := ValueHolder new.
    ].
    ^ diffTextLabelA.
!

diffTextLabelB
    "
    aspect for the label for version B.

    <return: ValueHolder on: nil>
    "

    diffTextLabelB isNil ifTrue:[
        diffTextLabelB := ValueHolder new.
    ].
    ^ diffTextLabelB.
!

diffTextView
    "
    return the component for the diff text view.

    <return: HVScrollableView>
    "
    diffTextView isNil ifTrue:[
        diffTextView := HVScrollableView
                           for:DiffTextView
                           miniScrollerH:true miniScrollerV:false.
        diffTextView addNextPreviousButtons.
    ].
    ^ diffTextView
!

methodText
    "
    aspect for the text in the method text view.

    <return: ValueHolder on: nil>
    "

    methodText isNil ifTrue:[
        methodText := ValueHolder new.
    ].
    ^ methodText.
!

methodsChanged
    "
    aspect for the 'changed method' list.

    <return: List>
    "

    methodsChanged isNil ifTrue:[
        methodsChanged := List new.
    ].
    ^ methodsChanged.
!

methodsChangedSelection
    "
    aspect for the selection holder of 'changed method'-list.

    <return: ValueHolder on: nil>
    "

    methodsChangedSelection isNil ifTrue:[
        methodsChangedSelection := ValueHolder new.
    ].
    ^ methodsChangedSelection.
!

methodsOnlyInA
    "
    aspect for the 'method only in version A' list.

    <return: List>
    "

    methodsOnlyInA isNil ifTrue:[
        methodsOnlyInA := List new.
    ].
    ^ methodsOnlyInA.
!

methodsOnlyInASelection
    "
    aspect for the selection holder of 'method only in version A'-list.

    <return: ValueHolder on: nil>
    "

    methodsOnlyInASelection isNil ifTrue:[
        methodsOnlyInASelection := ValueHolder new.
    ].
    ^ methodsOnlyInASelection.
!

methodsOnlyInB
    "
    aspect for the 'method only in version B' list.

    <return: List>
    "

    methodsOnlyInB isNil ifTrue:[
        methodsOnlyInB := List new.
    ].
    ^ methodsOnlyInB.
!

methodsOnlyInBSelection
    "
    aspect for the selection holder of 'method only in version B'-list.

    <return: ValueHolder on: nil>
    "

    methodsOnlyInBSelection isNil ifTrue:[
        methodsOnlyInBSelection := ValueHolder new.
    ].
    ^ methodsOnlyInBSelection.
!

onlyInALabelHolder
    "
    aspect for the label for 'method only in version A'.

    <return: ValueHolder on: nil>
    "

    onlyInALabelHolder isNil ifTrue:[
        onlyInALabelHolder := ValueHolder new.
    ].
    ^ onlyInALabelHolder.
!

onlyInBLabelHolder
    "
    aspect for the label for 'method only in version B'.

    <return: ValueHolder on: nil>
    "

    onlyInBLabelHolder isNil ifTrue:[
        onlyInBLabelHolder := ValueHolder new.
    ].
    ^ onlyInBLabelHolder.
! !

!VersionDiffBrowser methodsFor:'aspects - menu'!

canAcceptInCodeView
    ^ self hasChangeSelectedInA
      or:[self hasChangeSelectedInB
      or:[self hasChangeSelectedInM]]
!

hasChangeSelectedInA
    ^ self selectedChangeInA notNil
!

hasChangeSelectedInB
    ^ self selectedChangeInB notNil
!

hasChangeSelectedInM
    ^ self methodsChangedSelection value notNil
! !

!VersionDiffBrowser methodsFor:'aspects-exported'!

changedLabelHolder:aValueHolder
    builder aspectAt:#changedLabelHolder put:aValueHolder.

!

classHolder:aValueHolder
    |holder|

    (holder := builder bindingAt:#classHolder) notNil ifTrue:[
        holder removeDependent:self
    ].
    builder aspectAt:#classHolder put:aValueHolder.
    aValueHolder notNil ifTrue:[
        aValueHolder addDependent:self
    ]
!

onlyInALabelHolder:aValueHolder
    builder aspectAt:#onlyInALabelHolder put:aValueHolder.
!

onlyInBLabelHolder:aValueHolder
    builder aspectAt:#onlyInBLabelHolder put:aValueHolder.
!

versionAHolder:aValueHolder
    |holder|

    (holder := builder bindingAt:#versionAHolder) notNil ifTrue:[
        holder removeDependent:self
    ].
    builder aspectAt:#versionAHolder put:aValueHolder.
    aValueHolder notNil ifTrue:[
        aValueHolder addDependent:self
    ]
!

versionBHolder:aValueHolder
    |holder|

    (holder := builder bindingAt:#versionBHolder) notNil ifTrue:[
        holder removeDependent:self
    ].
    builder aspectAt:#versionBHolder put:aValueHolder.
    aValueHolder notNil ifTrue:[
        aValueHolder addDependent:self
    ]
! !

!VersionDiffBrowser methodsFor:'change & update'!

update:something with:parameter from:changedObject
    |classHolder versionAHolder versionBHolder|

    classHolder := self classHolder.
    versionAHolder := self versionAHolder.
    versionBHolder := self versionBHolder.

    (changedObject == classHolder 
    or:[changedObject == versionAHolder
    or:[changedObject == versionBHolder]]) ifTrue:[
        self setupForClass:(classHolder value) versionA:(versionAHolder value) versionB:(versionBHolder value)
.        ^ self
    ].
    super update:something with:parameter from:changedObject
! !

!VersionDiffBrowser methodsFor:'initialization & release'!

postBuildWith:aBuilder
    "
    components which are invisible should be ignored by the panel.
    Cannot be set via the interface builder.

    <return: self>
    "

    (self componentAt:#TopHorizontalPanel) ignoreInvisibleComponents:true.
    ^ super postBuildWith:aBuilder
! !

!VersionDiffBrowser methodsFor:'menu action'!

applySelectedChangeInA
    self applyChange:(self selectedChangeInA) 
!

applySelectedChangeInB
    self applyChange:(self selectedChangeInB) 
!

browseChange:aChange
    "
    browse the change in aChange 

    <return: self>
    "
    |cls sel m|

    aChange isNil ifTrue:[^ self].
    cls := aChange changeClass.
    sel := aChange changeSelector.
    (cls compiledMethodAt:sel) isNil ifTrue:[
        self information:'Method does not exist.'
    ].

    UserPreferences systemBrowserClass openInClass:cls selector:sel.
!

browseClassInA
    "
    browse the selected method.

    <return: self>
    "
    self browseChange:(self selectedChangeInA).
!

browseClassInB
    "
    browse the selected method.

    <return: self>
    "
    self browseChange:(self selectedChangeInB).
!

browseClassInM
    "
    browse the selected method.

    <return: self>
    "
    self browseChange:(self selectedChangesInM first).
!

createPatchFile
    "create a patchFile, to patch the old version (versionB) into the new version (versionA).
     I.e. a little changeFile to transport those changes."

    |defaultName f oldVersion newVersion vsnMthdA vsnMthdB vsnA vsnB info|

    defaultName := 'patchFile.chg'.

    classChangeSet classBeingCompared notNil ifTrue:[
        defaultName := classChangeSet classBeingCompared nameWithoutPrefix.
        classChangeSet versionA notNil ifTrue:[
            defaultName := defaultName , '-'.
            defaultName := defaultName , classChangeSet versionA.
            classChangeSet versionB notNil ifTrue:[
                defaultName := defaultName , '-'.
                defaultName := defaultName , classChangeSet versionB.
            ].
        ].
        defaultName := defaultName , '.chg'.
    ].
    f := Dialog 
            requestFileName:'Name of patchFile:'
            default:defaultName.
self warn:'Sorry: This function is not yet implemented'.
^ self.

"/    vsnMthdA := self changeSetA 
"/                detect:[:ch | ch isMethodChange
"/                              and:[ch changeClass isMeta
"/                              and:[ch changeSelector = #version]]]
"/                ifNone:nil.
"/    vsnMthdB := self changeSetA 
"/                detect:[:ch | ch isMethodChange
"/                              and:[ch changeClass isMeta
"/                              and:[ch changeSelector = #version]]]
"/                ifNone:nil.
"/
"/    vsnMthdA notNil ifTrue:[
"/        "/ extract the version        
"/        vsnA := Class revisionStringFromSource:vsnMthdA source.
"/        vsnA notNil ifTrue:[
"/            info := Class revisionInfoFromString:vsnA.
"/            info notNil ifTrue:[
"/                vsnA := info at:#revision ifAbsent:nil.
"/            ] ifFalse:[
"/                vsnA := nil.
"/            ].
"/        ].
"/    ].
"/    vsnMthdB notNil ifTrue:[
"/        "/ extract the version        
"/        vsnB := Class revisionStringFromSource:vsnMthdB source.
"/        vsnB notNil ifTrue:[
"/            info := Class revisionInfoFromString:vsnB.
"/            info notNil ifTrue:[
"/                vsnB := info at:#revision ifAbsent:nil.
"/            ] ifFalse:[
"/                vsnB := nil.
"/            ].
"/        ].
"/    ].
"/
"/    (vsnA isNil or:[vsnB isNil or:[vsnA = vsnB]]) ifTrue:[
"/        self warn:'The generated patch file will not be able to validate/update the class version'.
"/    ].
"/
"/self halt:'not yet finished'.
!

inspectSelectedChangeInA
    "
    inspect the selected method change for the 'method only in version A'.

    <return: self>
    "
    self selectedChangeInA inspect.
!

inspectSelectedChangeInB
    "
    inspect the selected method change for the 'method only in version B'.

    <return: self>
    "
    self selectedChangeInB inspect.
!

inspectSelectedChangeInM
    "
    inspect the two method changes for the selected 'changed method'.

    <return: self>
    "
    |changes|

    changes := self selectedChangesInM.
    changes do:[:change |
        change inspect
    ].
!

mainMenu
    "
    if this application runs as an subapplication,
    the menu bar should not be used.

    <return: self>
    "
    self masterApplication isNil ifTrue:[
        ^ self class mainMenu
    ].
    ^ nil
! !

!VersionDiffBrowser methodsFor:'private'!

acceptInLeftView
    |change|  

    change := self selectedChangesInM first.
    self applyChange:change
!

acceptInRightView
    |change|  

    change := self selectedChangesInM second.
    self applyChange:change
!

acceptInSingleView
    |change|  

    change := self selectedChangeInA.
    change isNil ifTrue:[
        change := self selectedChangeInB
    ].
    self applyChange:change
!

addAcceptToTextViewMenus
    "
    add to the standard diff text view or single text views menu an accept entry.
    The acceptAction will fetch the corresponding change and apply it
    (not the shown text)

    <return: self>
    "

    |m diffTextView leftView rightView singleView|

    diffTextView := self diffTextView.
    leftView := diffTextView leftTextView.
    rightView := diffTextView rightTextView.
    singleView := self componentAt:#singleTextView.

    (Array 
        with:leftView
        with:rightView
        with:singleView)
    do:[:v |
        m := v editMenu.
        (m selectorAt:#accept) isNil ifTrue:[
            m addLabels:(resources array:#('-' 'Accept'))
              selectors:(Array with:nil with:#accept)
              after:#copySelection.
        ].
        m 
            actionAt:#accept 
            put:[
                v == singleView ifTrue:[
                    self acceptInSingleView
                ] ifFalse:[     
                    v == leftView ifTrue:[
                       self acceptInLeftView
                    ] ifFalse:[
                       self acceptInRightView
                    ].
                ].
            ].
        m selectorAt:#accept put:nil.
        m enable:#copySelection.
        m setEnable:#accept to:[self halt. self canAcceptInCodeView].
        v menuHolder:m.
        v menuMessage:#value.
    ]
!

applyChange:change
    change notNil ifTrue:[
        change apply
    ]
!

printStringGenerator
    "
    generate a print string for a change.

    <return: Block>
    "
    ^ [:aChange |
        |result mPkg cPkg cls m changeClassName useChangesString 
         singleComparedClass singleComparedClassesName singleComparedMetaclassesName|

        (singleComparedClass := self classBeingCompared) notNil ifTrue:[
            singleComparedClassesName := singleComparedClass name.
            singleComparedMetaclassesName := singleComparedClass theMetaclass name.
        ].

        aChange isClassDefinitionChange ifTrue:[
            result := aChange printStringWithoutClassName
        ] ifFalse:[
            aChange isDoIt ifTrue:[
                result := aChange source , ' (doIt)'
            ] ifFalse:[
                useChangesString := false.
                changeClassName := aChange className.
                changeClassName = singleComparedClassesName ifTrue:[
                    result := aChange printStringWithoutClassName.
                    useChangesString := true.
                ] ifFalse:[
                    changeClassName = singleComparedMetaclassesName ifTrue:[
                        result := aChange printString.
                        useChangesString := true.
                    ].
                ].
                useChangesString ifTrue:[
                    aChange isMethodCategoryChange ifTrue:[
                        result := result , ' (category)'
                    ] ifFalse:[
                        aChange isMethodChange ifTrue:[
                            cls := aChange changeClass.
                            cls notNil ifTrue:[
                                m := cls compiledMethodAt:aChange selector.
                                (m notNil 
                                and:[m package ~= cls package]) ifTrue:[
                                    result := aChange printStringWithoutClassName , ' [' , m package , ']'.
                                ].
                            ].
                        ]
                    ]
                ] ifFalse:[
                
                    "/ include name in private class changes
                    (singleComparedClassesName notNil
                    and:[changeClassName startsWith:(singleComparedClassesName , '::')]) ifTrue:[
                        result := (changeClassName copyFrom:(singleComparedClassesName size + 3)) , ' ' ,  aChange printStringWithoutClassName
                    ] ifFalse:[
                        result := aChange printString
                    ]
                ]
            ]
        ].
        result
    ].
!

resetSelectionHolders
    "
    reset all selection holders when a new change set is given.
    First set the selection to nil. 

    <return: self>
    "

    self methodsChangedSelection value:nil.
    self methodsOnlyInASelection value:nil.
    self methodsOnlyInBSelection value:nil.
    self diffTextView text1:'' text2:''.
    self methodText value:''.

"/    self methodsChangedSelectionChanged.
"/    self methodsOnlyInASelectionChanged.
"/    self methodsOnlyInBSelectionChanged.
!

showDiffTextView
    "
    if a method change is selected, then show the diff text view.
    Add an accept entry to the popup menu.

    <return: self>
    "

    (self componentAt:#diffTextViewBox) raise; beVisible.
    (self componentAt:#singleTextView) beInvisible.
    (self componentAt:#diffTextView) realizeAllSubViews.

    self addAcceptToTextViewMenus.
!

showSingleTextView
    "
    if a method  is selected which is only in version A or B of the class,
    then show the text view.
    Add an accept entry to the popup menu.

    <return: self>
    "

    (self componentAt:#singleTextView) raise; beVisible.
    (self componentAt:#diffTextViewBox) beInvisible.
    self addAcceptToTextViewMenus.
!

updateLabels
    "
    update the labels of the diff text view. Show the version numbers
    of the class.

    <return: self>
    "

    |theVersionA theVersionB builder|

    builder := self builder.
    (theVersionA := self versionA) notNil ifTrue:[
        self diffTextLabelA value:theVersionA.
        self onlyInALabelHolder value:('Only in ' , theVersionA).
        (self componentAt:#OnlyInALabel) backgroundColor:Color green darkened.
    ].
    (theVersionB :=self versionB) notNil ifTrue:[
        self diffTextLabelB value:theVersionB.
        self onlyInBLabelHolder value:('Only in ' , theVersionB).
        (self componentAt:#OnlyInBLabel) backgroundColor:Color red darkened.
    ].
!

updateLists
    |classChangeSet listOnlyInA listOnlyInB listChanged printStringGenerator sortBlockForChangeLists|

    classChangeSet := self classChangeSet.

    printStringGenerator := self printStringGenerator.
    sortBlockForChangeLists := [:a :b | (printStringGenerator value:a) < (printStringGenerator value:b)].

    listOnlyInA := self methodsOnlyInA. 
    listOnlyInA removeAll.
    classChangeSet notNil ifTrue:[
        classChangeSet methodsOnlyInA sort:sortBlockForChangeLists.
        listOnlyInA addAll: (classChangeSet methodsOnlyInA collect:printStringGenerator).
    ].

    listOnlyInB := self methodsOnlyInB. 
    listOnlyInB removeAll.
    classChangeSet notNil ifTrue:[
        classChangeSet methodsOnlyInB sort:sortBlockForChangeLists.
        listOnlyInB addAll: (classChangeSet methodsOnlyInB collect:printStringGenerator).
    ].

    listChanged := self methodsChanged. 
    listChanged removeAll.
    classChangeSet notNil ifTrue:[
        classChangeSet methodsChanged sort:[:a :b | sortBlockForChangeLists value:a first value:b first].
        listChanged addAll: (classChangeSet methodsChanged collect:[:arr| printStringGenerator value:(arr first)]).
    ].

    self boxAVisible value:(listOnlyInA notEmpty).
    self boxBVisible value:(listOnlyInB notEmpty).

    self boxMVisible value:(listChanged isEmpty 
                            and: [(listOnlyInA notEmpty 
                                  or:[listOnlyInB notEmpty])]) not.
! !

!VersionDiffBrowser methodsFor:'setup'!

setupForClass:aClass againstVersion:aVersionA
    "
    compute the class change set for the class aClass of its current version against the repository version A.
    When setting the class change set, the labels, list etc. of the receiver
    are updated.

    <return: self>
    "
    |changeSet|

    aClass isNil ifTrue:[
        changeSet := nil
    ] ifFalse:[
        aClass isNameSpace ifFalse:[
            aClass isLoaded ifTrue:[
                changeSet := (ClassChangeSet newForClass:aClass againstVersion:aVersionA).
            ]
        ].
    ].
    self classChangeSet:changeSet.
    aVersionA isNil ifTrue:[
        self class:aClass versionA:'rep' versionB:'current'.
    ] ifFalse:[
        self class:aClass versionA:aVersionA versionB:(aVersionA , 'm').
    ]
!

setupForClass:classA labelA:aLabelA andClass:classB labelB:aLabelB
    "
    generate the class change set from the two classes A and B.
    When setting the class change set, the labels, list etc. of the receiver
    are updated.

    <return: self>
    "
    |changeSet|

    changeSet := (ClassChangeSet newForClass:classA labelA:aLabelA andClass:classB labelB:aLabelB).
    self classChangeSet:changeSet
!

setupForClass:aClass labelA:aLabelA sourceA:aSourceA labelB:aLabelB sourceB:aSourceB
    "
    generate the class change set from the two source files A and B.
    When setting the class change set, the labels, list etc. of the receiver
    are updated.

    <return: self>
    "
    |changeSet|

    (aClass isNameSpace not or:[aClass == Smalltalk]) ifTrue:[
        aClass isLoaded ifTrue:[
            changeSet := (ClassChangeSet newForClass:aClass labelA:aLabelA sourceA:aSourceA labelB:aLabelB sourceB:aSourceB).
        ]
    ].
    self classChangeSet:changeSet
!

setupForClass:aClass versionA:aVersionA versionB:aVersionB
    "
    compute the class change set for the class aClass and the versions A and B.
    When setting the class change set, the labels, list etc. of the receiver
    are updated.

    <return: self>
    "
    |changeSet|

    aClass isNameSpace ifFalse:[
        aClass isLoaded ifTrue:[
            changeSet := (ClassChangeSet newForClass:aClass versionA:aVersionA versionB:aVersionB).
        ]
    ].
    self classChangeSet:changeSet.
    self class:aClass versionA:aVersionA versionB:aVersionB.
!

setupForDiffSet:diffSet labelA:aLabelA labelB:aLabelB
    |changeSet|

    changeSet := (ClassChangeSet new diffSet:diffSet; labelA:aLabelA; labelB:aLabelB).
    self classChangeSet:changeSet
! !

!VersionDiffBrowser::ClassChangeSet class methodsFor:'instance creation'!

changeSetForClass:aClass 
    "return a ChangeSet for the class aClass and its current source.
     The source is generated into a stream and then the change set is generated
     from the source stream.

     <return: ChangeSet|nil>
    "

    ^ ChangeSet forExistingClass:aClass.
!

changeSetForClass:aClass andRevision:aVersion
    "return a ChangeSet for the class aClass and version aVersion.
    The version from the class source stream is checked out from the repositiory
    into a source stream. Then the change set is generated from the source stream.

    <return: ChangeSet|nil>
    "

    |theSourceCodeManager theSourceStream theChangeSet|

    theSourceCodeManager := aClass sourceCodeManager.
    [
        theSourceStream := theSourceCodeManager getSourceStreamFor:aClass revision:aVersion.
        theSourceStream notNil
            ifTrue:[theChangeSet := ChangeSet fromStream:theSourceStream]
    ] ensure:[
        theSourceStream notNil ifTrue:[theSourceStream close]
    ].
    ^theChangeSet
!

changeSetForClass:aClass andSource:aSource 
    "return a ChangeSet for the class aClass and source aSource.
    The source is converted to a stream and then the change set is generated
    from the source stream.

    <return: ChangeSet|nil>
    "
    |theChangeSet theSourceStream|

    [
        (theSourceStream := aSource readStream) notNil
        ifTrue:[
            theChangeSet := ChangeSet fromStream:(theSourceStream := aSource readStream)
        ]
    ] ensure:[
        theSourceStream notNil ifTrue:[
            theSourceStream close
        ]
    ].
    ^theChangeSet
!

newForClass:aClass againstVersion:aVersionA
"return a ClassChangeSet for the class aClass against some verison in the repository.
A new instance of ClassChangeSet is generated containing 
the correspondenting changes.

<return: ClassChangeSet>
"
    |theChangeSetA theChangeSetB theClassChangeSet versionCompared diffSet|

    theClassChangeSet := self new.
    theClassChangeSet classBeingCompared:aClass.
    versionCompared := aVersionA.
    aVersionA isNil ifTrue:[
        theClassChangeSet labelA:(versionCompared := aClass revision).
        theClassChangeSet versionA:versionCompared.
    ] ifFalse:[
        aVersionA == #newest ifTrue:[
            theClassChangeSet labelA:(VersionDiffBrowser resources string:'newest').
        ] ifFalse:[
            theClassChangeSet labelA:versionCompared.
            theClassChangeSet versionA:versionCompared.
        ]
    ].
    theClassChangeSet labelB:(VersionDiffBrowser resources string:'current').
    theChangeSetA := self changeSetForClass: aClass andRevision: versionCompared.
    theChangeSetB := self changeSetForClass: aClass.
    theChangeSetA isNil
        ifTrue: [theChangeSetA := ChangeSet new].
    theChangeSetB isNil
        ifTrue: [theChangeSetB := ChangeSet new].
    "/ if we are comparing a private class, prune out other changes
    aClass isPrivate ifTrue:[
        theChangeSetA removeAllSuchThat:[:aChange |
                                                aChange className ~= aClass name
                                        ].
        theChangeSetB removeAllSuchThat:[:aChange |
                                                aChange className ~= aClass name
                                        ].
    ].
    self activityNotification:'generating diff-set...'.
    diffSet := theClassChangeSet diffSet:(theChangeSetA diffSetsAgainst:theChangeSetB).
    self activityNotification:nil.
    ^ diffSet
!

newForClass:classA labelA:aLabelA andClass:classB labelB:aLabelB
"return a ClassChangeSet for two classes.
A new instance of ClassChangeSet is generated containing the correspondenting changes.

<return: ClassChangeSet>
"
    |aStream sourceA sourceB theChangeSetA theChangeSetB theClassChangeSet|

    theClassChangeSet := self new.
    theClassChangeSet classBeingCompared:classA.
    theClassChangeSet labelA:aLabelA.
    theClassChangeSet labelB:aLabelB.

    aStream := '' writeStream.
    Method flushSourceStreamCache.
    classA fileOutOn:aStream withTimeStamp:false.
    sourceA := aStream contents asString.

    aStream := '' writeStream.
    Method flushSourceStreamCache.
    classB fileOutOn:aStream withTimeStamp:false.
    sourceB := aStream contents asString.

    theChangeSetA:=self changeSetForClass:classA andSource:sourceA. 
    theChangeSetB:=self changeSetForClass:classB andSource:sourceB.
    theChangeSetA isNil
        ifTrue: [theChangeSetA := ChangeSet new].
    theChangeSetB isNil
        ifTrue: [theChangeSetB := ChangeSet new].

    "/ just in case (if comparing a class against another),
    "/ unify the classes of the changes (to avoid that all changes are detected as different)

    theChangeSetB do:[:eachChange |
        eachChange isMethodChange ifTrue:[
            eachChange changeClass isMeta ifTrue:[
                eachChange changeClass ~~ classA theMetaclass ifTrue:[
                    eachChange changeClass:classA theMetaclass.
                ]
            ] ifFalse:[
                eachChange changeClass ~~ classA theNonMetaclass ifTrue:[
                    eachChange changeClass:classA theNonMetaclass.
                ]
            ].
        ].
    ].
    "/ remove all #initialize doIts
    theChangeSetA := theChangeSetA select:[:eachChange | eachChange isDoIt not or:[eachChange isInitialize not]].
    theChangeSetB := theChangeSetB select:[:eachChange | eachChange isDoIt not or:[eachChange isInitialize not]].

    ^theClassChangeSet diffSet:(theChangeSetA diffSetsAgainst:theChangeSetB)
!

newForClass:aClass labelA:aLabelA sourceA:aSourceA labelB:aLabelB sourceB:aSourceB
    "return a ClassChangeSet for the class aClass and the two sources.
     The two classes are compared via the source files. A new instance of 
     ClassChangeSet is generated containing the correspondenting changes.

     <return: ClassChangeSet>
    "

    |theChangeSetA theChangeSetB theClassChangeSet|

    theClassChangeSet := self new.
    theClassChangeSet classBeingCompared:aClass.
    theClassChangeSet labelA:aLabelA.
    theClassChangeSet labelB:aLabelB.
    theChangeSetA:=self changeSetForClass:aClass andSource:aSourceA. 
    theChangeSetB:=self changeSetForClass:aClass andSource:aSourceB.

    aClass isPrivate ifTrue:[
        theChangeSetA := theChangeSetA select:[:change | change isMethodChange not
                                                         or:[change className = aClass name]].
        theChangeSetA := theChangeSetA select:[:change | change isClassDefinitionChange not
                                                         or:[change className = aClass name]].
        theChangeSetA := theChangeSetA select:[:change | change isDoIt not
                                                         or:[change receiverClassName = aClass name]].
        theChangeSetB := theChangeSetB select:[:change | change isMethodChange not
                                                         or:[change className = aClass name]].
        theChangeSetB := theChangeSetB select:[:change | change isClassDefinitionChange not
                                                         or:[change className = aClass name]].
        theChangeSetB := theChangeSetB select:[:change | change isDoIt not
                                                         or:[change receiverClassName = aClass name]].
        "/ there might be more needed...
    ].

    theChangeSetA isNil
        ifTrue: [theChangeSetA := ChangeSet new].
    theChangeSetB isNil
        ifTrue: [theChangeSetB := ChangeSet new].

    ^ theClassChangeSet diffSet:(theChangeSetA diffSetsAgainst:theChangeSetB)
!

newForClass:aClass versionA:aVersionA versionB:aVersionB
"return a ClassChangeSet for the class aClass and the two versions.
The two class version are checked out from the repository and then being
compared. A new instance of ClassChangeSet is generated containing 
the correspondenting changes.

<return: ClassChangeSet>
"
    |theChangeSetA theChangeSetB theClassChangeSet|

    theClassChangeSet := self new.
    theClassChangeSet classBeingCompared:aClass.
    theClassChangeSet versionA:aVersionA.
    theClassChangeSet versionB:aVersionB.
    theClassChangeSet labelA:aVersionA.
    theClassChangeSet labelB:aVersionB.
    theChangeSetA := self changeSetForClass: aClass andRevision: aVersionA.
    theChangeSetB := self changeSetForClass: aClass andRevision: aVersionB.
    theChangeSetA isNil
        ifTrue: [theChangeSetA := ChangeSet new].
    theChangeSetB isNil
        ifTrue: [theChangeSetB := ChangeSet new].
    ^theClassChangeSet diffSet:(theChangeSetA diffSetsAgainst:theChangeSetB)
! !

!VersionDiffBrowser::ClassChangeSet methodsFor:'accessing'!

classBeingCompared
    "returns the value of the class which is compared"

    ^ classBeingCompared
!

classBeingCompared:something
    "set the value of the class which is compared"

    classBeingCompared := something.
!

diffSet
    "returns a diffSet containing the different changes.
     it responds to:

     changed         OrderedCollection of arrays containing ChangeSets for methods 
                     which are changed and exists in the class versionA and versionB
     onlyInArg       ChangeSet for the methods which exists only in the class versionB
     onlyInReceiver  ChangeSet for the methods which exists only in the class versionA
    "  

    ^ diffSet
!

diffSet:something
    "sets the diffSet containing the different changes.
     it responds to:

     changed         OrderedCollection of arrays containing ChangeSets for methods 
                     which are changed and exists in the class versionA and versionB
     onlyInArg       ChangeSet for the methods which exists only in the class versionB
     onlyInReceiver  ChangeSet for the methods which exists only in the class versionA
    "  

    diffSet := something.
!

labelA
    "returns the label for the class versionA"

    ^ labelA
!

labelA:something
   "sets the label for the class versionA"

    labelA := something.
!

labelB
    "returns the label for the class versionB"

    ^ labelB
!

labelB:something
    "sets the label for the class versionB"

    labelB := something.
!

methodsChanged
    "returns an OrderedCollection of arrays containing ChangeSets for methods 
     which are changed and exists in the class versionA and versionB

     <return: OrderedCollection of Array(2)>
    "

    ^ self diffSet changed
!

methodsOnlyInA
    "returns a ChangeSet for the methods which exists only in the class versionA"  

    ^ self diffSet onlyInReceiver
!

methodsOnlyInB
    "returns a ChangeSet for the methods which exists only in the class versionB"  

    ^ self diffSet onlyInArg
!

versionA
    ^ versionA
!

versionA:something
    versionA := something.
!

versionB
    ^ versionB
!

versionB:something
    versionB := something.
! !

!VersionDiffBrowser class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libtool/VersionDiffBrowser.st,v 1.61 2002-09-06 15:15:10 cg Exp $'
! !