renamed OldMethods to MethodHistory.
authorClaus Gittinger <cg@exept.de>
Wed, 07 Jul 1999 16:35:02 +0200
changeset 4345 030d3a420dc8
parent 4344 262e182a394f
child 4346 d7f7dd10d107
renamed OldMethods to MethodHistory. Moved corresponding code from Class to here.
ClassDescr.st
ClassDescription.st
--- a/ClassDescr.st	Wed Jul 07 14:48:19 1999 +0200
+++ b/ClassDescr.st	Wed Jul 07 16:35:02 1999 +0200
@@ -21,7 +21,7 @@
 		FileOutNameSpaceQuerySignal
 		ChangeDefaultApplicationNotificationSignal
 		DefaultApplicationQuerySignal
-		ClassConventionViolationConfirmationQuerySignal'
+		ClassConventionViolationConfirmationQuerySignal MethodHistory'
 	poolDictionaries:''
 	category:'Kernel-Classes'
 !
@@ -51,64 +51,71 @@
 
     [Instance variables:]
 
-	instvars        <String>            the names of the instance variables
+        instvars        <String>            the names of the instance variables
 
 
     [Class variables:]
 
-	UpdatingChanges <Boolean>       true if the changes-file shall be updated
-					(except during startup and when filing in, this flag
-					 is usually true)
-
-	UpdateChangeFileQuerySignal     used as an upQuery from the change management.
-					Whenever a changeRecord is to be written,
-					this signal is raised and a handler (if present)
-					is supposed to return true or false.
-					If unhandled, the value of the global
-					UpdatingChanges is returned for backward
-					compatibility (which means that the old
-					mechanism is used if no query-handler
-					is present).
-
-	LockChangesFile <Boolean>       if true, the change file is locked for updates.
-					Required when multiple users operate on a common
-					change file.
-					This is an experimental new feature, being evaluated.
-
-	FileOutErrorSignal              raised when an error occurs during fileOut
-
-	CatchMethodRedefinitions        if true, classes protect themself 
-	MethodRedefinitionSignal        (by raising MethodRedefinitionSignal)
-					from redefining any existing methods,
-					which are defined in another package.
-					(i.e. a signal will be raised, if you
-					 fileIn something which redefines an
-					 existing method and the packages do not
-					 match).
-					The default is (currently) true.
-
-	TryLocalSourceFirst             If true, local source files are tried
-					first BEFORE the sourceCodeManager is
-					consulted. If false, the sourceCodeManager
-					is asked first.
-					Should be turned on, if you run an image from
-					local sources which have not yet been checked in.
-
-	NameSpaceQuerySignal            used as an upQuery to ask for a namespace into
-					which new classes are to be installed.
-
-	PackageQuerySignal              used as an upQuery to ask for a packageSymbol with
-					which new classes/methods are to be marked.
-
-	CreateNameSpaceQuerySignal      used as an upQuery to ask if unknown namespaces
-					should be silently created (without asking the user)
-
+        UpdatingChanges <Boolean>       true if the changes-file shall be updated
+                                        (except during startup and when filing in, this flag
+                                         is usually true)
+
+        UpdateChangeFileQuerySignal     used as an upQuery from the change management.
+                                        Whenever a changeRecord is to be written,
+                                        this signal is raised and a handler (if present)
+                                        is supposed to return true or false.
+                                        If unhandled, the value of the global
+                                        UpdatingChanges is returned for backward
+                                        compatibility (which means that the old
+                                        mechanism is used if no query-handler
+                                        is present).
+
+        LockChangesFile <Boolean>       if true, the change file is locked for updates.
+                                        Required when multiple users operate on a common
+                                        change file.
+                                        This is an experimental new feature, being evaluated.
+
+        FileOutErrorSignal              raised when an error occurs during fileOut
+
+        CatchMethodRedefinitions        if true, classes protect themself 
+        MethodRedefinitionSignal        (by raising MethodRedefinitionSignal)
+                                        from redefining any existing methods,
+                                        which are defined in another package.
+                                        (i.e. a signal will be raised, if you
+                                         fileIn something which redefines an
+                                         existing method and the packages do not
+                                         match).
+                                        The default is (currently) true.
+
+        TryLocalSourceFirst             If true, local source files are tried
+                                        first BEFORE the sourceCodeManager is
+                                        consulted. If false, the sourceCodeManager
+                                        is asked first.
+                                        Should be turned on, if you run an image from
+                                        local sources which have not yet been checked in.
+
+        NameSpaceQuerySignal            used as an upQuery to ask for a namespace into
+                                        which new classes are to be installed.
+
+        PackageQuerySignal              used as an upQuery to ask for a packageSymbol with
+                                        which new classes/methods are to be marked.
+
+        CreateNameSpaceQuerySignal      used as an upQuery to ask if unknown namespaces
+                                        should be silently created (without asking the user)
+
+        MethodHistory                   if nonNil, this must be an IdentityDictionary,
+                                        which is filled with method->previousversionMethod
+                                        associations. Can be used for undo-last-method-change
+                                        The number of remembered methods is controlled via the
+                                        UserPreferences.
+                                        Notice: this may fillup your memory over time,
+                                        the preferences are set too high.
 
     [author:]
