added: #changeMenuCompareClass:
authorClaus Gittinger <cg@exept.de>
Thu, 01 Dec 2011 19:18:12 +0100
changeset 10943 39d815d28b9d
parent 10942 fe91bd032e49
child 10944 b87f1b504617
added: #changeMenuCompareClass: not finished
Tools__ChangeSetBrowser2.st
--- a/Tools__ChangeSetBrowser2.st	Thu Dec 01 14:42:52 2011 +0100
+++ b/Tools__ChangeSetBrowser2.st	Thu Dec 01 19:18:12 2011 +0100
@@ -918,10 +918,21 @@
             itemValue: changeMenuBrowseClass:
             translateLabel: true
           )
+         (MenuItem
+            label: '-'
+          )
+         (MenuItem
+            enabled: hasSingleChangeSelectedAndCanBrowse:
+            label: 'Compare Class Against...'
+            itemValue: changeMenuCompareClass:
+            translateLabel: true
+          )
          )
         nil
         nil
       )
+
+    "Modified: / 01-12-2011 / 18:36:15 / cg"
 !
 
 changeMenu2
@@ -1926,6 +1937,113 @@
     "Created: / 05-09-2011 / 16:08:35 / cg"
 !
 
+changeMenuCompareClass: changeList
+    |changes classNames classNameToClassMapping lastNameSpace 
+     addClassName addThemChanges existingClasses
+     allChanges changeSet1 changeSet2 diffSet|
+
+    changeList == list1 ifTrue:[
+        changes := selection1Holder value.
+    ] ifFalse:[
+        changes := selection2Holder value.
+    ].
+    changes := changes collect:[:eachListEntry | eachListEntry change].
+
+    classNameToClassMapping := Dictionary new.
+    classNames := Set new.
+    allChanges := ChangeSet new.
+    existingClasses := Set new.
+
+    addClassName := 
+        [:nmArg |
+            |nm ns existingClass goodAnswer|
+
+            nm := nmArg.
+            existingClass := Smalltalk classNamed:nm.
+
+            existingClass notNil ifTrue:[
+                goodAnswer := nm
+            ] ifFalse:[
+                ns := NameSpace allNameSpaces 
+                                    detect:[:ns | (ns classNamed:nm) notNil ]
+                                    ifNone:nil.
+                ns notNil ifTrue:[
+                    goodAnswer := (ns classNamed:nm) name.
+                ] ifFalse:[                
+                    goodAnswer := nm.
+                    (lastNameSpace notNil 
+                        and:[ lastNameSpace isNamespace 
+                        and:[(lastNameSpace classNamed:nm) notNil ]]
+                    ) ifTrue:[
+                        goodAnswer := (lastNameSpace classNamed:nm) name.
+                    ] ifFalse:[
+                        (lastNameSpace notNil 
+                            and:[ lastNameSpace isBehavior 
+                            and:[(lastNameSpace privateClassesAt:nm asSymbol) notNil ]]
+                        ) ifTrue:[
+                            goodAnswer := (lastNameSpace privateClassesAt:nm asSymbol) name.
+                        ]
+                    ].
+                ].
+            ].
+            nm := Dialog 
+                    request:('Class to compare for "%1"?' bindWith:nmArg)
+                    initialAnswer:goodAnswer.
+            nm isNil ifTrue:[^ self].
+            nm notEmpty ifTrue:[
+                existingClass := Smalltalk at:nm asSymbol.
+            ].
+            existingClass notNil ifTrue:[
+                classNameToClassMapping at:nmArg put:existingClass.
+                existingClasses add:existingClass.
+            ].
+            classNames add:nmArg
+        ].
+
+    addThemChanges := [:changes |
+        "/ collect classes and mappings
+        changes do:[:c |
+            c isClassDefinitionChange ifTrue:[
+                addClassName value:(c className).
+                allChanges add:c.
+            ]].
+
+        changes do:[:c |
+            c isMethodChange ifTrue:[
+                (classNames includes:(c className)) ifFalse:[
+                    addClassName value:(c className).
+                ].
+                allChanges add:c.
+            ]].
+
+        changes do:[:c |
+            c isCompositeChange ifTrue:[
+                addThemChanges value:(c changes)
+            ].
+        ].
+    ].
+
+    changes do:addThemChanges.
+
+    "/ now, build a diffset and present it...
+    changeSet1 := allChanges.
+    changeSet2 := ChangeSet new.
+    existingClasses do:[:cls |
+        changeSet2 addAll:(ChangeSet forExistingClass:cls).
+    ].
+    diffSet := changeSet1 diffSetsAgainst:changeSet2.
+
+    (UserPreferences versionDiffViewerClass)
+        openOnDiffSet:diffSet 
+        labelA:'Monticello'
+        labelB:'Current (In Image)'
+        title:'Diffs'
+        ignoreExtensions:false.
+
+    "Created: / 04-08-2011 / 17:27:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 01-12-2011 / 18:36:44 / cg"
+!
+
 changeMenuDeleteSelection: changeList
 
     self selectionDo:[:chg|chg removed: true]
@@ -2510,11 +2628,11 @@
 !ChangeSetBrowser2 class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__ChangeSetBrowser2.st,v 1.23 2011-11-29 10:30:07 vrany Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__ChangeSetBrowser2.st,v 1.24 2011-12-01 18:18:12 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__ChangeSetBrowser2.st,v 1.23 2011-11-29 10:30:07 vrany Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__ChangeSetBrowser2.st,v 1.24 2011-12-01 18:18:12 cg Exp $'
 !
 
 version_SVN