Merge jv
authorMerge Script
Sun, 06 Sep 2015 06:46:42 +0200
branchjv
changeset 3898 33e7f5c6e2bc
parent 3895 7236976df613 (current diff)
parent 3897 4bc08912b7b9 (diff)
child 3901 5b03b8d3968b
Merge
ClassChange.st
SourceCodeManagerUtilities.st
--- a/ClassChange.st	Fri Sep 04 06:42:32 2015 +0200
+++ b/ClassChange.st	Sun Sep 06 06:46:42 2015 +0200
@@ -203,7 +203,8 @@
 !
 
 classBaseName 
-    "return the className of the change"
+    "return the className of the change.
+     This is without *any* prefix (namespace or private-owner)"
 
     ^ self cutNameSpaceOf:className
 
@@ -212,7 +213,10 @@
 
 className
     "Returns class name of the class *without* namespace, but with
-     all owning classes (if the change class is a private class)"
+     all owning classes (if the change class is a private class).
+     cg: this comment is wrong!! 
+     question: what is intended: what the comment says, or what the code does?"
+
     ^ className
 
     "Modified (comment): / 12-06-2013 / 11:33:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -569,11 +573,11 @@
 !ClassChange class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic3/ClassChange.st,v 1.78 2015-05-27 13:35:45 cg Exp $'
+    ^ '$Header$'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic3/ClassChange.st,v 1.78 2015-05-27 13:35:45 cg Exp $'
+    ^ '$Header$'
 !
 
 version_HG
@@ -582,6 +586,6 @@
 !
 
 version_SVN
-    ^ '$Id: ClassChange.st,v 1.78 2015-05-27 13:35:45 cg Exp $'
+    ^ '$Id$'
 ! !
 
--- a/SourceCodeManagerUtilities.st	Fri Sep 04 06:42:32 2015 +0200
+++ b/SourceCodeManagerUtilities.st	Sun Sep 06 06:46:42 2015 +0200
@@ -2153,191 +2153,209 @@
 
 compareClassWithRepository:aClass askForRevision:askForRevision
     "open a diff-textView comparing the current (in-image) version
-     against its orgiginal version found in the repository."
-
-    |classToCompare brwsr
-     aStream comparedSource currentSource rev revString thisRevString mgr
-     nm msg revisionInClass newestRev versionsAreTheSame|
+     against the newest or an asked-for version found in the repository."
+
+    |classToCompare brwsr comparedSource currentSource rev revString thisRevString 
+     scmManager revisionInClass versionsAreTheSame|
 
     classToCompare := aClass theNonMetaclass.
 