-	Claus Gittinger
+        Claus Gittinger
 
     [see also:]
-	Behavior Class Metaclass
+        Behavior Class Metaclass
 "
 ! !
 
@@ -396,6 +403,27 @@
     "Modified: / 17.6.1998 / 10:31:02 / cg"
 !
 
+keepMethodHistory:aBoolean
+    "turn on/off oldMethod remembering. If on, a methods previous version
+     is kept locally, for later undo (or compare)."
+
+    aBoolean ifTrue:[
+        MethodHistory isNil ifTrue:[
+            MethodHistory := OrderedDictionary new.
+        ]
+    ] ifFalse:[
+        MethodHistory := nil
+    ].
+
+    "
+     Class keepMethodHistory:true
+     Class keepMethodHistory:false
+    "
+
+    "Modified: 7.11.1996 / 18:36:00 / cg"
+    "Created: 7.11.1996 / 19:05:57 / cg"
+!
+
 lockChangesFile
     "return true, if the change file is locked during update"
 
@@ -412,6 +440,33 @@
     ^ prev
 ! !
 
+!ClassDescription class methodsFor:'accessing - history'!
+
+flushMethodHistory
+    "flush any method->previousVersion associations,
+     all method history is lost."
+
+    MethodHistory notNil ifTrue:[
+        MethodHistory := OrderedDictionary new
+    ].
+
+    "Created: 7.11.1996 / 19:07:25 / cg"
+!
+
+methodHistory
+    "return a dictionary containing method->previousVersion associations,
+     nil if method remembering has been turned off"
+
+    ^ MethodHistory 
+
+    "
+     Class methodHistory
+    "
+
+    "Modified: 7.11.1996 / 18:36:00 / cg"
+    "Created: 7.11.1996 / 19:06:28 / cg"
+! !
+
 !ClassDescription class methodsFor:'enumeration '!
 
 allClassesInCategory:aCategory do:aBlock