-    nm := classToCompare name.
-    (mgr := manager) isNil ifTrue:[
-        mgr := self sourceCodeManagerFor:classToCompare.
-        mgr isNil ifTrue:[
-            self error:'oops - no sourcecode manager' mayProceed:true.
-            ^ self
-        ].
-    ].
-
-    rev := classToCompare revisionInfoOfManager:mgr.
-"/    rev := classToCompare binaryRevision.
-    revisionInClass := classToCompare revisionOfManager:mgr.
-    rev isNil ifTrue:[
-        rev := revisionInClass
-    ].
-    rev isNil ifTrue:[
-        (Dialog confirm:'Class seems to be not yet in the repository (or classes revision info is missing or corrupted)\\Proceed ?' withCRs)
-        ifFalse:[
-            ^ self
-        ]
+    comparedSource := self 
+                        fetchSourceOf:classToCompare askForRevision:askForRevision 
+                        into:[:revStringArg :revisionInClassArg :scmManagerArg| 
+                            revString := revStringArg.
+                            revisionInClass := revisionInClassArg.
+                            scmManager := scmManagerArg.
+                        ].
+    comparedSource isNil ifTrue:[
+        ^ self
     ].
 
-    "/
-    "/ class in repository - ask for revision
-    "/
-    SourceCodeManagerError handle:[:ex |
-        Dialog warn:(resources 
-                                stringWithCRs:'Could not fetch revision info of "%1".\\Please check your sourcecode manager settings of %2 for package: "%3".\(and possibly the network for reachability of the repository)'
-                                with:classToCompare name
-                                with:classToCompare sourceCodeManager managerTypeName
-                                with:classToCompare package).
-        ^ self.
-    ] do:[
-        newestRev := mgr newestRevisionOf:classToCompare.
-    ].
-    askForRevision ifTrue:[
-        msg := resources string:'Compare to revision: (empty for newest)'.
-        rev notNil ifTrue:[
-            msg := msg , '\\' , (resources string:'Current %1 is based upon rev %2.'
-                                           with:nm allBold with:rev).
-            (revisionInClass notNil and:[revisionInClass ~= rev]) ifTrue:[
-                msg := msg , '\' , (resources string:'And has been checked into the repository as %1.'
-                                               with:revisionInClass)
+"/    classToCompare := aClass theNonMetaclass.
+"/
+"/    nm := classToCompare name.
+"/    (mgr := manager) isNil ifTrue:[
+"/        mgr := self sourceCodeManagerFor:classToCompare.
+"/        mgr isNil ifTrue:[
+"/            self error:'oops - no sourcecode manager' mayProceed:true.
+"/            ^ self
+"/        ].
+"/    ].
+"/
+"/    rev := classToCompare revisionInfoOfManager:mgr.
+"/"/    rev := classToCompare binaryRevision.
+"/    revisionInClass := classToCompare revisionOfManager:mgr.
+"/    rev isNil ifTrue:[
+"/        rev := revisionInClass
+"/    ].
+"/    rev isNil ifTrue:[
+"/        (Dialog confirm:'Class seems to be not yet in the repository (or classes revision info is missing or corrupted)\\Proceed ?' withCRs)
+"/        ifFalse:[
+"/            ^ self
+"/        ]
+"/    ].
+"/
+"/    "/
+"/    "/ class in repository - ask for revision
+"/    "/
+"/    SourceCodeManagerError handle:[:ex |
+"/        Dialog warn:(resources 
+"/                                stringWithCRs:'Could not fetch revision info of "%1".\\Please check your sourcecode manager settings of %2 for package: "%3".\(and possibly the network for reachability of the repository)'
+"/                                with:classToCompare name
+"/                                with:classToCompare sourceCodeManager managerTypeName
+"/                                with:classToCompare package).
+"/        ^ self.
+"/    ] do:[
+"/        newestRev := mgr newestRevisionOf:classToCompare.
+"/    ].
+"/    askForRevision ifTrue:[
+"/        msg := resources string:'Compare to revision: (empty for newest)'.
+"/        rev notNil ifTrue:[
+"/            msg := msg , '\\' , (resources string:'Current %1 is based upon rev %2.'
+"/                                           with:nm allBold with:rev).
+"/            (revisionInClass notNil and:[revisionInClass ~= rev]) ifTrue:[
+"/                msg := msg , '\' , (resources string:'And has been checked into the repository as %1.'
+"/                                               with:revisionInClass)
+"/            ]
+"/        ].
+"/        newestRev notNil ifTrue:[
+"/            msg := msg , '\' , (resources string:'Newest in repository is %1.'
+"/                                           with:newestRev)
+"/        ].
+"/
+"/        rev := self
+"/                    askForExistingRevision:msg 
+"/                    title:'Compare with repository' 
+"/                    class:classToCompare.
+"/    ] ifFalse:[
+"/        rev := newestRev.
+"/    ].
+"/
+"/    rev isNil ifTrue:[
+"/        mgr = classToCompare sourceCodeManager ifTrue:[
+"/            msg := 'Could not figure out the newest revision of "%1".\\Please check if this class is really contained in that repository,\and also your sourcecode manager settings of %2 for package: "%3".\(and possibly the network for reachability of the repository)'
+"/        ] ifFalse:[
+"/            msg := 'Could not figure out the newest revision of "%1".\\Notice that the class is actually maintained by %4, not %2.\Please check if this class is really in the %2 repository,\and also your sourcecode manager settings of %2 for package: "%3".\(and possibly the network for reachability of the repository)'
+"/        ].
+"/        Dialog warn:(resources 
+"/                                stringWithCRs:msg
+"/                                with:classToCompare name
+"/                                with:mgr managerTypeName
+"/                                with:classToCompare package
+"/                                with:(classToCompare sourceCodeManager managerTypeName)).
+"/        ^ self.
+"/        
+"/    ].
+"/    rev withoutSpaces isEmpty ifTrue:[
+"/        msg := 'extracting newest %1 (' , (newestRev ? '???') , ')'.
+"/        "/ aStream := mgr getMostRecentSourceStreamForClassNamed:nm.
+"/        aStream := mgr getSourceStreamFor:classToCompare revision:newestRev.
+"/        revString := '(newest: ' , (newestRev ? '???') , ')'.
+"/    ] ifFalse:[
+"/        msg := 'extracting previous %1'.
+"/        aStream := mgr getSourceStreamFor:classToCompare revision:rev.
+"/        revString := rev
+"/    ].
+"/
+"/    aStream isNil ifTrue:[
+"/        self warn:'Could not extract source from repository (check repository settings / network)'.
+"/        ^ self
+"/    ].
+"/    aStream class readErrorSignal handle:[:ex |
+"/        self warn:('Read error while reading extracted source\\' , ex description) withCRs.
+"/        aStream close.
+"/        ^ self
+"/    ] do:[
+"/        comparedSource := aStream contents asString.
+"/    ].
+"/    aStream close.
+
+    self activityNotification:'generating current source...'.
+
+    currentSource := self sourceCodeOfClass:classToCompare.
+
+    self activityNotification:'comparing...'.
+
+    versionsAreTheSame := false.
+    "/ a quick smoke test, if code is exactly the same
+    comparedSource = currentSource ifTrue:[
+        versionsAreTheSame := true.
+    ] ifFalse:[
+        "/ this branch generates chunks and compares individual methods.
+        "/ this is a litle more expensive, but will deal with reordered methods in the source,
+        "/ additional whitespace, empty lines etc.
+
+        thisRevString := revisionInClass ? 'no revision'.
+
+        revString = '(newest)' ifTrue:[
+            |newestRev|
+
+            (newestRev := scmManager newestRevisionOf:classToCompare) notNil ifTrue:[
+                revString := '(newest is ' , newestRev , ')'
             ]
         ].
-        newestRev notNil ifTrue:[
-            msg := msg , '\' , (resources string:'Newest in repository is %1.'
-                                           with:newestRev)
-        ].
-
-        rev := self
-                    askForExistingRevision:msg 
-                    title:'Compare with repository' 
-                    class:classToCompare.
-    ] ifFalse:[
-        rev := newestRev.
-    ].
-
-    rev isNil ifTrue:[
-        mgr = classToCompare sourceCodeManager ifTrue:[
-            msg := 'Could not figure out the newest revision of "%1".\\Please check if this class is really contained in that repository,\and also your sourcecode manager settings of %2 for package: "%3".\(and possibly the network for reachability of the repository)'
-        ] ifFalse:[
-            msg := 'Could not figure out the newest revision of "%1".\\Notice that the class is actually maintained by %4, not %2.\Please check if this class is really in the %2 repository,\and also your sourcecode manager settings of %2 for package: "%3".\(and possibly the network for reachability of the repository)'
-        ].
-        Dialog warn:(resources 
-                                stringWithCRs:msg
-                                with:classToCompare name
-                                with:mgr managerTypeName
-                                with:classToCompare package
-                                with:(classToCompare sourceCodeManager managerTypeName)).
-        ^ self.
-        
-    ] ifFalse:[
-        rev withoutSpaces isEmpty ifTrue:[
-            msg := 'extracting newest %1 (' , (newestRev ? '???') , ')'.
-            "/ aStream := mgr getMostRecentSourceStreamForClassNamed:nm.
-            aStream := mgr getSourceStreamFor:classToCompare revision:newestRev.
-            revString := '(newest: ' , (newestRev ? '???') , ')'.
-        ] ifFalse:[
-            msg := 'extracting previous %1'.
-            aStream := mgr getSourceStreamFor:classToCompare revision:rev.
-            revString := rev
-        ].
-
-        aStream isNil ifTrue:[
-            self warn:'Could not extract source from repository (check repository settings / network)'.
-            ^ self
-        ].
-        aStream class readErrorSignal handle:[:ex |
-            self warn:('Read error while reading extracted source\\' , ex description) withCRs.
-            aStream close.
-            ^ self
-        ] do:[
-            comparedSource := aStream contents asString.
-        ].
-        aStream close.
-
-        self activityNotification:'generating current source...'.
-
-        currentSource := self sourceCodeOfClass:classToCompare.
 
         self activityNotification:'comparing...'.
 
-        versionsAreTheSame := false.
-        comparedSource = currentSource ifTrue:[
-            versionsAreTheSame := true.
-        ] ifFalse:[
-            thisRevString := revisionInClass ? 'no revision'.
-
-            revString = '(newest)' ifTrue:[
-                (rev := mgr newestRevisionOf:classToCompare) notNil ifTrue:[
-                    revString := '(newest is ' , rev , ')'
-                ]
-            ].
-
-            self activityNotification:'comparing...'.
-
-            ChangeSet invalidChangeChunkError handle:[:ex |
-                |answer|
-
-                answer := Dialog 
-                            confirm:(resources 
-                                stringWithCRs:'An invalid change chunk was encountered when reading the source of %1.\This may be due to a currupted source file (or source file was modified/updated in the meantime, without recompilation).\\Proceed in debugger?'
-                                with:aClass)
-                            yesLabel:(resources string:'Debug')
-                            noLabel:(resources string:'Cancel')
-                            initialAnswer:false.
-                answer ifTrue:[ex reject].
-                AbortOperationRequest raise.
-            ] do:[
-                brwsr := (UserPreferences versionDiffViewerClass)
-                      openOnClass:classToCompare
-                      labelA:('Repository: ' , revString)
-                      sourceA:comparedSource
-                      labelB:('Current: (based on: ' , thisRevString , ')')
-                      sourceB:currentSource
-                      title:('Comparing ' , classToCompare name)
-                      ifSame:[versionsAreTheSame := true].
+        ChangeSet invalidChangeChunkError handle:[:ex |
+            |answer|
+
+            answer := Dialog 
+                        confirm:(resources 
+                            stringWithCRs:'An invalid change chunk was encountered when reading the source of %1.\This may be due to a currupted source file (or source file was modified/updated in the meantime, without recompilation).\\Proceed in debugger?'
+                            with:aClass)
+                        yesLabel:(resources string:'Debug')
+                        noLabel:(resources string:'Cancel')
+                        initialAnswer:false.
+            answer ifTrue:[ex reject].
+            AbortOperationRequest raise.
+        ] do:[
+            brwsr := (UserPreferences versionDiffViewerClass)
+                  openOnClass:classToCompare
+                  labelA:('Repository: ' , revString)
+                  sourceA:comparedSource
+                  labelB:('Current: (based on: ' , thisRevString , ')')
+                  sourceB:currentSource
+                  title:('Comparing ' , classToCompare name)
+                  ifSame:[versionsAreTheSame := true].
+        ].
+        versionsAreTheSame ifFalse:[
+            brwsr classChangeSet 
+                classBeingCompared:classToCompare;
+                versionA:revString;
+                versionB:thisRevString , 'mod'.
+        ].
+    ].
+
+    versionsAreTheSame ifTrue:[
+        (classToCompare hasUnsavedChanges) ifTrue:[
+            (self confirm:(resources 
+                            stringWithCRs:'Versions of %1 are identical.\\Remove entries from changeSet ?'
+                            with:classToCompare name allBold)) ifTrue:[
+                ChangeSet current condenseChangesForClass:classToCompare.
             ].
-            versionsAreTheSame ifFalse:[
-                brwsr classChangeSet 
-                    classBeingCompared:classToCompare;
-                    versionA:rev;
-                    versionB:rev , 'mod'.
-            ].
+        ] ifFalse:[
+            self information:'Versions are identical.'.
+            ChangeSet current unrememberChangedClasses.
         ].
-
-        versionsAreTheSame ifTrue:[
-            (classToCompare hasUnsavedChanges) ifTrue:[
-                (self confirm:(resources 
-                                stringWithCRs:'Versions of %1 are identical.\\Remove entries from changeSet ?'
-                                with:classToCompare name allBold)) ifTrue:[
-                    ChangeSet current condenseChangesForClass:classToCompare.
+        revisionInClass isNil ifTrue:[
+            (Dialog confirm:'Update (Fix) the classes Revision Info ?' withCRs)
+            ifTrue:[
+                |newString root|
+
+                newString := scmManager updatedRevisionStringOf:aClass forRevision:rev with:aClass revisionString.
+                newString isNil ifTrue:[
+                    root := scmManager getCVSROOTForModule:(aClass package upTo:$:).
+                    root := scmManager repositoryTopDirectoryFromCVSRoot:root.
+                    newString := '$', 'Header: ',(root copyReplaceAll: $: with:$/ ),'/'
+                                 ,(Smalltalk fileNameForClass:aClass),'.st,v ',rev,' '
+                                 ,(Date today printStringFormat:'%y-%m-%d'),' '
+                                 ,(Time now printStringFormat:'%h:%m:%s'),' '
+                                 ,'+0000 '
+                                 ,(OperatingSystem getLoginName),' Exp $'.
                 ].
-            ] ifFalse:[
-                self information:'Versions are identical.'.
-                ChangeSet current unrememberChangedClasses.
-            ].
-            revisionInClass isNil ifTrue:[
-                (Dialog confirm:'Update (Fix) the classes Revision Info ?' withCRs)
-                ifTrue:[
-                    |newString root|
-
-                    newString := mgr updatedRevisionStringOf:aClass forRevision:rev with:aClass revisionString.
-                    newString isNil ifTrue:[
-                        root := mgr getCVSROOTForModule:(aClass package upTo:$:).
-                        root := mgr repositoryTopDirectoryFromCVSRoot:root.
-                        newString := '$', 'Header: ',(root copyReplaceAll: $: with:$/ ),'/'
-                                     ,(Smalltalk fileNameForClass:aClass),'.st,v ',rev,' '
-                                     ,(Date today printStringFormat:'%y-%m-%d'),' '
-                                     ,(Time now printStringFormat:'%h:%m:%s'),' '
-                                     ,'+0000 '
-                                     ,(OperatingSystem getLoginName),' Exp $'.
-                    ].
-                    mgr updateVersionMethodOf:aClass for:newString.
-                ]
-            ].
+                scmManager updateVersionMethodOf:aClass for:newString.
+            ]
         ].
     ].
 
@@ -3106,6 +3124,128 @@
     "Created: / 29-12-2011 / 14:33:46 / cg"
 !
 
+fetchSourceOf:aClass askForRevision:askForRevision into:aBlockToReturnMultipleValues
+    "fetch the source of either the newest version or the revision being asked for,
+     or nil, if there are any problems.
+     Helper method"
+
+    |classToCompare aStream comparedSource rev revString mgr
+     nm msg revisionInClass newestRev|
+
+    classToCompare := aClass theNonMetaclass.
+
+    nm := classToCompare name.
+    (mgr := manager) isNil ifTrue:[
+        mgr := self sourceCodeManagerFor:classToCompare.
+        mgr isNil ifTrue:[
+            self error:'oops - no sourcecode manager' mayProceed:true.
+            ^ nil
+        ].
+    ].
+
+    rev := classToCompare revisionInfoOfManager:mgr.
+"/    rev := classToCompare binaryRevision.
+    revisionInClass := classToCompare revisionOfManager:mgr.
+    rev isNil ifTrue:[
+        rev := revisionInClass
+    ].
+    rev isNil ifTrue:[
+        (Dialog confirm:'Class seems to be not yet in the repository (or classes revision info is missing or corrupted)\\Proceed ?' withCRs)
+        ifFalse:[
+            ^ nil
+        ]
+    ].
+
+    "/
+    "/ class in repository - ask for revision
+    "/
+    SourceCodeManagerError handle:[:ex |
+        Dialog warn:(resources 
+                                stringWithCRs:'Could not fetch revision info of "%1".\\Please check your sourcecode manager settings of %2 for package: "%3".\(and possibly the network for reachability of the repository)'
+                                with:classToCompare name
+                                with:classToCompare sourceCodeManager managerTypeName
+                                with:classToCompare package).
+        ^ nil.
+    ] do:[
+        newestRev := mgr newestRevisionOf:classToCompare.
+    ].
+
+    askForRevision ifTrue:[
+        msg := resources string:'Compare to revision: (empty for newest)'.
+        rev notNil ifTrue:[
+            msg := msg , '\\' , (resources string:'Current %1 is based upon rev %2.'
+                                           with:nm allBold with:rev).
+            (revisionInClass notNil and:[revisionInClass ~= rev]) ifTrue:[
+                msg := msg , '\' , (resources string:'And has been checked into the repository as %1.'
+                                               with:revisionInClass)
+            ]
+        ].
+        newestRev notNil ifTrue:[
+            msg := msg , '\' , (resources string:'Newest in repository is %1.'
+                                           with:newestRev)
+        ].
+
+        rev := self
+                    askForExistingRevision:msg 
+                    title:'Compare with repository' 
+                    class:classToCompare.
+    ] ifFalse:[
+        rev := newestRev.
+    ].
+
+    rev isNil ifTrue:[
+        mgr = classToCompare sourceCodeManager ifTrue:[
+            msg := 'Could not figure out the newest revision of "%1".\\Please check if this class is really contained in that repository,\and also your sourcecode manager settings of %2 for package: "%3".\(and possibly the network for reachability of the repository)'
+        ] ifFalse:[
+            msg := 'Could not figure out the newest revision of "%1".\\Notice that the class is actually maintained by %4, not %2.\Please check if this class is really in the %2 repository,\and also your sourcecode manager settings of %2 for package: "%3".\(and possibly the network for reachability of the repository)'
+        ].
+        Dialog warn:(resources 
+                                stringWithCRs:msg
+                                with:classToCompare name
+                                with:mgr managerTypeName
+                                with:classToCompare package
+                                with:(classToCompare sourceCodeManager managerTypeName)).
+        ^ nil.
+    ].
+
+    rev withoutSpaces isEmpty ifTrue:[
+        msg := 'extracting newest %1 (' , (newestRev ? '???') , ')'.
+        "/ aStream := mgr getMostRecentSourceStreamForClassNamed:nm.
+        aStream := mgr getSourceStreamFor:classToCompare revision:newestRev.
+        revString := '(newest: ' , (newestRev ? '???') , ')'.
+    ] ifFalse:[
+        msg := 'extracting previous %1'.
+        aStream := mgr getSourceStreamFor:classToCompare revision:rev.
+        revString := rev
+    ].
+
+    aStream isNil ifTrue:[
+        self warn:'Could not extract source from repository (check repository settings / network)'.
+        ^ nil
+    ].
+    aStream class readErrorSignal handle:[:ex |
+        self warn:('Read error while reading extracted source\\' , ex description) withCRs.
+        aStream close.
+        ^ nil
+    ] do:[
+        comparedSource := aStream contents asString.
+    ].
+
+    aStream close.
+
+    aBlockToReturnMultipleValues 
+        value:revString 
+        value:revisionInClass
+        value:mgr. 
+    ^ comparedSource
+
+    "
+      self compareClassWithRepository:Array
+    "
+
+    "Modified: / 24-07-2012 / 18:11:27 / cg"
+!
+
 getLogMessageForClassCheckinTakingDefaultsFromPreviousLogInfo:aLogInfoOrNil forClass:aClass valuesInto:aBlock
     "open a dialog, asking for commit/checkin log info.
      Returns 2 values: a log message and additional checkinInfo (containing things like