@@ -722,68 +777,67 @@
     oldMethod := self compiledMethodAt:newSelector.
 
     CatchMethodRedefinitions ifTrue:[
-	"check for attempts to redefine a method
-	 in a different package. Signal a resumable error if so.
-	 This allows tracing redefinitions of existing system methods
-	 when filing in alien code ....
-	 (which we may want to forbit sometimes)
-	"
-	oldMethod notNil ifTrue:[
-	    oldPackage := oldMethod package.
-	    newPackage := newMethod package.
-	    oldPackage ~= newPackage ifTrue:[
-		"
-		 attempt to redefine an existing method, which was
-		 defined in another package (see oldPackage vs. newPackage).
-		 If you continue in the debugger, the new method gets installed.
-		 Otherwise, the existing (old) method remains valid.
-
-		 This check was added to help prevent accidental modifications
-		 of system code - especially, when alien code is filedIn. 
-		 After you became familiar with the system, may want to disable this
-		 check if it becomes too annoying (and only turn it on
-		 temporarily, when filing in unknown code-files).
-
-		 You can turn off the catching of redefinitions by setting
-		 my classVariable
-			  CatchMethodRedefinitions 
-		 to false.
-		 (also found in the Launchers 'settings-compilation' menu)
-		"
-		(Class methodRedefinitionSignal
-		    raiseRequestWith:(oldMethod -> newMethod)
-		    errorString:('redefinition of method: ' , self name , '>>' , newSelector) 
-		) == #keep ifTrue:[
-		    newMethod package:oldMethod package
-		].
-
-		"/ if proceeded, install as usual.
-	    ]
-	]
+        "check for attempts to redefine a method
+         in a different package. Signal a resumable error if so.
+         This allows tracing redefinitions of existing system methods
+         when filing in alien code ....
+         (which we may want to forbit sometimes)
+        "
+        oldMethod notNil ifTrue:[
+            oldPackage := oldMethod package.
+            newPackage := newMethod package.
+            oldPackage ~= newPackage ifTrue:[
+                "
+                 attempt to redefine an existing method, which was
+                 defined in another package (see oldPackage vs. newPackage).
+                 If you continue in the debugger, the new method gets installed.
+                 Otherwise, the existing (old) method remains valid.
+
+                 This check was added to help prevent accidental modifications
+                 of system code - especially, when alien code is filedIn. 
+                 After you became familiar with the system, may want to disable this
+                 check if it becomes too annoying (and only turn it on
+                 temporarily, when filing in unknown code-files).
+
+                 You can turn off the catching of redefinitions by setting
+                 my classVariable
+                          CatchMethodRedefinitions 
+                 to false.
+                 (also found in the Launchers 'settings-compilation' menu)
+                "
+                (Class methodRedefinitionSignal
+                    raiseRequestWith:(oldMethod -> newMethod)
+                    errorString:('redefinition of method: ' , self name , '>>' , newSelector) 
+                ) == #keep ifTrue:[
+                    newMethod package:oldMethod package
+                ].
+
+                "/ if proceeded, install as usual.
+            ]
+        ]
     ].
 
-    "/ remember new->old association in the OldMethods dictionary (if non-nil)
-
-    OldMethods notNil ifTrue:[
-	oldMethod notNil ifTrue:[
-"/            oldMethod source:(oldMethod source).
-	    OldMethods at:newMethod put:oldMethod
-	]
+    "/ remember new->old association in the MethodHistory dictionary (if non-nil)
+
+    MethodHistory notNil ifTrue:[
+        oldMethod notNil ifTrue:[
+            MethodHistory at:newMethod put:oldMethod
+        ]
     ].
 
     "/ remember in the projects overwritten dictionary
 
     oldMethod notNil ifTrue:[
-	oldMethod package ~= newMethod package ifTrue:[
-	    Project notNil ifTrue:[
-		"/ allow configurations without Project
-		Project rememberOverwrittenMethod:newMethod from:oldMethod
-	    ]
-	]
+        oldMethod package ~= newMethod package ifTrue:[
+            Project notNil ifTrue:[
+                "/ allow configurations without Project
+                Project rememberOverwrittenMethod:newMethod from:oldMethod
+            ]
+        ]
     ].
 
     (super addSelector:newSelector withMethod:newMethod) ifTrue:[
-	self addChangeRecordForMethod:newMethod.
+        self addChangeRecordForMethod:newMethod.
     ]
 
     "Modified: / 9.9.1996 / 22:39:32 / stefan"
@@ -3314,6 +3368,6 @@
 !ClassDescription class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Attic/ClassDescr.st,v 1.84 1999-07-04 16:50:09 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Attic/ClassDescr.st,v 1.85 1999-07-07 14:35:02 cg Exp $'
 ! !
 ClassDescription initialize!
--- a/ClassDescription.st	Wed Jul 07 14:48:19 1999 +0200
+++ b/ClassDescription.st	Wed Jul 07 16:35:02 1999 +0200
@@ -21,7 +21,7 @@
 		FileOutNameSpaceQuerySignal
 		ChangeDefaultApplicationNotificationSignal
 		DefaultApplicationQuerySignal
-		ClassConventionViolationConfirmationQuerySignal'
+		ClassConventionViolationConfirmationQuerySignal MethodHistory'
 	poolDictionaries:''
 	category:'Kernel-Classes'
 !
@@ -51,64 +51,71 @@
 
     [Instance variables:]
 
-	instvars        <String>            the names of the instance variables
+        instvars        <String>            the names of the instance variables
 
 
     [Class variables:]
 
-	UpdatingChanges <Boolean>       true if the changes-file shall be updated
-					(except during startup and when filing in, this flag
-					 is usually true)
-
-	UpdateChangeFileQuerySignal     used as an upQuery from the change management.
-					Whenever a changeRecord is to be written,
-					this signal is raised and a handler (if present)
-					is supposed to return true or false.
-					If unhandled, the value of the global
-					UpdatingChanges is returned for backward
-					compatibility (which means that the old
-					mechanism is used if no query-handler
-					is present).
-
-	LockChangesFile <Boolean>       if true, the change file is locked for updates.
-					Required when multiple users operate on a common
-					change file.
-					This is an experimental new feature, being evaluated.
-
-	FileOutErrorSignal              raised when an error occurs during fileOut
-
-	CatchMethodRedefinitions        if true, classes protect themself 
-	MethodRedefinitionSignal        (by raising MethodRedefinitionSignal)
-					from redefining any existing methods,
-					which are defined in another package.
-					(i.e. a signal will be raised, if you
-					 fileIn something which redefines an
-					 existing method and the packages do not
-					 match).
-					The default is (currently) true.
-
-	TryLocalSourceFirst             If true, local source files are tried
-					first BEFORE the sourceCodeManager is
-					consulted. If false, the sourceCodeManager
-					is asked first.
-					Should be turned on, if you run an image from
-					local sources which have not yet been checked in.
-
-	NameSpaceQuerySignal            used as an upQuery to ask for a namespace into
-					which new classes are to be installed.
-
-	PackageQuerySignal              used as an upQuery to ask for a packageSymbol with
-					which new classes/methods are to be marked.
-
-	CreateNameSpaceQuerySignal      used as an upQuery to ask if unknown namespaces
-					should be silently created (without asking the user)
-
+        UpdatingChanges <Boolean>       true if the changes-file shall be updated
+                                        (except during startup and when filing in, this flag
+                                         is usually true)
+
+        UpdateChangeFileQuerySignal     used as an upQuery from the change management.
+                                        Whenever a changeRecord is to be written,
+                                        this signal is raised and a handler (if present)
+                                        is supposed to return true or false.
+                                        If unhandled, the value of the global
+                                        UpdatingChanges is returned for backward
+                                        compatibility (which means that the old
+                                        mechanism is used if no query-handler
+                                        is present).
+
+        LockChangesFile <Boolean>       if true, the change file is locked for updates.
+                                        Required when multiple users operate on a common
+                                        change file.
+                                        This is an experimental new feature, being evaluated.
+
+        FileOutErrorSignal              raised when an error occurs during fileOut
+
+        CatchMethodRedefinitions        if true, classes protect themself 
+        MethodRedefinitionSignal        (by raising MethodRedefinitionSignal)
+                                        from redefining any existing methods,
+                                        which are defined in another package.
+                                        (i.e. a signal will be raised, if you
+                                         fileIn something which redefines an
+                                         existing method and the packages do not
+                                         match).
+                                        The default is (currently) true.
+
+        TryLocalSourceFirst             If true, local source files are tried
+                                        first BEFORE the sourceCodeManager is
+                                        consulted. If false, the sourceCodeManager
+                                        is asked first.
+                                        Should be turned on, if you run an image from
+                                        local sources which have not yet been checked in.
+
+        NameSpaceQuerySignal            used as an upQuery to ask for a namespace into
+                                        which new classes are to be installed.
+
+        PackageQuerySignal              used as an upQuery to ask for a packageSymbol with
+                                        which new classes/methods are to be marked.
+
+        CreateNameSpaceQuerySignal      used as an upQuery to ask if unknown namespaces
+                                        should be silently created (without asking the user)
+
+        MethodHistory                   if nonNil, this must be an IdentityDictionary,
+                                        which is filled with method->previousversionMethod
+                                        associations. Can be used for undo-last-method-change
+                                        The number of remembered methods is controlled via the
+                                        UserPreferences.
+                                        Notice: this may fillup your memory over time,
+                                        the preferences are set too high.
 
     [author:]
-	Claus Gittinger
+        Claus Gittinger
 
     [see also:]
-	Behavior Class Metaclass
+        Behavior Class Metaclass
 "
 ! !
 
@@ -396,6 +403,27 @@
     "Modified: / 17.6.1998 / 10:31:02 / cg"
 !
 
+keepMethodHistory:aBoolean
+    "turn on/off oldMethod remembering. If on, a methods previous version
+     is kept locally, for later undo (or compare)."
+
+    aBoolean ifTrue:[
+        MethodHistory isNil ifTrue:[
+            MethodHistory := OrderedDictionary new.
+        ]
+    ] ifFalse:[
+        MethodHistory := nil
+    ].
+
+    "
+     Class keepMethodHistory:true
+     Class keepMethodHistory:false
+    "
+
+    "Modified: 7.11.1996 / 18:36:00 / cg"
+    "Created: 7.11.1996 / 19:05:57 / cg"
+!
+
 lockChangesFile
     "return true, if the change file is locked during update"
 
@@ -412,6 +440,33 @@
     ^ prev
 ! !
 
+!ClassDescription class methodsFor:'accessing - history'!
+
+flushMethodHistory
+    "flush any method->previousVersion associations,
+     all method history is lost."
+
+    MethodHistory notNil ifTrue:[
+        MethodHistory := OrderedDictionary new
+    ].
+
+    "Created: 7.11.1996 / 19:07:25 / cg"
+!
+
+methodHistory
+    "return a dictionary containing method->previousVersion associations,
+     nil if method remembering has been turned off"
+
+    ^ MethodHistory 
+
+    "
+     Class methodHistory
+    "
+
+    "Modified: 7.11.1996 / 18:36:00 / cg"
+    "Created: 7.11.1996 / 19:06:28 / cg"
+! !
+
 !ClassDescription class methodsFor:'enumeration '!
 
 allClassesInCategory:aCategory do:aBlock
@@ -722,68 +777,67 @@
     oldMethod := self compiledMethodAt:newSelector.
 
     CatchMethodRedefinitions ifTrue:[
-	"check for attempts to redefine a method
-	 in a different package. Signal a resumable error if so.
-	 This allows tracing redefinitions of existing system methods
-	 when filing in alien code ....
-	 (which we may want to forbit sometimes)
-	"
-	oldMethod notNil ifTrue:[
-	    oldPackage := oldMethod package.
-	    newPackage := newMethod package.
-	    oldPackage ~= newPackage ifTrue:[
-		"
-		 attempt to redefine an existing method, which was
-		 defined in another package (see oldPackage vs. newPackage).
-		 If you continue in the debugger, the new method gets installed.
-		 Otherwise, the existing (old) method remains valid.
-
-		 This check was added to help prevent accidental modifications
-		 of system code - especially, when alien code is filedIn. 
-		 After you became familiar with the system, may want to disable this
-		 check if it becomes too annoying (and only turn it on
-		 temporarily, when filing in unknown code-files).
-
-		 You can turn off the catching of redefinitions by setting
-		 my classVariable
-			  CatchMethodRedefinitions 
-		 to false.
-		 (also found in the Launchers 'settings-compilation' menu)
-		"
-		(Class methodRedefinitionSignal
-		    raiseRequestWith:(oldMethod -> newMethod)
-		    errorString:('redefinition of method: ' , self name , '>>' , newSelector) 
-		) == #keep ifTrue:[
-		    newMethod package:oldMethod package
-		].
-
-		"/ if proceeded, install as usual.
-	    ]
-	]
+        "check for attempts to redefine a method
+         in a different package. Signal a resumable error if so.
+         This allows tracing redefinitions of existing system methods
+         when filing in alien code ....
+         (which we may want to forbit sometimes)
+        "
+        oldMethod notNil ifTrue:[
+            oldPackage := oldMethod package.
+            newPackage := newMethod package.
+            oldPackage ~= newPackage ifTrue:[
+                "
+                 attempt to redefine an existing method, which was
+                 defined in another package (see oldPackage vs. newPackage).
+                 If you continue in the debugger, the new method gets installed.
+                 Otherwise, the existing (old) method remains valid.
+
+                 This check was added to help prevent accidental modifications
+                 of system code - especially, when alien code is filedIn. 
+                 After you became familiar with the system, may want to disable this
+                 check if it becomes too annoying (and only turn it on
+                 temporarily, when filing in unknown code-files).
+
+                 You can turn off the catching of redefinitions by setting
+                 my classVariable
+                          CatchMethodRedefinitions 
+                 to false.
+                 (also found in the Launchers 'settings-compilation' menu)
+                "
+                (Class methodRedefinitionSignal
+                    raiseRequestWith:(oldMethod -> newMethod)
+                    errorString:('redefinition of method: ' , self name , '>>' , newSelector) 
+                ) == #keep ifTrue:[
+                    newMethod package:oldMethod package
+                ].
+
+                "/ if proceeded, install as usual.
+            ]
+        ]
     ].
 
-    "/ remember new->old association in the OldMethods dictionary (if non-nil)
-
-    OldMethods notNil ifTrue:[
-	oldMethod notNil ifTrue:[
-"/            oldMethod source:(oldMethod source).
-	    OldMethods at:newMethod put:oldMethod
-	]
+    "/ remember new->old association in the MethodHistory dictionary (if non-nil)
+
+    MethodHistory notNil ifTrue:[
+        oldMethod notNil ifTrue:[
+            MethodHistory at:newMethod put:oldMethod
+        ]
     ].
 
     "/ remember in the projects overwritten dictionary
 
     oldMethod notNil ifTrue:[
-	oldMethod package ~= newMethod package ifTrue:[
-	    Project notNil ifTrue:[
-		"/ allow configurations without Project
-		Project rememberOverwrittenMethod:newMethod from:oldMethod
-	    ]
-	]
+        oldMethod package ~= newMethod package ifTrue:[
+            Project notNil ifTrue:[
+                "/ allow configurations without Project
+                Project rememberOverwrittenMethod:newMethod from:oldMethod
+            ]
+        ]
     ].
 
     (super addSelector:newSelector withMethod:newMethod) ifTrue:[
-	self addChangeRecordForMethod:newMethod.
+        self addChangeRecordForMethod:newMethod.
     ]
 
     "Modified: / 9.9.1996 / 22:39:32 / stefan"
@@ -3314,6 +3368,6 @@
 !ClassDescription class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ClassDescription.st,v 1.84 1999-07-04 16:50:09 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ClassDescription.st,v 1.85 1999-07-07 14:35:02 cg Exp $'
 ! !
 ClassDescription initialize!